diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 6979c49aabc..b59c311eb2f 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -44,7 +44,7 @@ $actionsave=GETPOST('save', 'alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -// List of aviable colors +// List of available colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 2a0a66fe269..44cdd5e611b 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,5 +1,4 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand @@ -28,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; @@ -38,6 +38,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); +$actionsave=GETPOST('save', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -60,7 +61,7 @@ if ($action == 'setbankorder') { } } -//Auto report last num releve on conciliate +// Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -82,6 +83,58 @@ elseif ($action == 'unsetreportlastnumreleve') { } } +// Colorize movements +if ($action == 'setbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} +elseif ($action == 'unsetbankcolorizemovement') { + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +if ($actionsave) +{ + $db->begin(); + + $i=1; $errorsaved=0; + $error=0; + + // Save colors + while ($i <= 2) + { + $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); + if ($color=='-1') $color=''; + + $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (! $res > 0) $error++; + $i++; + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + if ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -157,10 +210,11 @@ elseif ($action == 'setdoc') { /* - * view + * View */ $form = new Form($db); +$formother=new FormOther($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -169,6 +223,10 @@ llxHeader("", $langs->trans("BankSetupModule")); $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); +print '
'; +print ''; +print ''; + $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); @@ -372,7 +430,56 @@ foreach ($dirmodels as $reldir) { print ''; //} +print '

'; +print load_fiche_titre($langs->trans("BankColorizeMovement"), '', ''); +print ''; +print "\n"; +print ''; +print ''."\n"; +print "\n"; + +print '"; +// Active +if ($conf->global->BANK_COLORIZE_MOVEMENT) { + print ''; +} +else +{ + print '"; +} + +print "\n"; + +if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) +{ + $i=1; + while ($i <= 2) + { + $key=$i; + $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key; + + print ''; + + // Label + print '"; + // Color + print ''; + print ""; + $i++; + } +} +print '
' . $langs->trans("Name") . ''.$langs->trans("Value").'
'; +print $langs->trans('BankColorizeMovementDesc'); +print "' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print "
'.$langs->trans("BankColorizeMovementName".$key)."'; + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print '
'; print '

'; @@ -384,7 +491,6 @@ print '

'; //{ print load_fiche_titre($langs->trans("Other"), '', ''); - print "\n"; print "\n"; print ''; @@ -416,6 +522,12 @@ print "\n"; print '
' . $langs->trans("Name") . '
'; dol_fiche_end(); +print '
'; +print ''; +print '
'; + +print "
\n"; + // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 6d1b640f45b..64e784ece9d 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -116,7 +116,7 @@ if (empty($reshook)) if (GETPOST('addfilter', 'alpha')) { $emailcollectorfilter = new EmailCollectorFilter($db); - $emailcollectorfilter->type = GETPOST('filtertype', 'az09'); + $emailcollectorfilter->type = GETPOST('filtertype', 'aZ09'); $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha'); $emailcollectorfilter->fk_emailcollector = $object->id; $emailcollectorfilter->status = 1; @@ -150,7 +150,7 @@ if ($action == 'deletefilter') if (GETPOST('addoperation', 'alpha')) { $emailcollectoroperation = new EmailCollectorAction($db); - $emailcollectoroperation->type = GETPOST('operationtype', 'az09'); + $emailcollectoroperation->type = GETPOST('operationtype', 'aZ09'); $emailcollectoroperation->actionparam = GETPOST('operationparam', 'none'); $emailcollectoroperation->fk_emailcollector = $object->id; $emailcollectoroperation->status = 1; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 8d102bc8328..013db3d36f1 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -63,8 +63,6 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("expensereports"); - llxHeader('', $langs->trans("ExpenseReportsSetup")); $linkback=''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php new file mode 100644 index 00000000000..b9c32a8b9c9 --- /dev/null +++ b/htdocs/admin/holiday_extrafields.php @@ -0,0 +1,118 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/holiday_extrafields.php + * \ingroup holiday + * \brief Page to setup extra fields of holiday + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +if (!$user->admin) + accessforbidden(); + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'errors', 'holiday', 'other')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='holiday'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +llxHeader('', $langs->trans("HolidaySetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); + +$head = holiday_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("Holidays"), -1, 'holiday'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index b62009c2ba6..b5f22376c16 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -50,7 +50,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmatio $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'alpha'); -$search_label=GETPOST('search_label', 'alpha'); +$search_label=GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)' $search_type_template=GETPOST('search_type_template', 'alpha'); $search_lang=GETPOST('search_lang', 'alpha'); $search_fk_user=GETPOST('search_fk_user', 'intcomma'); @@ -263,6 +263,7 @@ if (empty($reshook)) { //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); $keycode=$listfieldvalue[$i]; + if ($value == 'label') $_POST[$keycode] = dol_escape_htmltag($_POST[$keycode]); if ($value == 'lang') $keycode='langcode'; if ($value == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; @@ -667,8 +668,6 @@ if ($resql) print ''; foreach ($fieldlist as $field => $value) { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees $showfield=1; // By defaut $align="left"; $sortable=1; @@ -695,7 +694,7 @@ if ($resql) if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;} if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; } - // Affiche nom du champ + // Show fields if ($showfield) { if (! empty($tabhelp[$id][$value])) @@ -813,6 +812,10 @@ if ($resql) $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; + if ($value == 'label' || $value == 'topic') + { + $valuetoshow = dol_escape_htmltag($valuetoshow); + } if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index a5a0b5fbf3f..3dfd8e1e2c2 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -127,6 +127,15 @@ print ''; print ''; print ''; + +print ''; +print ''.$langs->trans('EnableResourceUsedInEventCheck').''; +print ''; +echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); +print ''; +print ''; +print ''; + print ''; print ''; diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 8bd64c76e2b..57dc1cbb394 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -96,11 +96,11 @@ else trans("Login"); ?> - + trans("Password"); ?> - + '.$langs->trans("CashDeskBankAccountForSell").''; print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cash') > 0)?GETPOST('bankid_cash'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cash') > 0)?GETPOST('bankid_cash'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown?0:2)); print ''; print "\n"; @@ -166,7 +166,7 @@ print ''.$langs->trans("CashDeskBankAccountForCheque").' print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cheque') > 0)?GETPOST('bankid_cheque'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cheque') > 0)?GETPOST('bankid_cheque'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown?0:2)); print ''; print "\n"; @@ -175,7 +175,7 @@ print ''.$langs->trans("CashDeskBankAccountForCB").''; print ''; $defaultknown=0; if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) $defaultknown=1; // If a particular stock is defined, we disable choice -print $form->select_comptes(((GETPOST('bankid_cb') > 0)?GETPOST('bankid_cb'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown?0:2)); +$form->select_comptes(((GETPOST('bankid_cb') > 0)?GETPOST('bankid_cb'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown?0:2)); print ''; print "\n"; @@ -191,7 +191,7 @@ print "\n";
-
+
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 67ef7905235..787e158670f 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -36,7 +36,7 @@ $langs->load("categories"); $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); -$type = GETPOST('type', 'az09'); +$type = GETPOST('type', 'aZ09'); $removeelem = GETPOST('removeelem', 'int'); $elemid = GETPOST('elemid', 'int'); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 003203940a8..173770d725c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -512,6 +512,65 @@ if ($action == 'update') $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error++; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) . "'"; + $sql .= " WHERE ac.id != " . $object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . "element_resources"; + $sql .= " WHERE element_id = " . $object->id; + $sql .= " AND element_type = '" . $db->escape($object->element) . "'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + if (! $error) { $db->begin(); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 12926f9b360..3c138043d26 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -657,7 +657,7 @@ class ActionComm extends CommonObject $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->contactid = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_project method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 48165361d7c..a2328dd9ca4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -87,7 +87,7 @@ $week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); $day=GETPOST("day", "int")?GETPOST("day", "int"):date("d"); $pid=GETPOST("search_projectid", "int", 3)?GETPOST("search_projectid", "int", 3):GETPOST("projectid", "int", 3); $status=GETPOST("search_status", 'aZ09')?GETPOST("search_status", 'aZ09'):GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' -$type=GETPOST("search_type", 'az09')?GETPOST("search_type", 'az09'):GETPOST("type", 'az09'); +$type=GETPOST("search_type", 'aZ09')?GETPOST("search_type", 'aZ09'):GETPOST("type", 'aZ09'); $maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) @@ -607,9 +607,7 @@ if ($resql) $event->fk_element=$obj->fk_element; $event->elementtype=$obj->elementtype; - $event->societe->id=$obj->fk_soc; $event->thirdparty_id=$obj->fk_soc; - $event->contact->id=$obj->fk_contact; $event->contact_id=$obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property @@ -1569,28 +1567,31 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code == 'ICALEVENT') print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; + $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); + $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->cotact->id > 0) ? $event->contact->id : 0)); + // If action related to company / contact $linerelatedto=''; - if (! empty($event->societe->id) && $event->societe->id > 0) + if ($thirdparty_id > 0) { - if (! isset($cachethirdparties[$event->societe->id]) || ! is_object($cachethirdparties[$event->societe->id])) + if (! isset($cachethirdparties[$thirdparty_id]) || ! is_object($cachethirdparties[$thirdparty_id])) { $thirdparty=new Societe($db); - $thirdparty->fetch($event->societe->id); - $cachethirdparties[$event->societe->id]=$thirdparty; + $thirdparty->fetch($thirdparty_id); + $cachethirdparties[$thirdparty_id]=$thirdparty; } - else $thirdparty=$cachethirdparties[$event->societe->id]; + else $thirdparty=$cachethirdparties[$thirdparty_id]; if (! empty($thirdparty->id)) $linerelatedto.=$thirdparty->getNomUrl(1, '', 0); } - if (! empty($event->contact->id) && $event->contact->id > 0) + if (! empty($contact_id) && $contact_id > 0) { - if (! is_object($cachecontacts[$event->contact->id])) + if (! is_object($cachecontacts[$contact_id])) { $contact=new Contact($db); - $contact->fetch($event->contact->id); - $cachecontacts[$event->contact->id]=$contact; + $contact->fetch($contact_id); + $cachecontacts[$contact_id]=$contact; } - else $contact=$cachecontacts[$event->contact->id]; + else $contact=$cachecontacts[$contact_id]; if ($linerelatedto) $linerelatedto.=' '; if (! empty($contact->id)) $linerelatedto.=$contact->getNomUrl(1, '', 0); } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index a8002c179be..da8b110abd2 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Frédéric France * @@ -1110,7 +1110,27 @@ if ($resql) $bankaccount = $cachebankaccount[$objp->bankid]; } - print ''; + if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) { + $backgroundcolor = "class='oddeven'"; + } else { + if ($objp->amount < 0) + { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) { + $color = '#fca955'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } else { + if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { + $color = '#7fdb86'; + } else { + $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; + } + $backgroundcolor = 'style="background-color: ' . $color . ';"'; + } + } + print ''; // Ref if (! empty($arrayfields['b.rowid']['checked'])) @@ -1356,7 +1376,7 @@ if ($resql) // Debit if (! empty($arrayfields['b.debit']['checked'])) { - print ''; + print ''; if ($objp->amount < 0) { print price($objp->amount * -1); @@ -1370,7 +1390,7 @@ if ($resql) // Credit if (! empty($arrayfields['b.credit']['checked'])) { - print ''; + print ''; if ($objp->amount > 0) { print price($objp->amount); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 2b04f83472f..3345fe6ee3e 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -323,7 +323,7 @@ if ($result) print ''; if (! $objp->rappro && ! $bankline->getVentilExportCompta()) { - print $form->select_comptes($acct->id, 'accountid', 0, '', 0); + $form->select_comptes($acct->id, 'accountid', 0, '', 0); } else { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff5a280a118..6b24807c007 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4982,7 +4982,7 @@ elseif ($id > 0 || ! empty($ref)) } // Classify paid - if ($object->statut == 1 && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) + if (($object->statut == 1 && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) ) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 79745113f88..9709eed637d 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -321,7 +321,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && ! $page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d54d2dd02ff..6cd98f00e48 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -384,6 +384,10 @@ if (! $error && $massaction == 'confirm_presend') foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object { // Make substitution in email content + if (! empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) + { + $objecttmp->fetch_projet(); + } $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 836652ea819..de3a43d9ce6 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -113,8 +113,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $result=$object->fetch($id); - $sendtosocid=0; // Thirdparty on object - if (method_exists($object, "fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) + $sendtosocid=0; // Id of related thirdparty + if (method_exists($object, "fetch_thirdparty") && ! in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact'))) { $result=$object->fetch_thirdparty(); if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok @@ -124,7 +124,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO elseif ($object->element == 'member' || $object->element == 'user') { $thirdparty=$object; - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; + if ($object->socid > 0) $sendtosocid=$object->socid; + } + elseif ($object->element == 'expensereport') + { + $tmpuser=new User($db); + $tmpuser->fetch($object->fk_user_author); + $thirdparty=$tmpuser; + if ($object->socid > 0) $sendtosocid=$object->socid; } elseif ($object->element == 'societe') { @@ -136,7 +143,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $contact=$object; if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; } - else dol_print_error('', 'Use actions_sendmails.in.php for an element/object that is not supported'); + else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); if (is_object($hookmanager)) { @@ -162,6 +169,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($receiver == '-1') $receiver=array(); else $receiver=array($receiver); } + $tmparray=array(); if (trim($_POST['sendto'])) { @@ -173,22 +181,23 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO foreach($receiver as $key=>$val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party + if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too) { - $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>'; } // Recipient was provided from combo list - elseif ($val == 'contact') // Id of contact + elseif ($val == 'contact') // Key selected means current contact { - $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; + $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // Id du contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = $val; } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $receiveruser=$_POST['receiveruser']; @@ -222,16 +231,16 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO foreach($receivercc as $key=>$val) { // Recipient was provided from combo list - if ($val == 'thirdparty') // Id of third party + if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too) { $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } // Recipient was provided from combo list - elseif ($val == 'contact') // Id of contact + elseif ($val == 'contact') // Key selected means current contact { $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; } - elseif ($val) // Id du contact + elseif ($val) // $val is the Id of a contact { $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = $val; TODO Add also id of contact in CC ? @@ -414,27 +423,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$mailfile->sendfile(); if ($result) { - // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required - /* - if (! empty($conf->dolimail->enabled)) - { - $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? - if ($mid) - { - // set imap flag answered if it is an answered mail - $dolimail=new DoliMail($db); - $dolimail->id = $mid; - $res=$dolimail->set_prop($user, 'answered',1); - } - if ($imap==1) - { - // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); - if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); - } - }*/ - // Initialisation of datas of object to call trigger if (is_object($object)) { diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 994b604ae78..67718e7fb8e 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -71,14 +71,14 @@ class box_actions extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $societestatic = new Societe($db); - $actionstatic = new ActionComm($db); + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); @@ -99,20 +99,20 @@ class box_actions extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; $sql.= " ORDER BY a.datec DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog("Box_actions::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { $now=dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { $late = ''; - $objp = $db->fetch_object($result); - $datelimite = $db->jdate($objp->dp); + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->dp); $actionstatic->id = $objp->id; $actionstatic->label = $objp->label; $actionstatic->type_label = $objp->type_label; @@ -164,12 +164,12 @@ class box_actions extends ModeleBoxes 'text'=>$langs->trans("NoActionsToDo"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 72116993505..0b690240db6 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -76,7 +76,7 @@ class box_activity extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -103,7 +103,7 @@ class box_activity extends ModeleBoxes if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + $propalstatic=new Propal($this->db); $cachedir = DOL_DATA_ROOT.'/propale/temp'; $filename = '/boxactivity-propal'.$fileid; @@ -119,27 +119,27 @@ class box_activity extends ModeleBoxes $sql.= " AND p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; + $sql.= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; $sql.= " AND p.date_cloture IS NULL"; // just unclosed $sql.= " GROUP BY p.fk_statut"; $sql.= " ORDER BY p.fk_statut DESC"; - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else @@ -190,7 +190,7 @@ class box_activity extends ModeleBoxes // list the summary of the orders if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $commandestatic=new Commande($db); + $commandestatic=new Commande($this->db); $langs->load("orders"); @@ -209,24 +209,24 @@ class box_activity extends ModeleBoxes $sql.= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'"; + $sql.= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; $sql.= " GROUP BY c.fk_statut"; $sql.= " ORDER BY c.fk_statut DESC"; - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); @@ -275,7 +275,7 @@ class box_activity extends ModeleBoxes if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($db); + $facturestatic=new Facture($this->db); // part 1 $cachedir = DOL_DATA_ROOT.'/facture/temp'; @@ -293,24 +293,24 @@ class box_activity extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; + $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); @@ -373,24 +373,24 @@ class box_activity extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; + $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index f15c5c8d1cb..8204543540e 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -71,13 +71,13 @@ class box_birthdays extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db; + global $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic=new User($db); + $userstatic=new User($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); @@ -89,23 +89,23 @@ class box_birthdays extends ModeleBoxes $sql.= " WHERE u.entity IN (".getEntity('user').")"; $sql.= " AND MONTH(u.birth) = ".date('m'); $sql.= " ORDER BY u.birth ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $userstatic->id = $objp->rowid; $userstatic->firstname = $objp->firstname; $userstatic->lastname = $objp->lastname; $userstatic->email = $objp->email; - $dateb=$db->jdate($objp->birth); + $dateb=$this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -129,13 +129,13 @@ class box_birthdays extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedUsers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 446b74a184c..45f64adce42 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -71,42 +71,42 @@ class box_birthdays_members extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db; + global $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($db); + $memberstatic=new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { $sql = "SELECT u.rowid, u.firstname, u.lastname"; - $sql.= ", u.birth"; + $sql.= ", u.birth"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql.= " AND u.statut = 1"; - $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; + $sql.= " AND u.statut = 1"; + $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; $sql.= " ORDER BY date_format(u.birth, '%m-%d') ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $memberstatic->id = $objp->rowid; $memberstatic->firstname = $objp->firstname; $memberstatic->lastname = $objp->lastname; $memberstatic->email = $objp->email; - $dateb=$db->jdate($objp->birth); + $dateb=$this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -130,13 +130,13 @@ class box_birthdays_members extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedUsers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index bb35c311f00..6edd7fa9866 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -67,7 +67,7 @@ class box_bookmarks extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; @@ -92,18 +92,18 @@ class box_bookmarks extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql.= " WHERE fk_user = ".$user->id; $sql.= " AND b.entity = ".$conf->entity; - $sql.= $db->order("position", "ASC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("position", "ASC"); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', @@ -133,12 +133,12 @@ class box_bookmarks extends ModeleBoxes ); } - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index ea2a7814f14..858a99921f3 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -74,13 +74,13 @@ class box_clients extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); @@ -103,20 +103,20 @@ class box_clients extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id"; $sql.= " ORDER BY s.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -149,13 +149,13 @@ class box_clients extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index e0d7d1fee4d..9084b6ad71a 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -71,16 +71,16 @@ class box_commandes extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $commandestatic = new Commande($db); - $societestatic = new Societe($db); - $userstatic = new User($db); + $commandestatic = new Commande($this->db); + $societestatic = new Societe($this->db); + $userstatic = new User($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders", $max)); @@ -110,18 +110,18 @@ class box_commandes extends ModeleBoxes if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->date_commande); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $date=$this->db->jdate($objp->date_commande); + $datem=$this->db->jdate($objp->tms); $commandestatic->id = $objp->rowid; $commandestatic->ref = $objp->ref; $commandestatic->ref_client = $objp->ref_client; @@ -174,12 +174,12 @@ class box_commandes extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 1928ac7cc94..4cd053b82fc 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -77,7 +77,7 @@ class box_comptes extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -97,19 +97,19 @@ class box_comptes extends ModeleBoxes $sql.= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql.= " ORDER BY label"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $solde_total = array(); - $account_static = new Account($db); + $account_static = new Account($this->db); while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; @@ -160,12 +160,12 @@ class box_comptes extends ModeleBoxes $line++; } - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 667f892bc0a..02f62324200 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -73,7 +73,7 @@ class box_contacts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; @@ -93,21 +93,21 @@ class box_contacts extends ModeleBoxes if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); - $contactstatic=new Contact($db); - $societestatic=new Societe($db); + $contactstatic=new Contact($this->db); + $societestatic=new Societe($this->db); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $contactstatic->id=$objp->id; $contactstatic->lastname=$objp->lastname; @@ -161,12 +161,12 @@ class box_contacts extends ModeleBoxes 'text'=>$langs->trans("NoRecordedContacts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 43ade84ad20..eb4a8c44ed0 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -70,7 +70,7 @@ class box_contracts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -80,11 +80,12 @@ class box_contracts extends ModeleBoxes if ($user->rights->contrat->lire) { - $contractstatic=new Contrat($db); - $thirdpartytmp=new Societe($db); + $contractstatic=new Contrat($this->db); + $thirdpartytmp=new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql.= ", c.ref_customer, c.ref_supplier"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; @@ -93,12 +94,12 @@ class box_contracts extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=dol_now(); $line = 0; @@ -107,16 +108,18 @@ class box_contracts extends ModeleBoxes while ($line < $num) { - $objp = $db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $datec=$this->db->jdate($objp->datec); + $dateterm=$this->db->jdate($objp->fin_validite); + $dateclose=$this->db->jdate($objp->date_cloture); $late = ''; $contractstatic->statut=$objp->fk_statut; $contractstatic->id=$objp->rowid; $contractstatic->ref=$objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; $result=$contractstatic->fetch_lines(); $thirdpartytmp->name = $objp->name; @@ -165,12 +168,12 @@ class box_contracts extends ModeleBoxes 'text'=>$langs->trans("NoRecordedContracts"), ); - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 05ab5db50fd..fd1203ac520 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -69,15 +69,15 @@ class box_factures extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($db); - $societestatic = new Societe($db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -105,22 +105,22 @@ class box_factures extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite = $db->jdate($objp->datelimite); - $date = $db->jdate($objp->df); - $datem = $db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; @@ -129,7 +129,7 @@ class box_factures extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -185,12 +185,12 @@ class box_factures extends ModeleBoxes 'text'=>$langs->trans("NoRecordedInvoices"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9d2e8e995e3..05cd900623e 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -70,15 +70,15 @@ class box_factures_fourn extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $facturestatic = new FactureFournisseur($db); - $thirdpartytmp = new Fournisseur($db); + $facturestatic = new FactureFournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills", $max) @@ -87,7 +87,7 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_fournisseur,"; + $sql.= " s.code_fournisseur, s.email,"; $sql.= " s.logo,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; $sql.= " f.total_ht,"; @@ -106,21 +106,21 @@ class box_factures_fourn extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); - $date=$db->jdate($objp->df); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datelimite=$this->db->jdate($objp->datelimite); + $date=$this->db->jdate($objp->df); + $datem=$this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; @@ -133,6 +133,7 @@ class box_factures_fourn extends ModeleBoxes $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; $thirdpartytmp->fournisseur = 1; $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; @@ -173,7 +174,7 @@ class box_factures_fourn extends ModeleBoxes 'text' => dol_print_date($date, 'day'), ); - $fac = new FactureFournisseur($db); + $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); $this->info_box_contents[$line][] = array( @@ -190,12 +191,12 @@ class box_factures_fourn extends ModeleBoxes 'text'=>$langs->trans("NoModifiedSupplierBills"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index a28f275dc96..b6066255a17 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -69,14 +69,14 @@ class box_factures_fourn_imp extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $facturestatic=new FactureFournisseur($db); + $facturestatic=new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($db); + $thirdpartytmp=new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); @@ -99,24 +99,24 @@ class box_factures_fourn_imp extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY datelimite DESC, f.ref_supplier DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); - $date=$db->jdate($objp->df); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datelimite=$this->db->jdate($objp->datelimite); + $date=$this->db->jdate($objp->df); + $datem=$this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; @@ -160,7 +160,7 @@ class box_factures_fourn_imp extends ModeleBoxes 'text' => dol_print_date($datelimite, 'day'), ); - $fac = new FactureFournisseur($db); + $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); $this->info_box_contents[$line][] = array( @@ -177,12 +177,12 @@ class box_factures_fourn_imp extends ModeleBoxes 'text'=>$langs->trans("NoUnpaidSupplierBills"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 5dfa6c8c492..9880d236a8e 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -72,15 +72,15 @@ class box_factures_imp extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($db); - $societestatic = new Societe($db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max)); @@ -111,12 +111,12 @@ class box_factures_imp extends ModeleBoxes $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql.= " ORDER BY datelimite ASC, f.ref ASC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; @@ -124,8 +124,8 @@ class box_factures_imp extends ModeleBoxes while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); + $objp = $this->db->fetch_object($result); + $datelimite=$this->db->jdate($objp->datelimite); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->type = $objp->type; @@ -133,7 +133,7 @@ class box_factures_imp extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -180,14 +180,14 @@ class box_factures_imp extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 8311ae7226c..2755e7a3f0d 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -70,12 +70,13 @@ class box_ficheinter extends ModeleBoxes */ public function loadBox($max = 10) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $ficheinterstatic=new Fichinter($db); + $ficheinterstatic=new Fichinter($this->db); + $companystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); @@ -85,7 +86,7 @@ class box_ficheinter extends ModeleBoxes $sql.= " f.datec,"; $sql.= " f.date_valid as datev,"; $sql.= " f.tms as datem,"; - $sql.= " s.nom as name, s.rowid as socid, s.client"; + $sql.= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; @@ -94,42 +95,40 @@ class box_ficheinter extends ModeleBoxes if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY f.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=dol_now(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); $ficheinterstatic->statut=$objp->fk_statut; $ficheinterstatic->id=$objp->rowid; $ficheinterstatic->ref=$objp->ref; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->semail; + $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $ficheinterstatic->getNomUrl(1), 'asis' => 1, ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, - ); - $this->info_box_contents[$i][] = array( 'td' => '', - 'text' => dol_trunc($objp->name, 40), - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( @@ -148,14 +147,14 @@ class box_ficheinter extends ModeleBoxes if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions")); - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 8d231cc472b..ff73e80b21c 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -70,15 +70,15 @@ class box_fournisseurs extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($db); + $thirdpartytmp=new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); @@ -94,19 +94,19 @@ class box_fournisseurs extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY s.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->code_client = $objp->code_client; @@ -136,12 +136,12 @@ class box_fournisseurs extends ModeleBoxes 'text'=>$langs->trans("NoRecordedSuppliers"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ea973caf773..3f0cea0651a 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -76,13 +76,13 @@ class box_goodcustomers extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); @@ -90,25 +90,25 @@ class box_goodcustomers extends ModeleBoxes { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; + $sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql.= ' AND s.rowid = f.fk_soc'; $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; - $sql.= $db->order("nbfact", "DESC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("nbfact", "DESC"); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->rowid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -145,13 +145,13 @@ class box_goodcustomers extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 6e5afe5df99..b83630f8916 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -65,14 +65,14 @@ class box_graph_invoices_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - //$facturestatic=new Facture($db); + //$facturestatic=new Facture($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index df4f4afc146..0b395946731 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -65,7 +65,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index b530b4ea268..1a1e29fb47a 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -65,14 +65,14 @@ class box_graph_orders_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - //$commandestatic=new Commande($db); + //$commandestatic=new Commande($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 8359ddbe070..da956670779 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -65,7 +65,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index d32c9bb1918..dac5137938a 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -72,7 +72,7 @@ class box_graph_product_distribution extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 36a35c3bbc2..98b12cf65f4 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -65,14 +65,14 @@ class box_graph_propales_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - //$propalstatic=new Propal($db); + //$propalstatic=new Propal($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index e9f00049e04..4de36596cc7 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -47,11 +47,14 @@ class box_last_modified_ticket extends ModeleBoxes /** * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters */ - public function __construct() + public function __construct($db, $param = '') { global $langs; - $langs->load("boxes"); + $langs->load("boxes"); + $this->db = $db; $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); } @@ -64,7 +67,7 @@ class box_last_modified_ticket extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max = $max; @@ -72,8 +75,8 @@ class box_last_modified_ticket extends ModeleBoxes $text = $langs->trans("BoxLastModifiedTicketDescription", $max); $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) + 'text' => $text, + 'limit' => dol_strlen($text) ); $this->info_box_contents[0][0] = array( @@ -99,20 +102,20 @@ class box_last_modified_ticket extends ModeleBoxes } $sql.= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=gmmktime(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $objp = $this->db->fetch_object($resql); + $datec=$this->db->jdate($objp->datec); + $dateterm=$this->db->jdate($objp->fin_validite); + $dateclose=$this->db->jdate($objp->date_cloture); $late = ''; $ticket = new Ticket($this->db); @@ -157,7 +160,7 @@ class box_last_modified_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($db->idate($objp->datec), 'dayhour') + 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour') ); $r++; @@ -177,7 +180,7 @@ class box_last_modified_ticket extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); } } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array( diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 352a10db682..708c4e97633 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -46,11 +46,14 @@ class box_last_ticket extends ModeleBoxes /** * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters */ - public function __construct() + public function __construct($db, $param = '') { global $langs; $langs->load("boxes"); + $this->db = $db; $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); } @@ -63,7 +66,7 @@ class box_last_ticket extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max = $max; @@ -100,20 +103,20 @@ class box_last_ticket extends ModeleBoxes //$sql.= " AND t.fk_statut > 9"; $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $db->plimit($max, 0); + $sql .= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now = gmmktime(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec = $db->jdate($objp->datec); - $dateterm = $db->jdate($objp->fin_validite); - $dateclose = $db->jdate($objp->date_cloture); + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; $ticket = new Ticket($this->db); @@ -156,7 +159,7 @@ class box_last_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($db->idate($objp->datec), 'dayhour'), + 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour'), ); $r++; @@ -176,7 +179,7 @@ class box_last_ticket extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); } } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array('td' => 'class="left"', diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 8a5b90ae9d5..997f3b8ca26 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -68,7 +68,7 @@ class box_lastlogin extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $textHead = $langs->trans("BoxLoginInformation"); $this->info_box_head = array( diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index b0f1200dec7..20bf6ca136f 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -76,13 +76,13 @@ class box_members extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($db); + $memberstatic=new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); @@ -95,19 +95,19 @@ class box_members extends ModeleBoxes $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; @@ -142,7 +142,7 @@ class box_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $db->jdate($objp->date_end_subscription), 3), + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), ); $line++; @@ -154,12 +154,12 @@ class box_members extends ModeleBoxes 'text'=>$langs->trans("NoRecordedCustomers"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 68c1b4c790b..0f094c5369e 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -75,12 +75,12 @@ class box_produits extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf, $hookmanager; + global $user, $langs, $conf, $hookmanager; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($db); + $productstatic=new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); @@ -98,18 +98,18 @@ class box_produits extends ModeleBoxes $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; } - $sql.= $db->order('p.datec', 'DESC'); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order('p.datec', 'DESC'); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); // Multilangs if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -120,10 +120,10 @@ class box_produits extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') $objp->label = $objtp->label; } @@ -202,12 +202,12 @@ class box_produits extends ModeleBoxes 'text'=>$langs->trans("NoRecordedProducts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 095709c2ea8..4f285c990cc 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -77,19 +77,19 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf, $hookmanager; + global $user, $langs, $conf, $hookmanager; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($db); + $productstatic=new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; - $sql.= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; + $sql.= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; @@ -104,19 +104,19 @@ class box_produits_alerte_stock extends ModeleBoxes $sql.=$hookmanager->resPrint; } $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; - $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; - $sql.= $db->order('p.seuil_stock_alerte', 'DESC'); - $sql.= $db->plimit($max, 0); + $sql.= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + $sql.= $this->db->order('p.seuil_stock_alerte', 'DESC'); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { $langs->load("stocks"); - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); $price = ''; $price_base_type = ''; @@ -129,10 +129,10 @@ class box_produits_alerte_stock extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') $objp->label = $objtp->label; } @@ -214,14 +214,14 @@ class box_produits_alerte_stock extends ModeleBoxes 'text'=>$langs->trans("NoTooLowStockProducts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 3cd36c470fe..f1265bc6658 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -72,7 +72,7 @@ class box_project extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; @@ -102,15 +102,15 @@ class box_project extends ModeleBoxes if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; - //$sql.= $db->plimit($max, 0); + //$sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $i = 0; while ($i < min($num, $max)) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; $projectstatic->ref = $objp->ref; @@ -132,9 +132,9 @@ class box_project extends ModeleBoxes $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; $sql.= " WHERE p.entity IN (".getEntity('project').')'; $sql.=" AND p.rowid = ".$objp->rowid; - $resultTask = $db->query($sql); + $resultTask = $this->db->query($sql); if ($resultTask) { - $objTask = $db->fetch_object($resultTask); + $objTask = $this->db->fetch_object($resultTask); $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f486463a32a..3b138eacd47 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -71,14 +71,14 @@ class box_propales extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $propalstatic=new Propal($db); - $societestatic = new Societe($db); + $propalstatic=new Propal($this->db); + $societestatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals", $max)); @@ -95,23 +95,23 @@ class box_propales extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->dp); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $objp = $this->db->fetch_object($result); + $date=$this->db->jdate($objp->dp); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); + $dateterm=$this->db->jdate($objp->fin_validite); + $dateclose=$this->db->jdate($objp->date_cloture); $propalstatic->id = $objp->rowid; $propalstatic->ref = $objp->ref; $propalstatic->total_ht = $objp->total_ht; @@ -164,12 +164,12 @@ class box_propales extends ModeleBoxes 'text'=>$langs->trans("NoRecordedProposals"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 947ebc18b52..3011234a3fb 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -76,11 +76,11 @@ class box_prospect extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; - $thirdpartystatic=new Client($db); + $thirdpartystatic=new Client($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); @@ -100,20 +100,20 @@ class box_prospect extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY s.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($resql); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -153,12 +153,12 @@ class box_prospect extends ModeleBoxes ); } - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength' => 500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index eaca6dc1548..3d852c7a190 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -71,22 +71,22 @@ class box_services_contracts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $form = new Form($db); + $form = new Form($this->db); $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max)); if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic=new Contrat($db); - $contractlinestatic=new ContratLigne($db); - $thirdpartytmp = new Societe($db); - $productstatic = new Product($db); + $contractstatic=new Contrat($this->db); + $contractlinestatic=new ContratLigne($this->db); + $thirdpartytmp = new Societe($this->db); + $productstatic = new Product($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; @@ -100,21 +100,21 @@ class box_services_contracts extends ModeleBoxes $sql.= ")"; $sql.= " WHERE c.entity = ".$conf->entity; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= $db->order("c.tms", "DESC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("c.tms", "DESC"); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->datem); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->datem); $contractlinestatic->id=$objp->cdid; $contractlinestatic->fk_contrat=$objp->rowid; @@ -149,10 +149,10 @@ class box_services_contracts extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if ($objtp->label != '') $contractlinestatic->label = $objtp->label; } } @@ -222,14 +222,14 @@ class box_services_contracts extends ModeleBoxes } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("NoContractedProducts")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength' => 500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 58262a16dec..f1f1c38dd59 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -69,7 +69,7 @@ class box_services_expired extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -88,19 +88,19 @@ class box_services_expired extends ModeleBoxes $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'"; + $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; $sql.= " ORDER BY date_line ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; @@ -111,7 +111,7 @@ class box_services_expired extends ModeleBoxes { $late=''; - $objp = $db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -129,7 +129,7 @@ class box_services_expired extends ModeleBoxes $contract->ref_customer = $objp->ref_customer; $contract->ref_supplier = $objp->ref_supplier; - $dateline=$db->jdate($objp->date_line); + $dateline=$this->db->jdate($objp->date_line); if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late")); $this->info_box_contents[$i][] = array( @@ -168,14 +168,14 @@ class box_services_expired extends ModeleBoxes ); } - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 1ae1172de1d..6dc7385d363 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -69,15 +69,15 @@ class box_supplier_orders extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $langs->load("boxes"); $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($db); + $supplierorderstatic=new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); @@ -100,18 +100,18 @@ class box_supplier_orders extends ModeleBoxes if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->date_commande); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $date=$this->db->jdate($objp->date_commande); + $datem=$this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; @@ -158,12 +158,12 @@ class box_supplier_orders extends ModeleBoxes 'text' => $langs->trans("NoSupplierOrder"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index cf1d5241753..b0c6306ac38 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -75,15 +75,15 @@ class box_task extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; $projectstatic = new Project($this->db); - $taskstatic=new Task($db); - $form= new Form($db); + $taskstatic=new Task($this->db); + $form= new Form($this->db); $cookie_name='boxfilter_task'; $boxcontent=''; @@ -160,13 +160,13 @@ class box_task extends ModeleBoxes $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); $i = 0; if ($result) { - $num = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) { + $num = $this->db->num_rows($result); + while ($objp = $this->db->fetch_object($result)) { $taskstatic->id=$objp->rowid; $taskstatic->ref=$objp->ref; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 738786a6b91..0a30c76aeb3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7631,18 +7631,20 @@ abstract class CommonObject } // Delete cascade first - foreach($this->childtablesoncascade as $table) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->error; - $this->db->rollback(); - return -1; - } - } + if (! empty($this->childtablesoncascade)) { + foreach($this->childtablesoncascade as $table) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->errors[]=$this->error; + $this->db->rollback(); + return -1; + } + } + } if (! $error) { if (! $notrigger) { @@ -7816,4 +7818,35 @@ abstract class CommonObject } } } + + /** + * copy related categories to another object + * + * @param int $fromId Id object source + * @param int $toId Id object cible + * @param string $type Type of category ('product', ...) + * @return int < 0 si erreur, > 0 si ok + */ + public function cloneCategories($fromId, $toId, $type = '') + { + $this->db->begin(); + + if (empty($type)) $type = $this->table_element; + + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $categorystatic = new Categorie($this->db); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type] . " (fk_categorie, fk_product)"; + $sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type]; + $sql.= " WHERE fk_product = '".$fromId."'"; + + if (! $this->db->query($sql)) + { + $this->db->rollback();die($sql); + return -1; + } + + $this->db->commit(); + return 1; + } } diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 57a076963fd..160e22f4c50 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -87,33 +87,9 @@ class Events // extends CommonObject array('id'=>'USER_NEW_PASSWORD', 'test'=>1), array('id'=>'USER_ENABLEDISABLE', 'test'=>1), array('id'=>'USER_DELETE', 'test'=>1), - /* array('id'=>'USER_SETINGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY - array('id'=>'USER_REMOVEFROMGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY */ array('id'=>'GROUP_CREATE', 'test'=>1), array('id'=>'GROUP_MODIFY', 'test'=>1), array('id'=>'GROUP_DELETE', 'test'=>1), - /* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled), - array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled), - array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled), - array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_CLOSE_SIGNED', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_CLOSE_REFUSED', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled), - array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled), - array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled), - array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled), - array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled), - array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled), - array('id'=>'MEMBER_CREATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled), - */ ); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0a9f98b4afd..5f26365c2a8 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -959,9 +959,10 @@ class ExtraFields * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) * @param int $objectid Current object id * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data + * @param string $mode 1=Used for search filters * @return string */ - public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '') + public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) { global $conf,$langs,$form; @@ -1116,13 +1117,20 @@ class ExtraFields } elseif ($type == 'boolean') { - $checked=''; - if (!empty($value)) { - $checked=' checked value="1" '; - } else { - $checked=' value="1" '; + if (empty($mode)) + { + $checked=''; + if (!empty($value)) { + $checked=' checked value="1" '; + } else { + $checked=' value="1" '; + } + $out=''; + } + else + { + $out.=$form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); } - $out=''; } elseif ($type == 'price') { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index fe00f803a6b..eca41a55301 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -88,11 +88,12 @@ class Translate if (empty($srclang) || $srclang == 'auto') { + // $_SERVER['HTTP_ACCEPT_LANGUAGE'] can be 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6' but can contains also malicious content $langpref=empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])?'':$_SERVER['HTTP_ACCEPT_LANGUAGE']; - $langpref=preg_replace("/;([^,]*)/i", "", $langpref); + $langpref=preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part $langpref=str_replace("-", "_", $langpref); $langlist=preg_split("/[;,]/", $langpref); - $codetouse=$langlist[0]; + $codetouse=preg_replace('/[^_a-zA-Z]/', '', $langlist[0]); } else $codetouse=$srclang; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 6ed17305096..ea5027de1ee 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -323,6 +323,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date) * 0 =Input date is local date using PHP server timezone * @return int Date as a timestamp * 19700101020000 -> 7200 with gm=1 + * 19700101000000 -> 0 with gm=1 * * @see dol_print_date(), dol_mktime(), dol_getdate() */ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d0b724bbf8e..557ce1bdeea 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4499,7 +4499,9 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * Numeric = Nb of digits for rounding * @param int $alreadysqlnb Put 1 if you know that content is already universal format number - * @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''. + * @return string Amount with universal numeric format (Example: '99.99999'). + * If conversion fails, it return text unchanged if $rounding = '' or '0' if $rounding is defined. + * If amount is null or '', it returns '' if $rounding = '' or '0' if $rounding is defined.. * * @see price() Opposite function of price2num */ @@ -5921,11 +5923,13 @@ $substitutionarray=array_merge($substitutionarray, array( $substitutionarray['__REF_SUPPLIER__'] = '__REF_SUPPLIER__'; $substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__'; - $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; - $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; - $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; - $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; - + if (! empty($conf->societe->enabled)) + { + $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; + $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; + $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; + } if (! empty($conf->adherent->enabled)) { $substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__'; @@ -5933,15 +5937,19 @@ $substitutionarray=array_merge($substitutionarray, array( $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; } - $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; - $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; - $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; - - $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start'; - $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start'; - $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service'; - $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service'; - + if (! empty($conf->projet->enabled)) + { + $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; + $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; + $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; + } + if (! empty($conf->contrat->enabled)) + { + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start'; + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start'; + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service'; + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service'; + } $substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable'; $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = 'TextAndUrlToPayOnlineIfApplicable'; $substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)'; @@ -6019,7 +6027,13 @@ $substitutionarray=array_merge($substitutionarray, array( $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } - if (is_object($object->projet) && $object->projet->id > 0) + if (is_object($object->project) && $object->project->id > 0) + { + $substitutionarray['__PROJECT_ID__'] = (is_object($object->project)?$object->project->id:''); + $substitutionarray['__PROJECT_REF__'] = (is_object($object->project)?$object->project->ref:''); + $substitutionarray['__PROJECT_NAME__'] = (is_object($object->project)?$object->project->title:''); + } + if (is_object($object->projet) && $object->projet->id > 0) // Deprecated, for backward compatibility { $substitutionarray['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:''); $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); @@ -7291,7 +7305,7 @@ function printCommonFooter($zone = 'private') { print "\n"; print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; - print 'jQuery(".menuhider").click(function(event) {'; + print 'jQuery("li.menuhider").click(function(event) {'; print ' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'."\n"; print ' console.log("We click on .menuhider");'."\n"; print ' $("body").toggleClass("sidebar-collapse")'."\n"; diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index 492766192b4..960acfa3aa7 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -86,6 +86,11 @@ function holiday_admin_prepare_head() // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin'); + $head[$h][0] = DOL_URL_ROOT.'/admin/holiday_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin', 'remove'); return $head; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 438ff8246ea..2aaeb967675 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -271,14 +271,19 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t // Show logo company if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + $mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI); + $mysoc->logo_squarred_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); + if (! empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + } + elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); } else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; } $title=$langs->trans("GoIntoSetupToChangeLogo"); print "\n".''."\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a4eb2d57053..d62cd1993fd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -43,7 +43,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; */ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '') { - global $user,$conf,$langs,$dolibarr_main_db_name; + global $user,$conf,$langs,$mysoc; + global $dolibarr_main_db_name; $mainmenu=(empty($_SESSION["mainmenu"])?'':$_SESSION["mainmenu"]); $leftmenu=(empty($_SESSION["leftmenu"])?'':$_SESSION["leftmenu"]); @@ -55,22 +56,23 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $usemenuhider = 1; - // Show/Hide vertical menu + // Show/Hide vertical menu. The hamburger icon for .menuhider action. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $menu_arr = array(); + // Home $menu_arr[] = array( 'name' => 'Home', 'link' => '/index.php?mainmenu=home&leftmenu=home', - 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? '   ' : "Home") , + 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : "Home") , 'level' => 0, 'enabled' => $showmode = 1, 'target' => $atarget, @@ -473,8 +475,35 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->liste = dol_sort_array($menu->liste, 'position'); // Output menu entries + // Show logo company + if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI); + $mysoc->logo_squarred_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); + if (! empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + } + elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); + } + else + { + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; + } + $title=$langs->trans("GoIntoSetupToChangeLogo"); + + print "\n".''."\n"; + print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo"', 1); + + print ''."\n"; + + print_end_menu_entry(4); + } + if (empty($noout)) { - foreach($menu->liste as $menkey => $menuval) { + foreach($menu->liste as $menuval) { print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url']!='#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); print_end_menu_entry($menuval['enabled']); @@ -615,30 +644,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $usemenuhider = 0; - // Show logo company - if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); - } - else - { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; - } - $title=$langs->trans("GoIntoSetupToChangeLogo"); - print "\n".''."\n"; - print ''."\n"; - } - if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index ea1ffb7f6a3..ac93d45d133 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -38,7 +38,7 @@ class modExpenseReport extends DolibarrModules */ public function __construct($db) { - global $conf; + global $conf, $user; // Required by some include code $this->db = $db; $this->numero = 770; @@ -200,8 +200,13 @@ class modExpenseReport extends DolibarrModules $this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login'); $this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + $keyforselect='expensereport'; $keyforelement='expensereport'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,'; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expensereport as d'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_extrafields as extra on d.rowid = extra.fk_object'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid'; $this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid'; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index ba792ad28ad..2fd98887b87 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -202,13 +202,13 @@ class modHoliday extends DolibarrModules $this->export_permission[$r]=array(array("holiday","read_all")); $this->export_fields_array[$r]=array( 'd.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID', - 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay', + 'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay','none.num_open_days'=>'NbUseDaysCP', 'd.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname", 'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status' ); $this->export_TypeFields_array[$r]=array( 'd.rowid'=>"Numeric",'t.code'=>'Text', 't.label'=>'Text','d.fk_user'=>'Numeric', - 'u.lastname'=>'Text','u.firstname'=>'Text','u.login'=>"Text",'d.date_debut'=>'Date','d.date_fin'=>'Date', + 'u.lastname'=>'Text','u.firstname'=>'Text','u.login'=>"Text",'d.date_debut'=>'Date','d.date_fin'=>'Date','none.num_open_days'=>'NumericCompute', 'd.date_valid'=>'Date','d.fk_validator'=>"Numeric",'ua.lastname'=>"Text",'ua.firstname'=>"Text", 'ua.login'=>"Text",'d.description'=>'Text','d.statut'=>'Numeric' ); @@ -216,10 +216,15 @@ class modHoliday extends DolibarrModules 'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user' ); $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); + $this->export_special_array[$r] = array('none.num_open_days'=>'getNumOpenDays'); $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + $keyforselect='holiday'; $keyforelement='holiday'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'holiday as d'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'holiday_extrafields as extra on d.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u'; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index f3864525d8d..93afcdaebd7 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -316,17 +316,21 @@ class modStock extends DolibarrModules $this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*", 'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse", 'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode', - 'e.statut'=>'Status' + 'e.statut'=>'Status', + 'e.fk_parent'=>'ParentWarehouse' ); $this->import_convertvalue_array[$r]=array( - 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry') + 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), + 'e.fk_parent'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref') ); $this->import_regex_array[$r]=array('e.statut'=>'^[0|1]'); $this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001", 'e.description'=>"Central Warehouse",'e.lieu'=>"Central", 'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US', - 'e.statut'=>'1'); + 'e.statut'=>'1', + 'e.fk_parent'=>'' + ); // Import stocks $r++; diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index b4a98946f94..0b9a048f28a 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -22,28 +22,28 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; + print ''; $tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key); if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { - $crit=$val; $searchclass=''; if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } - elseif (! in_array($typeofextrafield, array('datetime','timestamp'))) - { - // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') - $morecss=''; - if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; - echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss); - } elseif (in_array($typeofextrafield, array('datetime','timestamp'))) { // TODO // Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + $morecss=''; + if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; + echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1); + } print ''; } } diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index c2c4934c832..29c67094975 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -25,10 +25,18 @@ if (! empty($extrafieldsobjectkey) && ! empty($search_array_options) && is_array { $sql .= " AND ".$extrafieldsobjectprefix.$tmpkey." = '".$db->idate($crit)."'"; } + elseif (in_array($typ, array('boolean'))) + { + if ($crit !== '-1' && $crit !== '') { + $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." = '".$db->escape($crit)."'"; + if ($crit == '0') $sql.=" OR ".$extrafieldsobjectprefix.$tmpkey." IS NULL"; + $sql.= ")"; + } + } elseif ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) { $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text if (is_array($crit)) $crit = implode(' ', $crit); // natural_search() expects a string diff --git a/htdocs/document.php b/htdocs/document.php index 8e86d6c3e6f..84fb0492554 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -161,6 +161,8 @@ if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; $type = 'application/octet-stream'; if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); +// Security: Force to octet-stream if file is a dangerous file +if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream'; // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); @@ -217,7 +219,7 @@ if (! $accessallowed) } // Security: -// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. +// We refuse directory transversal change and pipes in file names if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file)) { dol_syslog("Refused to deliver file ".$fullpath_original_file); @@ -229,6 +231,7 @@ if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $full clearstatcache(); $filename = basename($fullpath_original_file); +$filename = preg_replace('/\.noexe$/i', '', $filename); // Output file on browser dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type"); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 666403a7412..fd53e8af1d1 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -40,12 +40,13 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php' // Load translation files required by the page $langs->loadLangs(array('companies', 'users', 'trips')); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'expensereportlist'; +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'expensereportlist'; $childids = $user->getAllChildIds(1); @@ -136,17 +137,17 @@ $arrayfields=array( 'd.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } $canedituser=(! empty($user->admin) || $user->rights->user->user->creer); -$object = new ExpenseReport($db); $objectuser = new User($db); @@ -161,12 +162,13 @@ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test must be present to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; $search_user=""; @@ -176,7 +178,6 @@ if (empty($reshook)) $search_status=""; $month_start=""; $year_start=""; - $day =""; $month_end=""; $year_end=""; $day_end = ""; @@ -258,9 +259,9 @@ $title = $langs->trans("ListOfTrips"); llxHeader('', $title); $max_year = 5; -$min_year = 5; +$min_year = 10; -// Récupération de l'ID de l'utilisateur +// Get current user id $user_id = $user->id; if ($id > 0) @@ -340,15 +341,15 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.="&sall=".$sall; - if ($search_ref) $param.="&search_ref=".$search_ref; - if ($search_user) $param.="&search_user=".$search_user; - if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht; - if ($search_amount_ttc) $param.="&search_amount_ttc=".$search_amount_ttc; - if ($search_status >= 0) $param.="&search_status=".$search_status; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sall) $param.="&sall=".urlencode($sall); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_user) $param.="&search_user=".urlencode($search_user); + if ($search_amount_ht) $param.="&search_amount_ht=".urlencode($search_amount_ht); + if ($search_amount_ttc) $param.="&search_amount_ttc=".urlencode($search_amount_ttc); + if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -503,7 +504,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -606,7 +607,7 @@ if ($resql) print ''; } // Action column - print ''; @@ -757,6 +758,7 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation if (! empty($arrayfields['d.date_create']['checked'])) { @@ -801,10 +803,9 @@ if ($resql) } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - - print ''.''; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; } // Show total line diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 51a16f717b2..da184f27574 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -540,7 +540,7 @@ class Export public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') { // phpcs:enable - global $conf,$langs; + global $conf,$langs,$mysoc; $indice=0; asort($array_selected); @@ -634,6 +634,14 @@ class Export $alias=str_replace(array('.', '-','(',')'), '_', $key); if ($obj->$alias < 0) $obj->$alias='0'; } + // Operation GETNUMOPENDAYS (for Holiday module) + elseif ($this->array_export_special[$indice][$key]=='getNumOpenDays') + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + //$alias=$this->array_export_alias[$indice][$key]; + $alias=str_replace(array('.', '-','(',')'), '_', $key); + $obj->$alias=num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code); + } // Operation INVOICEREMAINTOPAY elseif ($this->array_export_special[$indice][$key]=='getRemainToPay') { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 90240e4cd2b..5ebe8ffed56 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -605,9 +605,9 @@ if ($object->id > 0) $sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; - // Show orders with status validated, shipping started and delivered (even if any order we can bill) + // Show orders with status validated, shipping started and delivered (even if any order we can bill). //$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; - $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; + $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/orderstoinvoice.php $sql2.= " AND c.billed = 0"; // Find order that are not already invoiced // just need to check received status because we have the billed status now diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6847af5edf1..febfda0a419 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -207,7 +207,7 @@ class ProductFournisseur extends Product /** * Modify the purchase price for a supplier * - * @param int $qty Min quantity for which price is valid + * @param float $qty Min quantity for which price is valid * @param float $buyprice Purchase price for the quantity min * @param User $user Object user user made changes * @param string $price_base_type HT or TTC @@ -230,7 +230,7 @@ class ProductFournisseur extends Product * @param string $desc_fourn Custom description for product_fourn_price * @param string $barcode Barcode * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') { @@ -272,11 +272,10 @@ class ProductFournisseur extends Product $buyprice=price2num($buyprice, 'MU'); $charges=price2num($charges, 'MU'); - $qty=price2num($qty); - $error=0; - + $qty=price2num($qty, 'MS'); $unitBuyPrice = price2num($buyprice/$qty, 'MU'); + $error=0; $now=dol_now(); $newvat = $tva_tx; @@ -298,6 +297,12 @@ class ProductFournisseur extends Product if (empty($localtax1)) $localtax1=0; // If = '' then = 0 if (empty($localtax2)) $localtax2=0; // If = '' then = 0 + // Check parameters + if ($buyprice != '' && ! is_numeric($buyprice)) + { + + } + $this->db->begin(); if ($this->product_fourn_price_id > 0) @@ -331,7 +336,7 @@ class ProductFournisseur extends Product $sql.= " SET fk_user = " . $user->id." ,"; $sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',"; $sql.= " desc_fourn = '" . $this->db->escape($desc_fourn) . "',"; - $sql.= " price = ".price2num($buyprice).","; + $sql.= " price = ".$buyprice.","; $sql.= " quantity = ".$qty.","; $sql.= " remise_percent = ".$remise_percent.","; $sql.= " remise = ".$remise.","; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 6d808934a7b..d7271318e51 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -450,7 +450,7 @@ if (($action != 'create' && $action != 'add') && !$error) { $sql .= ' AND c.fk_soc = s.rowid'; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql .= " AND c.fk_statut IN (5)"; + $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php $sql .= " AND c.billed = 0"; // Find order that are not already invoiced diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 204d832a94c..bc9c10045a8 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -37,9 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Get parameters -$action=GETPOST('action', 'alpha'); +$action=GETPOST('action', 'aZ09'); +$cancel=GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + $id=GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); $fuserid = (GETPOST('fuserid', 'int')?GETPOST('fuserid', 'int'):$user->id); @@ -48,10 +52,10 @@ $fuserid = (GETPOST('fuserid', 'int')?GETPOST('fuserid', 'int'):$user->id); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'holiday', $id, 'holiday'); -$now=dol_now(); - // Load translation files required by the page -$langs->load("holiday"); +$langs->loadLangs(array("holiday","mails")); + +$now=dol_now(); $childids = $user->getAllChildIds(1); @@ -61,6 +65,11 @@ if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; $error = 0; $object = new Holiday($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + if ($id > 0) { $object->fetch($id); @@ -83,745 +92,798 @@ $candelete = 0; if (! empty($user->rights->holiday->delete)) $candelete=1; if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete=1; + /* * Actions */ -if (GETPOST('cancel', 'alpha')) -{ - $action = ''; -} +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -// If create a request -if ($action == 'create') +if (empty($reshook)) { - // If no right to create a request - if (! $cancreate) - { - $error++; - setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); - $action='request'; - } + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } - if (! $error) - { - $object = new Holiday($db); + // If create a request + if ($action == 'create') + { - $db->begin(); - - $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); - $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); - $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); - $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); - $starthalfday=GETPOST('starthalfday'); - $endhalfday=GETPOST('endhalfday'); - $type=GETPOST('type'); - $halfday=0; - if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2; - elseif ($starthalfday == 'afternoon') $halfday=-1; - elseif ($endhalfday == 'morning') $halfday=1; - - $valideur = GETPOST('valideur', 'int'); - $description = trim(GETPOST('description')); - - // If no type - if ($type <= 0) + // If no right to create a request + if (! $cancreate) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error++; - $action='create'; + $error++; + setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); + $action='request'; } - // If no start date - if (empty($date_debut)) - { - setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); - $error++; - $action='create'; - } - // If no end date - if (empty($date_fin)) - { - setEventMessages($langs->trans("NoDateFin"), null, 'errors'); - $error++; - $action='create'; - } - // If start date after end date - if ($date_debut > $date_fin) - { - setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); - $error++; - $action='create'; - } - - // Check if there is already holiday for this period - $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); - if (! $verifCP) - { - setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); - $error++; - $action='create'; - } - - // If there is no Business Days within request - $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if($nbopenedday < 0.5) - { - setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); - $error++; - $action='create'; - } - - // If no validator designated - if ($valideur < 1) - { - setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); - $error++; - } - - $result = 0; - if (! $error) { - $object->fk_user = $fuserid; - $object->description = $description; - $object->fk_validator = $valideur; - $object->fk_type = $type; - $object->date_debut = $date_debut; - $object->date_fin = $date_fin; - $object->halfday = $halfday; + $object = new Holiday($db); - $result = $object->create($user); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } + $db->begin(); + + $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); + $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); + $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); + $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); + $starthalfday=GETPOST('starthalfday'); + $endhalfday=GETPOST('endhalfday'); + $type=GETPOST('type'); + $halfday=0; + if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2; + elseif ($starthalfday == 'afternoon') $halfday=-1; + elseif ($endhalfday == 'morning') $halfday=1; + + $valideur = GETPOST('valideur', 'int'); + $description = trim(GETPOST('description')); + + // If no type + if ($type <= 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $error++; + $action='create'; + } + + // If no start date + if (empty($date_debut)) + { + setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); + $error++; + $action='create'; + } + // If no end date + if (empty($date_fin)) + { + setEventMessages($langs->trans("NoDateFin"), null, 'errors'); + $error++; + $action='create'; + } + // If start date after end date + if ($date_debut > $date_fin) + { + setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); + $error++; + $action='create'; + } + + // Check if there is already holiday for this period + $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); + if (! $verifCP) + { + setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); + $error++; + $action='create'; + } + + // If there is no Business Days within request + $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); + if($nbopenedday < 0.5) + { + setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); + $error++; + $action='create'; + } + + // If no validator designated + if ($valideur < 1) + { + setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); + $error++; + } + + $result = 0; + + if (! $error) + { + $object->fk_user = $fuserid; + $object->description = $description; + $object->fk_validator = $valideur; + $object->fk_type = $type; + $object->date_debut = $date_debut; + $object->date_fin = $date_fin; + $object->halfday = $halfday; + + $result = $object->create($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + // If no SQL error we redirect to the request card + if (! $error) + { + $db->commit(); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $db->rollback(); + } + } + } + + if ($action == 'update' && GETPOSTISSET('savevalidator') && ! empty($user->rights->holiday->approve)) + { + $object->fetch($id); + + $object->oldcopy = dol_clone($object); + + $object->fk_validator = GETPOST('valideur', 'int'); + + if ($object->fk_validator != $object->oldcopy->fk_validator) + { + $verif = $object->update($user); + + if ($verif <= 0) + { + setEventMessages($object->error, $object->errors, 'warnings'); + $action='editvalidator'; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } } - // If no SQL error we redirect to the request card - if (! $error) - { - $db->commit(); + $action = ''; + } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + if ($action == 'update' && ! GETPOSTISSET('savevalidator')) + { + $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); + $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); + $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); + $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); + $starthalfday=GETPOST('starthalfday'); + $endhalfday=GETPOST('endhalfday'); + $halfday=0; + if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2; + elseif ($starthalfday == 'afternoon') $halfday=-1; + elseif ($endhalfday == 'morning') $halfday=1; + + // If no right to modify a request + if (! $user->rights->holiday->write) + { + header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=CantUpdate'); exit; } - else - { - $db->rollback(); + + $object->fetch($id); + + // If under validation + if ($object->statut == Holiday::STATUS_DRAFT) + { + // If this is the requestor or has read/write rights + if ($cancreate) + { + $valideur = GETPOST('valideur', 'int'); + $description = trim(GETPOST('description', 'none')); + + // If no start date + if (empty($_POST['date_debut_'])) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatedebut'); + exit; + } + + // If no end date + if (empty($_POST['date_fin_'])) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatefin'); + exit; + } + + // If start date after end date + if ($date_debut > $date_fin) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=datefin'); + exit; + } + + // If no validator designated + if ($valideur < 1) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=Valideur'); + exit; + } + + // If there is no Business Days within request + $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); + if ($nbopenedday < 0.5) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=DureeHoliday'); + exit; + } + + $object->description = $description; + $object->date_debut = $date_debut; + $object->date_fin = $date_fin; + $object->fk_validator = $valideur; + $object->halfday = $halfday; + + // Update + $verif = $object->update($user); + + if ($verif <= 0) + { + setEventMessages($object->error, $object->errors, 'warnings'); + $action='edit'; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); + $action=''; + } } - } -} + else + { + setEventMessages($langs->trans("ErrorBadStatus"), null, 'errors'); + $action=''; + } + } -if ($action == 'update' && GETPOSTISSET('savevalidator') && ! empty($user->rights->holiday->approve)) -{ - $object->fetch($id); + // If delete of request + if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete) + { + $error=0; - $object->oldcopy = dol_clone($object); + $db->begin(); - $object->fk_validator = GETPOST('valideur', 'int'); + $object->fetch($id); - if ($object->fk_validator != $object->oldcopy->fk_validator) - { - $verif = $object->update($user); - - if ($verif <= 0) - { - setEventMessages($object->error, $object->errors, 'warnings'); - $action='editvalidator'; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - - $action = ''; -} - -if ($action == 'update' && ! GETPOSTISSET('savevalidator')) -{ - $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); - $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); - $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); - $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); - $starthalfday=GETPOST('starthalfday'); - $endhalfday=GETPOST('endhalfday'); - $halfday=0; - if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2; - elseif ($starthalfday == 'afternoon') $halfday=-1; - elseif ($endhalfday == 'morning') $halfday=1; - - // If no right to modify a request - if (! $user->rights->holiday->write) - { - header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=CantUpdate'); - exit; - } - - $object->fetch($id); - - // If under validation - if ($object->statut == Holiday::STATUS_DRAFT) - { - // If this is the requestor or has read/write rights - if ($cancreate) - { - $valideur = GETPOST('valideur', 'int'); - $description = trim(GETPOST('description', 'none')); - - // If no start date - if (empty($_POST['date_debut_'])) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatedebut'); - exit; - } - - // If no end date - if (empty($_POST['date_fin_'])) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatefin'); - exit; - } - - // If start date after end date - if ($date_debut > $date_fin) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=datefin'); - exit; - } - - // If no validator designated - if ($valideur < 1) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=Valideur'); - exit; - } - - // If there is no Business Days within request - $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if ($nbopenedday < 0.5) - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=DureeHoliday'); - exit; - } - - $object->description = $description; - $object->date_debut = $date_debut; - $object->date_fin = $date_fin; - $object->fk_validator = $valideur; - $object->halfday = $halfday; - - // Update - $verif = $object->update($user); - - if ($verif <= 0) + // If this is a rough draft, approved, canceled or refused + if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) + { + // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer + if ($candelete) { - setEventMessages($object->error, $object->errors, 'warnings'); - $action='edit'; + $result=$object->delete($user); } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + $error++; + setEventMessages($langs->trans('ErrorCantDeleteCP'), null, 'errors'); + $action=''; } - } - else - { - setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); - $action=''; - } - } - else - { - setEventMessages($langs->trans("ErrorBadStatus"), null, 'errors'); - $action=''; - } -} + } -// If delete of request -if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete) -{ - $error=0; - - $db->begin(); - - $object->fetch($id); - - // If this is a rough draft, approved, canceled or refused - if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) - { - // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer - if ($candelete) + if (! $error) { - $result=$object->delete($user); + $db->commit(); + header('Location: list.php?restore_lastsearch_values=1'); + exit; } else { - $error++; - setEventMessages($langs->trans('ErrorCantDeleteCP'), null, 'errors'); - $action=''; + $db->rollback(); } } - if (! $error) + // Action validate (+ send email for approval) + if ($action == 'confirm_send') { - $db->commit(); - header('Location: list.php?restore_lastsearch_values=1'); - exit; + $object->fetch($id); + + // Si brouillon et créateur + if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) + { + $object->oldcopy = dol_clone($object); + + $object->statut = Holiday::STATUS_VALIDATED; + + $verif = $object->validate($user); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if ($verif > 0) + { + // To + $destinataire = new User($db); + $destinataire->fetch($object->fk_validator); + $emailTo = $destinataire->email; + + if (!$emailTo) + { + dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + + // From + $expediteur = new User($db); + $expediteur->fetch($object->fk_user); + $emailFrom = $expediteur->email; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); + + // Content + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message.= "\n"; + $message.= $langs->transnoentities("HolidaysToValidateBody")."\n"; + + $delayForRequest = $object->getConfCP('delayForRequest'); + //$delayForRequest = $delayForRequest * (60*60*24); + + $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); + + // Si l'option pour avertir le valideur en cas de délai trop court + if ($object->getConfCP('AlertValidatorDelay')) + { + if($object->date_debut < $nextMonth) + { + $message.= "\n"; + $message.= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; + } + } + + // Si l'option pour avertir le valideur en cas de solde inférieur à la demande + if ($object->getConfCP('AlertValidatorSolde')) + { + $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) + { + $message.= "\n"; + $message.= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; + } + } + + $message.= "\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; + $message.= "\n"; + + $trackid='leav'.$object->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + + // Envoi du mail + $result=$mail->sendfile(); + + if (!$result) + { + setEventMessages($mail->error, $mail->errors, 'warnings'); + $action=''; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + } } - else + + if ($action == 'update_extras') { - $db->rollback(); + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (! $error) + { + // Actions on extra fields + $result = $object->insertExtraFields('HOLIDAY_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + if ($error) + $action = 'edit_extras'; } -} - -// Action validate (+ send email for approval) -if ($action == 'confirm_send') -{ - $object->fetch($id); - - // Si brouillon et créateur - if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) - { - $object->oldcopy = dol_clone($object); - - $object->statut = Holiday::STATUS_VALIDATED; - - $verif = $object->validate($user); - - // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) - { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_validator); - $emailTo = $destinataire->email; - - if (!$emailTo) - { - dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_user); - $emailFrom = $expediteur->email; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); - - // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message.= "\n"; - $message.= $langs->transnoentities("HolidaysToValidateBody")."\n"; - - $delayForRequest = $object->getConfCP('delayForRequest'); - //$delayForRequest = $delayForRequest * (60*60*24); - - $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); - - // Si l'option pour avertir le valideur en cas de délai trop court - if ($object->getConfCP('AlertValidatorDelay')) - { - if($object->date_debut < $nextMonth) - { - $message.= "\n"; - $message.= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; - } - } - - // Si l'option pour avertir le valideur en cas de solde inférieur à la demande - if ($object->getConfCP('AlertValidatorSolde')) - { - $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) - { - $message.= "\n"; - $message.= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; - } - } - - $message.= "\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message.= "\n"; - - $trackid='leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); - - // Envoi du mail - $result=$mail->sendfile(); - - if (!$result) - { - setEventMessages($mail->error, $mail->errors, 'warnings'); - $action=''; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } -} - - -// Approve leave request -if ($action == 'confirm_valid') -{ - $object->fetch($id); - - // Si statut en attente de validation et valideur = utilisateur - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) - { - $object->oldcopy = dol_clone($object); - - $object->date_valid = dol_now(); - $object->fk_user_valid = $user->id; - $object->statut = Holiday::STATUS_APPROVED; - - $db->begin(); - - $verif = $object->approve($user); - if ($verif <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - - // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (! $error) - { - // Calculcate number of days consummed - $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); - $newSolde = ($soldeActuel - $nbopenedday); - - // On ajoute la modification dans le LOG - $result=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); - if ($result < 0) - { - $error++; - setEventMessages(null, $object->errors, 'errors'); - } - - //Update balance - $result=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - if ($result < 0) - { - $error++; - setEventMessages(null, $object->errors, 'errors'); - } - } - - if (! $error) - { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) - { - dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); - } - else - { - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_validator); - $emailFrom = $expediteur->email; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); - - // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message.= "\n"; - $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - - $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message.= "\n"; - - $trackid='leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); - - // Envoi du mail - $result=$mail->sendfile(); - - if (!$result) - { - setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 - $action=''; - } - } - } - - if (! $error) - { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $db->rollback(); - $action=''; - } - } -} - -if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') -{ - if (! empty($_POST['detail_refuse'])) - { - $object->fetch($id); - - // Si statut en attente de validation et valideur = utilisateur - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) - { - $object->date_refuse = dol_print_date('dayhour', dol_now()); - $object->fk_user_refuse = $user->id; - $object->statut = Holiday::STATUS_REFUSED; - $object->detail_refuse = GETPOST('detail_refuse', 'alphanohtml'); - - $db->begin(); - - $verif = $object->update($user); - if ($verif <= 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - - // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (! $error) - { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) - { - dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); - } - else - { - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_validator); - $emailFrom = $expediteur->email; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); - - // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message.= "\n"; - $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message.= GETPOST('detail_refuse', 'alpha')."\n\n"; - - $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message.= "\n"; - - $trackid='leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); - - // Envoi du mail - $result=$mail->sendfile(); - - if (! $result) - { - setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 - $action=''; - } - } - } - else - { - $action=''; - } - - if (! $error) - { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $db->rollback(); - $action=''; - } - } - } else { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DetailRefusCP")), null, 'errors'); - $action='refuse'; - } -} - - -// Si Validation de la demande -if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') -{ - $error = 0; - - $object->fetch($id); - - $oldstatus = $object->statut; - $object->statut = Holiday::STATUS_DRAFT; - - $result = $object->update($user); - if ($result < 0) - { - $error++; - setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors'); - } - - if (! $error) - { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $db->rollback(); - } -} - -// Si confirmation of cancellation -if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') -{ - $error = 0; - - $object->fetch($id); - - // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres - if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all))) - { - $db->begin(); - - $oldstatus = $object->statut; - $object->date_cancel = dol_now(); - $object->fk_user_cancel = $user->id; - $object->statut = Holiday::STATUS_CANCELED; - - $result = $object->update($user); - - if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) // holiday was already validated, status 3, so we must increase back the balance - { - // Calculcate number of days consummed - $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - - $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); - $newSolde = ($soldeActuel + $nbopenedday); - - // On ajoute la modification dans le LOG - $result1=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $object->fk_type); - - // Mise à jour du solde - $result2=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - - if ($result1 < 0 || $result2 < 0) - { - $error++; - setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors'); - } - } - - if (! $error) - { - $db->commit(); - } - else - { - $db->rollback(); - } - - // Si pas d'erreur SQL on redirige vers la fiche de la demande - if (! $error && $result > 0) - { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); - - // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message.= "\n"; - - $message.= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message.= "\n"; - - $trackid='leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); - - // Envoi du mail - $result=$mail->sendfile(); - - if (!$result) - { - setEventMessages($mail->error, $mail->errors, 'warnings'); - $action=''; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - } + + // Approve leave request + if ($action == 'confirm_valid') + { + $object->fetch($id); + + // Si statut en attente de validation et valideur = utilisateur + if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) + { + $object->oldcopy = dol_clone($object); + + $object->date_valid = dol_now(); + $object->fk_user_valid = $user->id; + $object->statut = Holiday::STATUS_APPROVED; + + $db->begin(); + + $verif = $object->approve($user); + if ($verif <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if (! $error) + { + // Calculcate number of days consummed + $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); + $newSolde = ($soldeActuel - $nbopenedday); + + // On ajoute la modification dans le LOG + $result=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); + if ($result < 0) + { + $error++; + setEventMessages(null, $object->errors, 'errors'); + } + + //Update balance + $result=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); + if ($result < 0) + { + $error++; + setEventMessages(null, $object->errors, 'errors'); + } + } + + if (! $error) + { + // To + $destinataire = new User($db); + $destinataire->fetch($object->fk_user); + $emailTo = $destinataire->email; + + if (!$emailTo) + { + dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); + } + else + { + // From + $expediteur = new User($db); + $expediteur->fetch($object->fk_validator); + $emailFrom = $expediteur->email; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); + + // Content + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message.= "\n"; + $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + + $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; + $message.= "\n"; + + $trackid='leav'.$object->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + + // Envoi du mail + $result=$mail->sendfile(); + + if (!$result) + { + setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 + $action=''; + } + } + } + + if (! $error) + { + $db->commit(); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $db->rollback(); + $action=''; + } + } + } + + if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') + { + if (! empty($_POST['detail_refuse'])) + { + $object->fetch($id); + + // Si statut en attente de validation et valideur = utilisateur + if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) + { + $object->date_refuse = dol_print_date('dayhour', dol_now()); + $object->fk_user_refuse = $user->id; + $object->statut = Holiday::STATUS_REFUSED; + $object->detail_refuse = GETPOST('detail_refuse', 'alphanohtml'); + + $db->begin(); + + $verif = $object->update($user); + if ($verif <= 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if (! $error) + { + // To + $destinataire = new User($db); + $destinataire->fetch($object->fk_user); + $emailTo = $destinataire->email; + + if (!$emailTo) + { + dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); + } + else + { + // From + $expediteur = new User($db); + $expediteur->fetch($object->fk_validator); + $emailFrom = $expediteur->email; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); + + // Content + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message.= "\n"; + $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + $message.= GETPOST('detail_refuse', 'alpha')."\n\n"; + + $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; + $message.= "\n"; + + $trackid='leav'.$object->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + + // Envoi du mail + $result=$mail->sendfile(); + + if (! $result) + { + setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 + $action=''; + } + } + } + else + { + $action=''; + } + + if (! $error) + { + $db->commit(); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $db->rollback(); + $action=''; + } + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DetailRefusCP")), null, 'errors'); + $action='refuse'; + } + } + + + // Si Validation de la demande + if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') + { + $error = 0; + + $object->fetch($id); + + $oldstatus = $object->statut; + $object->statut = Holiday::STATUS_DRAFT; + + $result = $object->update($user); + if ($result < 0) + { + $error++; + setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors'); + } + + if (! $error) + { + $db->commit(); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $db->rollback(); + } + } + + // Si confirmation of cancellation + if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') + { + $error = 0; + + $object->fetch($id); + + // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres + if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all))) + { + $db->begin(); + + $oldstatus = $object->statut; + $object->date_cancel = dol_now(); + $object->fk_user_cancel = $user->id; + $object->statut = Holiday::STATUS_CANCELED; + + $result = $object->update($user); + + if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) // holiday was already validated, status 3, so we must increase back the balance + { + // Calculcate number of days consummed + $nbopenedday=num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + + $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); + $newSolde = ($soldeActuel + $nbopenedday); + + // On ajoute la modification dans le LOG + $result1=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $object->fk_type); + + // Mise à jour du solde + $result2=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); + + if ($result1 < 0 || $result2 < 0) + { + $error++; + setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors'); + } + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if (! $error && $result > 0) + { + // To + $destinataire = new User($db); + $destinataire->fetch($object->fk_user); + $emailTo = $destinataire->email; + + if (!$emailTo) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + + // From + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_cancel); + $emailFrom = $expediteur->email; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); + + // Content + $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; + $message.= "\n"; + + $message.= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; + $message.= "\n"; + + $trackid='leav'.$object->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + + // Envoi du mail + $result=$mail->sendfile(); + + if (!$result) + { + setEventMessages($mail->error, $mail->errors, 'warnings'); + $action=''; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + } + } + + /* + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='HOLIDAY_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_HOLIDAY_TO'; + $trackid='leav'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + // Actions to build doc + $upload_dir = $conf->holiday->dir_output; + $permissioncreate = $user->rights->holiday->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + */ } @@ -1049,6 +1111,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ print $doleditor->Create(1); print ''; + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + print ''; print '
'; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'; @@ -1134,6 +1199,7 @@ else if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) $edit = true; print '
'."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; } @@ -1247,6 +1313,9 @@ else print ''; } + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print ''; print ''."\n"; @@ -1311,7 +1380,7 @@ else } print ''; - print ''.$langs->trans('DateCreateCP').''; + print ''.$langs->trans('DateCreation').''; print ''.dol_print_date($object->date_create, 'dayhour').''; print ''; if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index d767bcdc691..25d1c1d5a2d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -402,6 +402,8 @@ class Holiday extends CommonObject } $this->db->free($resql); + $this->fetch_optionals(); + return 1; } else @@ -558,6 +560,7 @@ class Holiday extends CommonObject $sql.= " cp.fk_user,"; $sql.= " cp.fk_type,"; $sql.= " cp.date_create,"; + $sql.= " cp.tms as date_update,"; $sql.= " cp.description,"; $sql.= " cp.date_debut,"; $sql.= " cp.date_fin,"; @@ -623,6 +626,7 @@ class Holiday extends CommonObject $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); + $tab_result[$i]['date_update'] = $this->db->jdate($obj->date_update); $tab_result[$i]['description'] = $obj->description; $tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut); $tab_result[$i]['date_fin'] = $this->db->jdate($obj->date_fin); diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index a594a920e74..6ade6a13e17 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -251,7 +251,7 @@ if ($object->id) } print ''; - print ''.$langs->trans('DateCreateCP').''; + print ''.$langs->trans('DateCreation').''; print ''.dol_print_date($object->date_create,'dayhour').''; print ''; if ($object->statut == 3) { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index f74d731e8bd..072a6aacc45 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -27,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; @@ -40,16 +41,19 @@ $langs->loadLangs(array('users', 'holidays', 'hrm')); // Protection if external user if ($user->societe_id > 0) accessforbidden(); -$action = GETPOST('action', 'alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'holidaylist'; // To manage different context of search + $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$id = GETPOST('id', 'int'); + $childids = $user->getAllChildIds(1); // Security check @@ -59,8 +63,7 @@ if ($user->societe_id > 0) // Protection if external user //$socid = $user->societe_id; accessforbidden(); } -$result = restrictedArea($user, 'holiday', $id, ''); -$id = GETPOST('id', 'int'); +$result = restrictedArea($user, 'holiday', '', ''); // If we are on the view of a specific user if ($id > 0) { @@ -74,6 +77,9 @@ if ($id > 0) } } +$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id; + + // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); @@ -83,20 +89,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - -// Initialize technical objects -$object=new Holiday($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('holiday'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="cp.rowid"; -if (! $sortorder) $sortorder="DESC"; - +if (!$sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield="cp.rowid"; $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alphanohtml'); @@ -114,13 +108,47 @@ $search_valideur = GETPOST('search_valideur', 'int'); $search_statut = GETPOST('search_statut', 'int'); $search_type = GETPOST('search_type', 'int'); +// Initialize technical objects +$object=new Holiday($db); +$extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('holiday'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'cp.description'=>'Description', 'uu.lastname'=>'EmployeeLastname', - 'uu.firstname'=>'EmployeeFirstname' + 'uu.firstname'=>'EmployeeFirstname', + 'uu.login'=>'Login' ); +$arrayfields=array( + 'cp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'cp.fk_user'=>array('label'=>$langs->trans("Employee"), 'checked'=>1, 'position'=>20), + 'cp.fk_validator'=>array('label'=>$langs->trans("ValidatorCP"), 'checked'=>1, 'position'=>30), + 'cp.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1, 'position'=>35), + 'duration'=>array('label'=>$langs->trans("NbUseDaysCPShort"), 'checked'=>1, 'position'=>38), + 'cp.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>40), + 'cp.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>42), + 'cp.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1, 'position'=>60), + 'cp.date_approve'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1, 'position'=>70), + 'cp.date_create'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'cp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>501), + 'cp.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} + /* @@ -130,7 +158,7 @@ $fieldstosearchall = array( if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -$parameters=array(); +$parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -180,59 +208,21 @@ if (empty($reshook)) $form = new Form($db); $formother = new FormOther($db); +$formfile = new FormFile($db); -$holiday = new Holiday($db); -$holidaystatic=new Holiday($db); $fuser = new User($db); +$holidaystatic=new Holiday($db); // Update sold -$result = $holiday->updateBalance(); +$result = $object->updateBalance(); + +$title = $langs->trans('CPTitreMenu'); +llxHeader('', $title); $max_year = 5; $min_year = 10; -$filter=''; -llxHeader('', $langs->trans('CPTitreMenu')); - -$order = $db->order($sortfield, $sortorder).$db->plimit($limit + 1, $offset); - -// Ref -if(!empty($search_ref)) -{ - $filter.= " AND cp.rowid = ".(int) $db->escape($search_ref); -} -// Start date -$filter.= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start); -// End date -$filter.= dolSqlDateFilter("cp.date_fin", $search_day_end, $search_month_end, $search_year_end); -// Create date -$filter.= dolSqlDateFilter("cp.date_create", $search_day_create, $search_month_create, $search_year_create); -// Employee -if(!empty($search_employee) && $search_employee != -1) { - $filter.= " AND cp.fk_user = '".$db->escape($search_employee)."'\n"; -} -// Validator -if(!empty($search_valideur) && $search_valideur != -1) { - $filter.= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n"; -} -// Type -if (!empty($search_type) && $search_type != -1) { - $filter.= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; -} -// Status -if(!empty($search_statut) && $search_statut != -1) { - $filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n"; -} -// Search all -if (!empty($sall)) -{ - $filter.= natural_search(array_keys($fieldstosearchall), $sall); -} - -if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',', $childids).')'; - - -// Récupération de l'ID de l'utilisateur +// Get current user id $user_id = $user->id; if ($id > 0) @@ -246,356 +236,559 @@ if ($id > 0) } // Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy -// Load array $holiday->holiday -if (empty($user->rights->holiday->read_all) || $id > 0) -{ - if ($id > 0) $result = $holiday->fetchByUser($id, $order, $filter); - else $result = $holiday->fetchByUser(join(',', $childids), $order, $filter); -} -else -{ - $result = $holiday->fetchAll($order, $filter); -} -// Si erreur SQL -if ($result == '-1') -{ - print load_fiche_titre($langs->trans('CPTitreMenu'), '', 'title_hrm.png'); +// Load array $object->holiday - dol_print_error($db, $langs->trans('Error').' '.$holiday->error); - exit(); +$sql = "SELECT"; +$sql.= " cp.rowid,"; +$sql.= " cp.ref,"; + +$sql.= " cp.fk_user,"; +$sql.= " cp.fk_type,"; +$sql.= " cp.date_create,"; +$sql.= " cp.tms as date_update,"; +$sql.= " cp.description,"; +$sql.= " cp.date_debut,"; +$sql.= " cp.date_fin,"; +$sql.= " cp.halfday,"; +$sql.= " cp.statut,"; +$sql.= " cp.fk_validator,"; +$sql.= " cp.date_valid,"; +$sql.= " cp.fk_user_valid,"; +$sql.= " cp.date_refuse,"; +$sql.= " cp.fk_user_refuse,"; +$sql.= " cp.date_cancel,"; +$sql.= " cp.fk_user_cancel,"; +$sql.= " cp.detail_refuse,"; + +$sql.= " uu.lastname as user_lastname,"; +$sql.= " uu.firstname as user_firstname,"; +$sql.= " uu.login as user_login,"; +$sql.= " uu.statut as user_statut,"; +$sql.= " uu.photo as user_photo,"; + +$sql.= " ua.lastname as validator_lastname,"; +$sql.= " ua.firstname as validator_firstname,"; +$sql.= " ua.login as validator_login,"; +$sql.= " ua.statut as validator_statut,"; +$sql.= " ua.photo as validator_photo"; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."holiday_extrafields as ef on (cp.rowid = ef.fk_object)"; +$sql.= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; +$sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; +$sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau +// Search all +if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +// Ref +if(!empty($search_ref)) +{ + $sql.= " AND cp.rowid = ".(int) $db->escape($search_ref); +} +// Start date +$sql.= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start); +// End date +$sql.= dolSqlDateFilter("cp.date_fin", $search_day_end, $search_month_end, $search_year_end); +// Create date +$sql.= dolSqlDateFilter("cp.date_create", $search_day_create, $search_month_create, $search_year_create); +// Employee +if(!empty($search_employee) && $search_employee != -1) { + $sql.= " AND cp.fk_user = '".$db->escape($search_employee)."'\n"; +} +// Validator +if(!empty($search_valideur) && $search_valideur != -1) { + $sql.= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n"; +} +// Type +if (!empty($search_type) && $search_type != -1) { + $sql.= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; +} +// Status +if(!empty($search_statut) && $search_statut != -1) { + $sql.= " AND cp.statut = '".$db->escape($search_statut)."'\n"; } +if (empty($user->rights->holiday->read_all)) $sql.=' AND cp.fk_user IN ('.join(',', $childids).')'; +if ($id > 0) $sql.= " AND cp.fk_user IN (".$id.")"; -// Show table of vacations +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; -$num = count($holiday->holiday); +$sql.= $db->order($sortfield, $sortorder); -$arrayofselected=is_array($toselect)?$toselect:array(); - -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); -if ($search_ref) $param.='&search_ref='.urlencode($search_ref); -if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); -if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); -if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); -if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start); -if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); -if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); -if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end); -if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); -if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); -if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); -if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); -if ($search_type > 0) $param.='&search_type='.urlencode($search_type); -if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); - -// List of mass actions available -$arrayofmassactions = array( -//'presend'=>$langs->trans("SendByMail"), -//'builddoc'=>$langs->trans("PDFMerge"), -); -if ($user->rights->holiday->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); - -print ''; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if ($id > 0) print ''; - -if ($id > 0) // For user tab +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; - $head = user_prepare_head($fuser); - - dol_fiche_head($head, 'paidholidays', $title, -1, 'user'); - - dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { - print '
'; - - print '
'; - - showMyBalance($holiday, $user_id); + $page = 0; + $offset = 0; } - - dol_fiche_end(); - - // Buttons for actions - - print '
'; - - $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); - - if ($canedit) - { - print ''.$langs->trans("AddCP").''; - } - - print '
'; } -else + +$sql.= $db->plimit($limit+1, $offset); + + +//print $sql; +$resql = $db->query($sql); +if ($resql) { - $nbtotalofrecords = count($holiday->holiday); - //print $num; - //print count($holiday->holiday); + $num = $db->num_rows($resql); - $newcardbutton=''; - if ($user->rights->holiday->write) + $arrayofselected=is_array($toselect)?$toselect:array(); + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); + if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); + if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); + if ($search_day_start) $param.='&search_day_start='.urlencode($search_day_start); + if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); + if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); + if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end); + if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); + if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); + if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); + if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); + if ($search_type > 0) $param.='&search_type='.urlencode($search_type); + if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + ); + if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); + if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + // Lines of title fields + print ''."\n"; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($id > 0) print ''; + + if ($id > 0) // For user tab { - $newcardbutton.= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); - } + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; + $head = user_prepare_head($fuser); - print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit); + dol_fiche_head($head, 'paidholidays', $title, -1, 'user'); + + dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) + { + print '
'; + + print '
'; + + showMyBalance($object, $user_id); + } + + dol_fiche_end(); + + // Buttons for actions + + print '
'; + + $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); + + if ($canedit) + { + print ''.$langs->trans("AddCP").''; + } + + print '
'; + } + else + { + $title = $langs->trans("ListeCP"); + + $newcardbutton=''; + if ($user->rights->holiday->write) + { + $newcardbutton.= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); + } + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit); + } $topicmail="Information"; $modelmail="leaverequest"; $objecttmp=new Holiday($db); $trackid='leav'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -} -if ($sall) -{ - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; -} - -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=''; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - -print '
'; -print ''."\n"; - -// Filters -print ''; -print ''; - -// Create date -print ''; - - -$morefilter = 'AND employee = 1'; -if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; - -// User -$disabled=0; -// If into the tab holiday of a user ($id is set in such a case) -if ($id && ! GETPOSTISSET('search_employee')) -{ - $search_employee=$id; - $disabled=1; -} -if (! empty($user->rights->holiday->read_all)) // Can see all -{ - if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee', 'int'); - print ''; -} -else -{ - if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee', 'int'); - print ''; -} - -// Approve -if ($user->rights->holiday->read_all) -{ - print ''; -} -else -{ - print ''; -} - -// Type -print ''; -// Duration -print ''; + $moreforfilter=''; -// Start date -print ''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; -// End date -print ''; - -// Status -print ''; - -// Actions -print ''; - -print "\n"; - -print ''; -print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("DateCreateCP", $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("ValidatorCP", $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); -print_liste_field_titre("NbUseDaysCPShort", $_SERVER["PHP_SELF"], '', '', $pram, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("DateDebCP", $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("DateFinCP", $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -print "\n"; - -$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); - - -// If we ask a dedicated card and not allow to see it, we forc on user. -if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) { - $langs->load("errors"); - print ''; - $result = 0; -} -elseif (! empty($holiday->holiday) && !empty($mysoc->country_id)) -{ - // Lines - $userstatic = new User($db); - $approbatorstatic = new User($db); - - $typeleaves=$holiday->getTypes(1, -1); - - foreach($holiday->holiday as $infos_CP) + if (! empty($moreforfilter)) { - // Leave request - $holidaystatic->id=$infos_CP['rowid']; - $holidaystatic->ref=($infos_CP['ref']?$infos_CP['ref']:$infos_CP['rowid']); + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + + + $include = ''; + if (! empty($user->rights->holiday->read_all)) $include = 'hierarchyme'; // Can see all + + print '
'; + print '
'; -print ''; -print ''; -print ''; -$formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0); -print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); - print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); - print ''; - - $validator = new UserGroup($db); - $excludefilter=$user->admin?'':'u.rowid <> '.$user->id; - $valideurobjects = $validator->listUsersForGroup($excludefilter); - $valideurarray = array(); - foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; - print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); - print ' '; -if (empty($mysoc->country_id)) { - setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")), 'errors'); -} else { - $typeleaves=$holidaystatic->getTypes(1, -1); - $arraytypeleaves=array(); - foreach($typeleaves as $key => $val) + if ($sall) { - $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); - //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); - $arraytypeleaves[$val['rowid']]=$labeltoshow; + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; } - print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); -} -print '
 '; -print ''; -$formother->select_year($search_year_start, 'search_year_start', 1, $min_year, $max_year); -print ''; -print ''; -$formother->select_year($search_year_end, 'search_year_end', 1, $min_year, $max_year); -print ''; -$holiday->selectStatutCP($search_statut, 'search_statut'); -print ''; -$searchpicto=$form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
'.$langs->trans("NotEnoughPermissions").'
'."\n"; + + + // Filters + print ''; + + if (! empty($arrayfields['cp.ref']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['cp.fk_user']['checked'])) + { + $morefilter = 'AND employee = 1'; + if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; // User - $userstatic->id=$infos_CP['fk_user']; - $userstatic->lastname=$infos_CP['user_lastname']; - $userstatic->firstname=$infos_CP['user_firstname']; - $userstatic->login=$infos_CP['user_login']; - $userstatic->statut=$infos_CP['user_statut']; - $userstatic->photo=$infos_CP['user_photo']; + $disabled=0; + // If into the tab holiday of a user ($id is set in such a case) + if ($id && ! GETPOSTISSET('search_employee')) + { + $search_employee=$id; + $disabled=1; + } - // Validator - $approbatorstatic->id=$infos_CP['fk_validator']; - $approbatorstatic->lastname=$infos_CP['validator_lastname']; - $approbatorstatic->firstname=$infos_CP['validator_firstname']; - $approbatorstatic->login=$infos_CP['validator_login']; - $approbatorstatic->statut=$infos_CP['validator_statut']; - $approbatorstatic->photo=$infos_CP['validator_photo']; - - $date = $infos_CP['date_create']; - - $starthalfday=($infos_CP['halfday'] == -1 || $infos_CP['halfday'] == 2)?'afternoon':'morning'; - $endhalfday=($infos_CP['halfday'] == 1 || $infos_CP['halfday'] == 2)?'morning':'afternoon'; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Action column - print ''; - - print ''."\n"; } -} -// Si il n'y a pas d'enregistrement suite à une recherche -if ($result == '2') -{ - print ''; - print ''; - print ''; -} + // Approver + if (! empty($arrayfields['cp.fk_validator']['checked'])) + { + if ($user->rights->holiday->read_all) + { + print ''; + } + else + { + print ''; + } + } -print '
'; + print ''; + print '
'; - print $holidaystatic->getNomUrl(1, 1); + print ''; + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''.dol_print_date($date, 'day').''.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).''; - $labeltypeleavetoshow = ($langs->trans($typeleaves[$infos_CP['fk_type']]['code'])!=$typeleaves[$infos_CP['fk_type']]['code'] ? $langs->trans($typeleaves[$infos_CP['fk_type']]['code']) : $typeleaves[$infos_CP['fk_type']]['label']); - print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $infos_CP['fk_type']) : $labeltypeleavetoshow; - print ''; - $nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']); - print $nbopenedday.' '.$langs->trans('DurationDays'); - print ''; - print dol_print_date($infos_CP['date_debut'], 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''; - print dol_print_date($infos_CP['date_fin'], 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''.$holidaystatic->LibStatut($infos_CP['statut'], 5).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($infos_CP['rowid'], $arrayofselected)) $selected=1; - print ''; - } - print '
'.$langs->trans('NoRecordFound').'
'; + $validator = new UserGroup($db); + $excludefilter=$user->admin?'':'u.rowid <> '.$user->id; + $valideurobjects = $validator->listUsersForGroup($excludefilter); + $valideurarray = array(); + foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print ' 
'; -print '
'; + // Type + if (! empty($arrayfields['cp.fk_type']['checked'])) + { + print ''; + if (empty($mysoc->country_id)) { + setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")), 'errors'); + } else { + $typeleaves=$holidaystatic->getTypes(1, -1); + $arraytypeleaves=array(); + foreach($typeleaves as $key => $val) + { + $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); + //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); + $arraytypeleaves[$val['rowid']]=$labeltoshow; + } + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); + } + print ''; + } -print '
'; + // Duration + if (! empty($arrayfields['duration']['checked'])) + { + print ' '; + } -/*if ($user_id == $user->id) -{ - print '
'; - print '
'; - print ''.$langs->trans('AddCP').''; + // Start date + if (! empty($arrayfields['cp.date_debut']['checked'])) + { + print ''; + print ''; + $formother->select_year($search_year_start, 'search_year_start', 1, $min_year, $max_year); + print ''; + } + + // End date + if (! empty($arrayfields['cp.date_fin']['checked'])) + { + print ''; + print ''; + $formother->select_year($search_year_end, 'search_year_end', 1, $min_year, $max_year); + print ''; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Create date + if (! empty($arrayfields['cp.date_create']['checked'])) + { + print ''; + print ''; + $formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0); + print ''; + } + + // Create date + if (! empty($arrayfields['cp.tms']['checked'])) + { + print ''; + print ''; + $formother->select_year($search_year_update, 'search_year_update', 1, $min_year, 0); + print ''; + } + + // Status + if (! empty($arrayfields['cp.statut']['checked'])) + { + print ''; + $object->selectStatutCP($search_statut, 'search_statut'); + print ''; + } + + // Action column + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print ''; + + print "\n"; + + print ''; + if (! empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + + $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + + + // If we ask a dedicated card and not allow to see it, we force on user. + if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) { + $langs->load("errors"); + print ''.$langs->trans("NotEnoughPermissions").''; + $result = 0; + } + elseif ($num > 0 && !empty($mysoc->country_id)) + { + // Lines + $userstatic = new User($db); + $approbatorstatic = new User($db); + + $typeleaves=$object->getTypes(1, -1); + + $i = 0; + $totalarray=array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + // Leave request + $holidaystatic->id=$obj->rowid; + $holidaystatic->ref=($obj->ref?$obj->ref:$obj->rowid); + + // User + $userstatic->id=$obj->fk_user; + $userstatic->lastname=$obj->user_lastname; + $userstatic->firstname=$obj->user_firstname; + $userstatic->login=$obj->user_login; + $userstatic->statut=$obj->user_statut; + $userstatic->photo=$obj->user_photo; + + // Validator + $approbatorstatic->id=$obj->fk_validator; + $approbatorstatic->lastname=$obj->validator_lastname; + $approbatorstatic->firstname=$obj->validator_firstname; + $approbatorstatic->login=$obj->validator_login; + $approbatorstatic->statut=$obj->validator_statut; + $approbatorstatic->photo=$obj->validator_photo; + + $date = $obj->date_create; + $date_modif = $obj->date_update; + + $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; + $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; + + print ''; + + if (! empty($arrayfields['cp.ref']['checked'])) + { + print ''; + print $holidaystatic->getNomUrl(1, 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.fk_user']['checked'])) + { + print ''.$userstatic->getNomUrl(-1, 'leave').''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.fk_validator']['checked'])) + { + print ''.$approbatorstatic->getNomUrl(-1).''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.fk_type']['checked'])) + { + print ''; + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code'])!=$typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); + print empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['duration']['checked'])) + { + print ''; + $nbopenedday=num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); + print $nbopenedday.' '.$langs->trans('DurationDays'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.date_debut']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.date_fin']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (! empty($arrayfields['cp.date_create']['checked'])) + { + print ''.dol_print_date($date, 'dayhour').''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.tms']['checked'])) + { + print ''.dol_print_date($date_modif, 'dayhour').''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['cp.statut']['checked'])) + { + print ''.$holidaystatic->LibStatut($obj->statut, 5).''; + if (! $i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''."\n"; + + $i++; + } + } + + // Si il n'y a pas d'enregistrement suite à une recherche + if ($num == 0) + { + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; + } + + print ''; print '
'; -}*/ + + print ''; +} +else +{ + dol_print_error($db); +} // End of page llxFooter(); diff --git a/htdocs/install/check.php b/htdocs/install/check.php index c4d580bf99f..1e248071135 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -35,7 +35,7 @@ $allowinstall = 0; $allowupgrade = false; $checksok = 1; -$setuplang=GETPOST("selectlang", 'az09', 3)?GETPOST("selectlang", 'az09', 3):$langs->getDefaultLang(); +$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):$langs->getDefaultLang(); $langs->setDefaultLang($setuplang); $langs->load("install"); diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index aaa96e3136a..0e2a1875e21 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -113,12 +113,13 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',165); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_SENTBYMAIL','Ticket message sent by email','Executed when a message is sent from the ticket record','ticket',166); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',167); --- actions not enabled by default (no constant created for that) when we enable module agenda +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modified','Executed when a intervention is modified','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142); +-- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',152); diff --git a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql index 70750494a10..737fe66f9da 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql @@ -70,7 +70,7 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-KONEGIE', 0, 41, '', 0, 6, 1, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-26OKT', 0, 41, '', 0, 10, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-TOUSSAINT', 0, 41, '', 0, 11, 1, 1); -INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-IMMACULE', 0, 41, '', 0, 12 8, 1); +INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-IMMACULE', 0, 41, '', 0, 12, 8, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-24DEC', 0, 41, '', 0, 12, 24, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-SAINTSTEFAN', 0, 41, '', 0, 12, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('AT-Silvester', 0, 41, '', 0, 12, 31, 1); diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 26c2acdf308..c0a03c141bf 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -36,36 +36,36 @@ delete from llx_c_tva; -- ARGENTINA (id country=23) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '21','0','IVA standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '0','0','IVA Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (232, 23,'10.5','0','IVA reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (233, 23, '0','0','IVA Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (233, 23, '21','0','IVA standard rate',1); -- AUSTRALIA (id country=28) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (281, 28, '10','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (282, 28, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (281, 28, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (282, 28, '10','0','VAT standard rate',1); -- AUSTRIA (id country=41) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (411, 41, '20','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (411, 41, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (412, 41, '10','0','VAT reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (413, 41, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (413, 41, '20','0','VAT standard rate',1); -- BRASIL (id country=56) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (561, 56, '0','0','VAT reduced rate',1); -- BULGARIA (id country=59) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (591, 59, '20','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (591, 59, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (592, 59, '7','0','VAT reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (593, 59, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (593, 59, '20','0','VAT standard rate',1); -- BELGIUM (id country=2) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 21, 2, '21','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 21, 2, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 22, 2, '6','0','VAT reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 23, 2, '0','0','VAT Rate 0 ou non applicable',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 23, 2, '21','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 24, 2, '12','0','VAT reduced rate', 1); -- CANADA (id country=14) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (141, 14, '7','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (142, 14, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (141, 14, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (142, 14, '7','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (143, 14,'5','0','9.975','1','GST/TPS and PST/TVQ rate for Province',1); --insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (143, 14,'5','0','9.975','1','GST/TPS and PST/TVQ rate for Quebec',1); --insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (144, 14,'5','0','7','1','GST/TPS and PST/TVQ rate for British Columbia',1); @@ -73,72 +73,73 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_typ -- CAMEROUN (id country=24) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (241, 24, '19.25','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (242, 24, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (241, 24, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (242, 24, '19.25','0','VAT standard rate',1); -- CHILE (id country=67) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (671, 67, '19','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (672, 67, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (671, 67, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (672, 67, '19','0','VAT standard rate',1); -- CHINA (id country=9) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 91, 9, '17','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 91, 9, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 92, 9, '13','0','VAT reduced rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 93, 9, '3','0','VAT super reduced rate 0',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 94, 9, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 94, 9, '17','0','VAT standard rate',1); -- CYPRUS (id country=78) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (781, 78, '19','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (781, 78, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (782, 78, '9','0','VAT Rate 9',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (783, 78, '5','0','VAT Rate 5',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (784, 78, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (784, 78, '19','0','VAT standard rate',1); -- DANMERK (id country=80) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (801, 80, '25','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (802, 80, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (801, 80, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (802, 80, '25','0','VAT standard rate',1); -- FRANCE (id country=1) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '0','0','VAT Rate 0 ou non applicable',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 12, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 13, 1, '10','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT reduced rate (France hors DOM-TOM)',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 16, 1, '2.1','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 17, 1, '10','0','VAT reduced rate',1); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '2.1','0','VAT super-reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values (16, 1, '8.5', '85', '0', 'VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); +insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values (17, 1, '8.5', '85NPR', '1', 'VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (18, 1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (19, 1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); -- GERMANY (id country=5) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 51, 5, '19.0','0','allgemeine Ust.',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 51, 5, '0','0','No VAT', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 52, 5, '7.0','0','ermäßigte USt.', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 53, 5, '0.0','0','keine USt.', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 54, 5, '5.5','0','USt. Forst', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 55, 5, '10.7','0','USt. Landwirtschaft', 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 56, 5, '19.0','0','allgemeine Ust.',1); -- GREECE (id country=102) -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2462, 102, 24, 0, '0', 0, '0', 0, 'Κανονικός Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2463, 102, 0, 0, '0', 0, '0', 0, 'Μηδενικό Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2464, 102, 13, 0, '0', 0, '0', 0, 'Μειωμένος Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2465, 102, 6.5, 0, '0', 0, '0', 0, 'Υπερμειωμένος Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2466, 102, 16, 0, '0', 0, '0', 0, 'Νήσων κανονικός Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2467, 102, 9, 0, '0', 0, '0', 0, 'Νήσων μειωμένος Φ.Π.Α.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2468, 102, 5, 0, '0', 0, '0', 0, 'Νήσων υπερμειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1021, 102, 0, 0, '0', 0, '0', 0, 'Μηδενικό Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1022, 102, 24, 0, '0', 0, '0', 0, 'Κανονικός Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1023, 102, 13, 0, '0', 0, '0', 0, 'Μειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1024, 102, 6.5, 0, '0', 0, '0', 0, 'Υπερμειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1025, 102, 16, 0, '0', 0, '0', 0, 'Νήσων κανονικός Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1026, 102, 9, 0, '0', 0, '0', 0, 'Νήσων μειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1027, 102, 5, 0, '0', 0, '0', 0, 'Νήσων υπερμειωμένος Φ.Π.Α.', 1); -- ICELAND (id country=116) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1161, 116,'25.5','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1161, 116, '0','0','VAT rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1163, 116,'25.5','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1162, 116, '7','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1163, 116, '0','0','VAT rate 0',1); -- INDIA (id country=117) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '0','0','VAT Rate 0', 0); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1178, 117, 'C+S-5', 0, 2.5, '1', 2.5, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1179, 117, 'I-5' , 5, 0, '0', 0, '0', 0, 'IGST', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1180, 117, 'C+S-12', 0, 6, '1', 6, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1181, 117, 'I-12' , 12, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1172, 117, 'C+S-5' , 0, 2.5, '1', 2.5, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1173, 117, 'I-5' , 5, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1174, 117, 'C+S-12', 0, 6, '1', 6, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1175, 117, 'I-12' , 12, 0, '0', 0, '0', 0, 'IGST', 1); insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'C+S-18', 0, 9, '1', 9, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'I-18' , 18, 0, '0', 0, '0', 0, 'IGST', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1182, 117, 'C+S-28', 0, 14, '1', 14, '1', 0, 'CGST+SGST - Same state sales', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1183, 117, 'I-28' , 28, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'I-18' , 18, 0, '0', 0, '0', 0, 'IGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1178, 117, 'C+S-28', 0, 14, '1', 14, '1', 0, 'CGST+SGST - Same state sales', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1179, 117, 'I-28' , 28, 0, '0', 0, '0', 0, 'IGST', 1); -- IRELAND (id country=8) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 81, 8, '0','0','VAT Rate 0',1); @@ -148,165 +149,165 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 8 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 85, 8, '4.8','0','VAT reduced rate',1); -- ITALY (id country=3) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 31, 3, '22','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 31, 3, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 32, 3, '10','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 33, 3, '4','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '22','0','VAT standard rate',1); -- IVORY COST (id country=21) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (211, 21, '0','0',0,0,0,0,'IVA Rate 0',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (212, 21, '18','0',7.5,2,0,0,'IVA standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (212, 21, '18','0',7.5,2,0,0,'IVA standard rate',1); -- JAPAN (id country=123) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1231, 123, '0','0','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1232, 123, '5','0','VAT Rate 5',1); -- LUXEMBOURG (id country=140) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1401, 140, '17','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1401, 140, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1402, 140, '14','0','VAT intermediary rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1403, 140, '8','0','VAT reduced rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1404, 140, '3','0','VAT super-reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1405, 140, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1405, 140, '17','0','VAT standard rate',1); -- MONACO (id country=27) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 271, 27,'19.6','0','VAT standard rate (France hors DOM-TOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 271, 27, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 272, 27, '8.5','0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 273, 27, '8.5','1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 274, 27, '5.5','0','VAT reduced rate (France hors DOM-TOM)',0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 275, 27, '0','0','VAT Rate 0 ou non applicable',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 275, 27,'19.6','0','VAT standard rate (France hors DOM-TOM)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 276, 27, '2.1','0','VAT super-reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 277, 27, '7','0','VAT reduced rate',1); -- MAROCO (id country=12) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 121, 12, '20','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 121, 12, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 122, 12, '14','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 123, 12, '10','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 124, 12, '7','0','VAT super-reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 125, 12, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 125, 12, '20','0','VAT standard rate',1); -- MALTA (id country=148) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1481, 148, '18','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1481, 148, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1482, 148, '7','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1483, 148, '5','0','VAT super-reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1484, 148, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1484, 148, '18','0','VAT standard rate',1); -- NEDERLAND (id country=17) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 171, 17, '19','0','Algemeen BTW tarief',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 171, 17, '0','0','0 BTW tarief', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 172, 17, '6','0','Verlaagd BTW tarief', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '0','0','0 BTW tarief', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '19','0','Algemeen BTW tarief',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 174, 17, '21','0','Algemeen BTW tarief (vanaf 1 oktober 2012)',0); -- NEW ZEALAND (id country=166) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1661, 166, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1663, 166, '0','0','VAT Rate 0', 1); -- NIGERIA (id country=169) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1691, 169, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1692, 169, '5','0','VAT standard rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1693, 169, '0','0','VAT Rate 0', 1); -- NORWAY (id country=173) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1731, 173, '25','0','VAT standard rate', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1731, 173, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1732, 173, '14','0','VAT reduced rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1733, 173, '8','0','VAT reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1734, 173, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1734, 173, '25','0','VAT standard rate', 1); -- PANAMA (id country=178) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1781, 178, '7','0','ITBMS standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1782, 178, '0','0','ITBMS Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1781, 178, '0','0','ITBMS Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1782, 178, '7','0','ITBMS standard rate',1); -- PERU (id country=181) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1811, 181, '18','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1812, 181, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1811, 181, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1818, 181, '18','0','VAT standard rate',1); -- POLAND (id country=184) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1841, 184, '23','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1841, 184, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1842, 184, '8','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1843, 184, '3','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1844, 184, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1844, 184, '23','0','VAT standard rate',1); -- PORTUGAL (id country=25) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 251, 25, '23','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 251, 25, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 252, 25, '13','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 253, 25, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 253, 25, '23','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 254, 25, '6','0','VAT reduced rate',1); -- ROMANIA (id country=188) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1881, 188, '19','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1881, 188, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1882, 188, '9','0','VAT reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1883, 188, '19','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1884, 188, '5','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1883, 188, '0','0','VAT Rate 0', 1); -- SAUDI ARABIA (id country=26) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 261, 26, '0', '0', 'VAT Rate 0', 1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 262, 26, '5', '0', 'VAT Rate 5', 1); -- SAN SALVADOR (id country=86) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 861, 86, '13', '0', 'IVA 13', 1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 862, 86, '0', '0', 'SIN IVA', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 861, 86, '0', '0', 'SIN IVA', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 862, 86, '13', '0', 'IVA 13', 1); -- SENEGAL (id country=22) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 221, 22, '18', '0', 'VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 221, 22, '0', '0', 'VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 222, 22, '10', '0', 'VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 223, 22, '0', '0', 'VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 223, 22, '18', '0', 'VAT standard rate',1); -- SLOVAKIA (id country=201) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2011, 201, '19', '0', 'VAT standard rate', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2011, 201, '0', '0', 'VAT Rate 0', 1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2012, 201, '10', '0', 'VAT reduced rate', 1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2013, 201, '0', '0', 'VAT Rate 0', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2013, 201, '19', '0', 'VAT standard rate', 1); -- SLOVENIA (id country=202) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2021, 202, '22', '0', 'VAT standard rate', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2021, 202, '0', '0', 'VAT Rate 0', 1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2022, 202,'9.5', '0', 'VAT reduced rate', 1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2023, 202, '0', '0', 'VAT Rate 0', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2023, 202, '22', '0', 'VAT standard rate', 1); -- SOUTH AFRICA (id country=205) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2051, 205, '15', '0', 'VAT standard rate', 1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2053, 205, '0', '0', 'VAT Rate 0', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2051, 205, '0', '0', 'VAT Rate 0', 1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2052, 205, '15', '0', 'VAT standard rate', 1); -- SPAIN (id country=4) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 41, 4,'21','0','5.2','3','-19:-15:-9','5','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 41, 4, '0','0', '0','3','-19:-15:-9','5','VAT Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 42, 4,'10','0','1.4','3','-19:-15:-9','5','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 43, 4, '4','0','0.5','3','-19:-15:-9','5','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 44, 4, '0','0', '0','3','-19:-15:-9','5','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 44, 4,'21','0','5.2','3','-19:-15:-9','5','VAT standard rate',1); -- SWEDEN (id country=20) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 201, 20, '25','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 201, 20, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 202, 20, '12','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 203, 20, '6','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 204, 20, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 204, 20, '25','0','VAT standard rate',1); -- SWITZERLAND (id country=6) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 61, 6, '7.7','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 61, 6, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 62, 6, '3.7','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 63, 6, '2.5','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '7.7','0','VAT standard rate',1); -- SRI LANKA (id country=207) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2071, 207, '0','0','VAT 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2072, 207, '15','0','VAT 15%', 1); -- TAIWAN (id country=213) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2131, 213, '5','0','VAT 5%',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2132, 213, '0','0','VAT 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2131, 213, '0','0','VAT 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2132, 213, '5','0','VAT 5%',1); -- TUNISIA (id country=10) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '6','0','VAT 6%', 1, 1, '4', 0, 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '0','0','VAT Rate 0', 1, 1, '4', 0, 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0, 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0, 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0, 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0, 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '0','0','VAT Rate 0', 1, 1, '4', 0, 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '6','0','VAT 6%', 1, 1, '4', 0, 0); -- UKRAINE (id country=226) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '20','0','VAT standart rate',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2262,226, '0','0','VAT Rate 0',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '0','0','VAT Rate 0',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2262,226, '20','0','VAT standart rate',1); -- UNITED OF KINGDOM (id country=7) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 71, 7, '20','0','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 71, 7, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 72, 7, '17.5','0','VAT standard rate before 2011',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 73, 7, '5','0','VAT reduced rate', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 74, 7, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 74, 7, '20','0','VAT standard rate',1); -- UNITED STATES (id country=11) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (111,11, '0','0','No Sales Tax',1); @@ -325,35 +326,40 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (24 -- MAURITANIA (id country=151) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1511,151, '0','0','VAT Rate 0',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1512,151, '14','0','VAT Rate 14',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1512,151, '14','0','VAT Rate 14',1); -- MAURITIUS (id country=152) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1521,152, '0','0','VAT Rate 0',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1522,152, '15','0','VAT Rate 15',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1522,152, '15','0','VAT Rate 15',1); -- HONDURAS (id country=114) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1141,114, '0','0','No ISV',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1142,114, '12','0','ISV 12%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1142,114, '12','0','ISV 12%',1); -- MEXIQUE (id country=154) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1541,154, '0','0','No VAT',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1542,154, '16','0','VAT 16%',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1543,154, '10','0','VAT Frontero',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1542,154, '16','0','VAT 16%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1543,154, '10','0','VAT Frontero',1); -- BARBADOS (id country=46) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 461, 46, '0','0','No VAT',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 462, 46, '15','0','VAT 15%',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 463, 46, '7.5','0','VAT 7.5%',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 462, 46, '15','0','VAT 15%',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 463, 46, '7.5','0','VAT 7.5%',1); -- SOUTH AFRICA (id country=205) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2051,205, '0','0','No VAT',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2052,205, '14','0','VAT 14%',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2052,205, '14','0','VAT 14%',1); -- VENEZUELA (id country=232) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2321,232, '0','0','No VAT',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1); +-- Example of code to insert a vat rate 0 for each country +--delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1') +--insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva); + + diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 4a86d4ada9c..b03d3ffdf17 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -33,6 +33,23 @@ ALTER TABLE llx_account_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL ALTER TABLE llx_expensereport ADD COLUMN paid smallint default 0 NOT NULL; UPDATE llx_expensereport set paid = 1 WHERE fk_statut = 6 and paid = 0; + +-- For v11 + +create table llx_holiday_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_holiday_extrafields ADD INDEX idx_holiday_extrafields (fk_object); + +ALTER TABLE llx_societe_rib MODIFY label varchar(200); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_SENTBYMAIL','Email sent','Executed when an email is sent from user card','user',300); + create table llx_entrepot_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 51fe48dcda2..4d87203b068 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -468,6 +468,12 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS -- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; +-- Note to make all deposit as payed when there is already a discount generated from it. +--drop table tmp_invoice_deposit_mark_as_available; +--create table tmp_invoice_deposit_mark_as_available as select * from llx_facture as f where f.type = 3 and f.paye = 0 and f.rowid in (select fk_facture_source from llx_societe_remise_except); +--update llx_facture set paye = 1 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available); + + -- Note to migrate from old counter aquarium to new one -- drop table tmp; diff --git a/htdocs/install/mysql/tables/llx_holiday_extrafields.key.sql b/htdocs/install/mysql/tables/llx_holiday_extrafields.key.sql new file mode 100644 index 00000000000..6558fdef503 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_extrafields.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_holiday_extrafields ADD INDEX idx_holiday_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_holiday_extrafields.sql b/htdocs/install/mysql/tables/llx_holiday_extrafields.sql new file mode 100644 index 00000000000..29881bbb0cb --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_holiday_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_societe_rib.sql b/htdocs/install/mysql/tables/llx_societe_rib.sql index 5bfc6d10fd6..adabd0ab35f 100644 --- a/htdocs/install/mysql/tables/llx_societe_rib.sql +++ b/htdocs/install/mysql/tables/llx_societe_rib.sql @@ -24,7 +24,7 @@ create table llx_societe_rib ( rowid integer AUTO_INCREMENT PRIMARY KEY, type varchar(32) DEFAULT 'ban' NOT NULL, -- 'ban' or 'paypal' or 'card' or 'stripe' - label varchar(30), + label varchar(200), fk_soc integer NOT NULL, datec datetime, tms timestamp, diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index d34d43384d0..95ad4d2d563 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -42,7 +42,7 @@ error_reporting(0); @set_time_limit(120); error_reporting($err); -$setuplang=GETPOST("selectlang", 'az09', 3)?GETPOST("selectlang", 'az09', 3):'auto'; +$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):'auto'; $langs->setDefaultLang($setuplang); $langs->loadLangs(array("admin","install","other")); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 08c1069e457..efe599ed291 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1060,7 +1060,7 @@ BackgroundImageLogin=Background image PermanentLeftSearchForm=Permanent search form on left menu DefaultLanguage=Default language EnableMultilangInterface=Enable multilanguage support -EnableShowLogo=Show logo on left menu +EnableShowLogo=Show the company logo in the menu CompanyInfo=Company/Organization CompanyIds=Company/Organization identities CompanyName=Name @@ -1908,6 +1908,7 @@ ResourceSetup=Configuration of Resource module UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). DisabledResourceLinkUser=Disable feature to link a resource to users DisabledResourceLinkContact=Disable feature to link a resource to contacts +EnableResourceUsedInEventCheck=Enable feature to check if a resource is in use in an event ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 47295ec7e31..44f80c7c3b7 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -169,3 +169,7 @@ FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make d AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation CashControl=POS cash fence NewCashFence=New cash fence +BankColorizeMovement=Colorize movements +BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements +BankColorizeMovementName1=Background color for debit movement +BankColorizeMovementName2=Background color for credit movement diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 145f996c4f2..9e31180f3ea 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -8,7 +8,6 @@ NotActiveModCP=You must enable the module Leave to view this page. AddCP=Make a leave request DateDebCP=Start date DateFinCP=End date -DateCreateCP=Creation date DraftCP=Draft ToReviewCP=Awaiting approval ApprovedCP=Approved diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index e0a1a5f8fcf..9919767db0f 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -153,6 +153,7 @@ RowMaterial=Raw Material ConfirmCloneProduct=Are you sure you want to clone product or service %s? CloneContentProduct=Clone all main information of product/service ClonePricesProduct=Clone prices +CloneCategoriesProduct=Clone tags/categories linked CloneCompositionProduct=Clone virtual product/service CloneCombinationsProduct=Clone product variants ProductIsUsed=This product is used diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang index 33a5046e006..134cc4c87a3 100644 --- a/htdocs/langs/en_US/resource.lang +++ b/htdocs/langs/en_US/resource.lang @@ -34,3 +34,6 @@ IdResource=Id resource AssetNumber=Serial number ResourceTypeCode=Resource type code ImportDataset_resource_1=Resources + +ErrorResourcesAlreadyInUse=Some resources are in use +ErrorResourceUseInEvent=%s use in %s event \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ff684f01cb9..3d15d7fe3d4 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1907,6 +1907,7 @@ ResourceSetup=Configuration du module Ressource UseSearchToSelectResource=Utilisez un champ avec auto-complétion pour choisir les ressources (plutôt qu'une liste déroulante). DisabledResourceLinkUser=Désactiver la fonctionnalité pour lier une ressource aux utilisateurs DisabledResourceLinkContact=Désactiver la fonctionnalité pour lier une ressource aux contacts/adresses +EnableResourceUsedInEventCheck=Activer la fonctionnalité de vérification d'une ressource déjà réservée lors d'un évènement ConfirmUnactivation=Confirmer réinitialisation du module OnMobileOnly=Sur petit écran (smartphone) uniquement DisableProspectCustomerType=Désactiver le type de tiers "Prospect + Client" (le tiers doit donc être un client potentiel ou un client, mais ne peut pas être les deux) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index a0473ad8c76..0248f6470a9 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -153,6 +153,8 @@ RowMaterial=Matière première ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service %s ? CloneContentProduct=Cloner les informations générales du produit/service ClonePricesProduct=Cloner les prix +CloneCategoriesProduct=Cloner les catégories associées +CloneCompositionProduct=Cloner le produits packagés CloneCompositionProduct=Cloner les produits virtuels CloneCombinationsProduct=Cloner les variantes ProductIsUsed=Ce produit est utilisé diff --git a/htdocs/langs/fr_FR/resource.lang b/htdocs/langs/fr_FR/resource.lang index be7547b36da..5db22aedcbd 100644 --- a/htdocs/langs/fr_FR/resource.lang +++ b/htdocs/langs/fr_FR/resource.lang @@ -34,3 +34,6 @@ IdResource=id ressource AssetNumber=Numéro de série ResourceTypeCode=Code de type de ressource ImportDataset_resource_1=Ressources + +ErrorResourcesAlreadyInUse=Des ressources sont déjà occupées +ErrorResourceUseInEvent=%s occupée dans l'événement %s \ No newline at end of file diff --git a/htdocs/langs/fr_NC/admin.lang b/htdocs/langs/fr_NC/admin.lang index d86b324fdc5..f7c25610e3f 100644 --- a/htdocs/langs/fr_NC/admin.lang +++ b/htdocs/langs/fr_NC/admin.lang @@ -1,4 +1,4 @@ # Dolibarr language file - Source file is en_US - admin -VATManagement=Gestion TSS -VATIsUsedDesc=Le taux de TSS proposé par défaut lors de la création de proposition commerciale, facture, commande, etc... répond à la règle standard suivante :
Si vendeur non assujetti à TSS, TSS par défaut=0. Fin de règle.
Si le (pays vendeur= pays acheteur) alors TSS par défaut=TSS du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TSS par défaut=0 (La TSS doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TSS par défaut=TSS du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TSS par défaut=0. Fin de règle.
Sinon TSS proposée par défaut=0. Fin de règle.
-VATIsNotUsedDesc=Le taux de TSS proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés. +VATManagement=Gestion TGC +VATIsUsedDesc=Le taux de TGC proposé par défaut lors de la création de proposition commerciale, facture, commande, etc... répond à la règle standard suivante :
Si vendeur non assujetti à TGC, TGC par défaut=0. Fin de règle.
Si le (pays vendeur= pays acheteur) alors TGC par défaut=TGC du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TGC par défaut=0 (La TGC doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TGC par défaut=TGC du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TGC par défaut=0. Fin de règle.
Sinon TGC proposée par défaut=0. Fin de règle.
+VATIsNotUsedDesc=Le taux de TGC proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés. diff --git a/htdocs/langs/fr_NC/companies.lang b/htdocs/langs/fr_NC/companies.lang index 9853f7e7e21..c3520226e42 100644 --- a/htdocs/langs/fr_NC/companies.lang +++ b/htdocs/langs/fr_NC/companies.lang @@ -1,3 +1,3 @@ # Dolibarr language file - Source file is en_US - companies -VATIsUsed=Assujetti à la TSS -VATIsNotUsed=Non assujetti à la TSS +VATIsUsed=Assujetti à la TGC +VATIsNotUsed=Non assujetti à la TGC diff --git a/htdocs/langs/fr_NC/compta.lang b/htdocs/langs/fr_NC/compta.lang index f22e834c4a5..2d7a5468f84 100644 --- a/htdocs/langs/fr_NC/compta.lang +++ b/htdocs/langs/fr_NC/compta.lang @@ -1,21 +1,21 @@ # Dolibarr language file - Source file is en_US - compta -VATToPay=TSS ventes -VATReceived=TSS collectée -VATToCollect=TSS achats -VATSummary=Balance de TSS -VATPaid=TSS payée -VATCollected=TSS récupérée -PaymentVat=Règlement TSS -VATPayment=Règlement TSS -VATPayments=Règlements TSS -ShowVatPayment=Affiche paiement TSS -RulesResultInOut=- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TSS.
- Il se base sur la date de règlement de ces factures, charges et TSS. -VATReportByCustomersInInputOutputMode=Rapport par client des TSS collectées et payées (TSS sur encaissement) -VATReportByQuartersInInputOutputMode=Rapport par taux des TSS collectées et payées (TSS sur encaissement) -SeeVATReportInInputOutputMode=Voir le rapport %sTSS encaissement%s pour mode de calcul standard -SeeVATReportInDueDebtMode=Voir le rapport %sTSS sur débit%s pour mode de calcul avec option sur les débits -RulesVATInServices=- Pour les services, le rapport inclut les TSS des règlements effectivement reçus ou émis en se basant sur la date du règlement. -RulesVATInProducts=- Pour les biens matériels, il inclut les TSS des factures en se basant sur la date de facture. -RulesVATDueServices=- Pour les services, le rapport inclut les TSS des factures dues, payées ou non en se basant sur la date de facture. -RulesVATDueProducts=- Pour les biens matériels, il inclut les TSS des factures en se basant sur la date de facture. -CalculationRuleDesc=Pour calculer le total de TSS, il existe 2 modes:
Le mode 1 consiste à arrondir la TSS de chaque ligne et à sommer cet arrondi.
Le mode 2 consiste à sommer la tva de chaque ligne puis à l'arrondir.
Les résultats peuvent différer de quelques centimes. Le mode par défaut est le mode %s. +VATToPay=TGC ventes +VATReceived=TGC collectée +VATToCollect=TGC achats +VATSummary=Balance de TGC +VATPaid=TGC payée +VATCollected=TGC récupérée +PaymentVat=Règlement TGC +VATPayment=Règlement TGC +VATPayments=Règlements TGC +ShowVatPayment=Affiche paiement TGC +RulesResultInOut=- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TGC.
- Il se base sur la date de règlement de ces factures, charges et TGC. +VATReportByCustomersInInputOutputMode=Rapport par client des TGC collectées et payées (TGC sur encaissement) +VATReportByQuartersInInputOutputMode=Rapport par taux des TGC collectées et payées (TGC sur encaissement) +SeeVATReportInInputOutputMode=Voir le rapport %sTGC encaissement%s pour mode de calcul standard +SeeVATReportInDueDebtMode=Voir le rapport %sTGC sur débit%s pour mode de calcul avec option sur les débits +RulesVATInServices=- Pour les services, le rapport inclut les TGC des règlements effectivement reçus ou émis en se basant sur la date du règlement. +RulesVATInProducts=- Pour les biens matériels, il inclut les TGC des factures en se basant sur la date de facture. +RulesVATDueServices=- Pour les services, le rapport inclut les TGC des factures dues, payées ou non en se basant sur la date de facture. +RulesVATDueProducts=- Pour les biens matériels, il inclut les TGC des factures en se basant sur la date de facture. +CalculationRuleDesc=Pour calculer le total de TGC, il existe 2 modes:
Le mode 1 consiste à arrondir la TGC de chaque ligne et à sommer cet arrondi.
Le mode 2 consiste à sommer la tva de chaque ligne puis à l'arrondir.
Les résultats peuvent différer de quelques centimes. Le mode par défaut est le mode %s. diff --git a/htdocs/langs/fr_NC/main.lang b/htdocs/langs/fr_NC/main.lang index 82c7a4ee746..c2d48114259 100644 --- a/htdocs/langs/fr_NC/main.lang +++ b/htdocs/langs/fr_NC/main.lang @@ -3,7 +3,7 @@ DIRECTION=ltr FONTFORPDF=helvetica FONTSIZEFORPDF=10 SeparatorDecimal=, -SeparatorThousand=None +SeparatorThousand=Space FormatDateShort=%d/%m/%Y FormatDateShortInput=%d/%m/%Y FormatDateShortJava=dd/MM/yyyy @@ -20,7 +20,7 @@ FormatDateHourSecShort=%d/%m/%Y %H:%M:%S FormatDateHourTextShort=%d %b %Y %H:%M FormatDateHourText=%d %B %Y %H:%M ErrorNoVATRateDefinedForSellerCountry=Erreur, aucun taux de taxe défini pour le pays '%s'. -AmountVAT=Montant TSS -TotalVAT=Total TSS -VAT=TSS -VATRate=Taux TSS +AmountVAT=Montant TGC +TotalVAT=Total TGC +VAT=TGC +VATRate=Taux TGC diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 014ca843236..5fd79e96c23 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -79,6 +79,8 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/union.+select/i', $val); $inj += preg_match('/(\.\.%2f)+/i', $val); } + // For XSS Injection done by closing textarea to exucute content into a textarea field + $inj += preg_match('/<\/textarea/i', $val); // For XSS Injection done by adding javascript with script // This is all cases a browser consider text is javascript: // When it found ''.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a2bd9d39fe7..b7baf32089f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -291,7 +291,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && ! $page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index abad76ce228..8f946a30001 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -197,7 +197,7 @@ if (! empty($conf->banque->enabled)) { print ''; print $langs->trans("BankAccount").''; - print $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); print ''; } diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index aefcb50369a..545fe9c368c 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -214,7 +214,7 @@ if (! empty($conf->banque->enabled)) { print ''; print $langs->trans("BankAccount").''; - print $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); print ''; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5be4dc43358..d6dd9e876cd 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -522,6 +522,19 @@ if (empty($reshook)) } } + if (GETPOST('clone_categories')) + { + $result = $object->cloneCategories($originalId, $id); + + if ($result < 1) + { + $db->rollback(); + setEventMessage($langs->trans('ErrorProductClone'), null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); + exit; + } + } + // $object->clone_fournisseurs($originalId, $id); $db->commit(); @@ -1951,6 +1964,7 @@ $formquestionclone=array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), ); if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 446b4fa3cfe..812c2df7459 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -467,6 +467,94 @@ class Products extends DolibarrApi ); } + + /** + * List purchase prices + * + * Get a list of all purchase prices of products + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category of product + * @param int $supplier Use this param to filter list by supplier + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" + * @return array Array of product objects + * + * @url GET purchase_prices + */ + public function getSupplierProducts($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $supplier = 0, $sqlfilters = '') + { + global $db, $conf; + $obj_ret = array(); + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $sql = "SELECT t.rowid, t.ref, t.ref_ext"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; + if ($category > 0) { + $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c"; + } + $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s"; + + $sql.= ' WHERE t.entity IN ('.getEntity('product').')'; + + if ($supplier > 0) { + $sql.= " AND s.fk_soc = ".$db->escape($supplier); + } + $sql.= " AND s.fk_product = t.rowid "; + // Select products of given category + if ($category > 0) { + $sql.= " AND c.fk_categorie = ".$db->escape($category); + $sql.= " AND c.fk_product = t.rowid "; + } + if ($mode == 1) { + // Show only products + $sql.= " AND t.fk_product_type = 0"; + } elseif ($mode == 2) { + // Show only services + $sql.= " AND t.fk_product_type = 1"; + } + // Add sql filters + if ($sqlfilters) { + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + $sql.= $db->plimit($limit + 1, $offset); + } + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $product_static = new Product($db); + if($product_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($product_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror()); + } + if(! count($obj_ret)) { + throw new RestException(404, 'No product found'); + } + return $obj_ret; + } + /** * Get purchase prices for a product * @@ -515,7 +603,7 @@ class Products extends DolibarrApi if($result) { $this->product = new ProductFournisseur($this->db); $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, $sortfield, $sortorder, 0, 0); + $this->product->list_product_fournisseur_price($id, '', '', 0, 0); } return $this->_cleanObjectDatas($this->product); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index dd88c3dfa8a..647ffda194d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3487,7 +3487,7 @@ class Product extends CommonObject * @param int $id_fourn Supplier id * @param string $ref_fourn Supplier ref * @param float $quantity Quantity minimum for price - * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK + * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK */ public function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { @@ -3498,6 +3498,9 @@ class Product extends CommonObject dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); + // Clean parameters + $quantity = price2num($quantity, 'MS'); + if ($ref_fourn) { $sql = "SELECT rowid, fk_product"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; @@ -3524,7 +3527,7 @@ class Product extends CommonObject if ($ref_fourn) { $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; } else { $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } - $sql.= " AND quantity = '".$quantity."'"; + $sql.= " AND quantity = ".$quantity; $sql.= " AND fk_product = ".$this->id; $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index cb56ff63cfc..42644f24098 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -154,7 +154,7 @@ if (empty($reshook)) if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); $ref_fourn_old=GETPOST("ref_fourn_old"); if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; - $quantity=GETPOST("qty"); + $quantity=price2num(GETPOST("qty", 'nohtml'), 'MS'); $remise_percent=price2num(GETPOST('remise_percent', 'alpha')); $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; $tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); @@ -481,7 +481,7 @@ if ($id > 0 || $ref) print ''; print ''.$langs->trans("QtyMin").''; print ''; - $quantity = GETPOST('qty') ? GETPOST('qty') : "1"; + $quantity = GETPOSTISSET('qty') ? price2num(GETPOST('qty', 'nohtml'), 'MS') : "1"; if ($rowid) { print ''; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 26cb0e7b828..6b9247530fd 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -54,19 +54,17 @@ $sortorder = GETPOST("sortorder", 'alpha'); $max=3; - /* * View */ $companystatic=new Societe($db); $projectstatic=new Project($db); -$userstatic=new User($db); $form=new Form($db); $formfile=new FormFile($db); $projectset = ($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projetset, 1); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projectset, 1); //var_dump($projectsListId); llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); @@ -80,14 +78,15 @@ $titleall=$langs->trans("AllAllowedProjects"); if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects"); else $titleall=$langs->trans("AllAllowedProjects").'

'; - $morehtml=''; -$morehtml.='
'; +$morehtml.=''; +$morehtml.=''; $morehtml.=''; $morehtml.=''; +$morehtml.='
'; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'title_project.png', 0, $morehtml); @@ -170,7 +169,6 @@ print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppst print '
'; - // Last modified projects $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.tms as datem,"; $sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas"; diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index d137b7be456..7f482367eba 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -23,13 +23,14 @@ a:hover { font-weight: normal; color: #444444 !important; - margin: 8px 0px 8px 2px; + margin: 8px 2px 8px 2px; /*border: 1px solid #bbb; border-radius: 8px; -moz-border-radius: 8px;*/ - background: -webkit-linear-gradient(bottom, rgb(255,255,255) 85%, rgb(255,255,255) 100%); + + max-width: 346px; } .csscolumns { margin-top: 6px; @@ -99,7 +100,7 @@ img.demothumb { width: 110px; } .demobackground { - background-image: url('dolibarr_demo_ban.jpg'); + background-image: linear-gradient(to bottom, rgba(250,250,255,0.5), rgba(250,250,255,0.4)), url('dolibarr_demo_ban.jpg'); background-size: cover; object-fit: contain; height: 140px; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 62de885eac6..d2633d9c708 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -336,7 +336,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
'."\n"; + print '
'."\n"; print '
'; diff --git a/htdocs/public/paybox/index.php b/htdocs/public/paybox/index.php deleted file mode 100644 index 58d748aba72..00000000000 --- a/htdocs/public/paybox/index.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paybox/index.php - * \ingroup core - * \brief A redirect page to an error - * \author Laurent Destailleur - */ - -require '../../master.inc.php'; - -header("Location: ".DOL_URL_ROOT.'/public/error-404.php'); diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php deleted file mode 100644 index 319c40f2c18..00000000000 --- a/htdocs/public/paybox/newpayment.php +++ /dev/null @@ -1,49 +0,0 @@ - - * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paybox/newpayment.php - * \ingroup paybox - * \brief File to offer a way to make a payment for a particular Dolibarr entity - * \author Laurent Destailleur - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -// Security check -if (empty($conf->paybox->enabled)) accessforbidden('', 0, 0, 1); - -$newurl = $_SERVER['REQUEST_URI']; -$newurl = preg_replace('/\/paybox\/newpayment/', '/payment/newpayment', $newurl); -header("Location: ".$newurl.(preg_match('/\?/', $newurl)?'&':'?').'paymentmethod=paybox'); -exit; diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php deleted file mode 100644 index a2f9f52e9e5..00000000000 --- a/htdocs/public/paybox/paymentko.php +++ /dev/null @@ -1,162 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paybox/paymentko.php - * \ingroup paybox - * \brief File to show page after a failed payment - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -// Security check -if (empty($conf->paybox->enabled)) accessforbidden('', 0, 0, 1); - -$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); - -$object = new stdClass(); // For triggers - -$paymentmethod='paybox'; - - -/* - * Actions - */ - - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayBox payment was canceled. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_paybox'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); - - -if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice -{ - // Get on url call - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; - $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; - // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; - $currencyCodeType = $_SESSION['currencyCodeType']; - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYBOX_PAYMENT_OK', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - // Send an email - $sendemail = ''; - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - - if ($sendemail) - { - $sendto=$sendemail; - $from=$conf->global->MAILING_EMAIL_FROM; - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentFailed"); - $content=""; - $content.=$langs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\npaymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); - } - } - - unset($_SESSION['ipaddress']); -} - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - -// Show message -print ''."\n"; -print '
'."\n"; - -print $langs->trans("YourPaymentHasNotBeenRecorded")."

\n"; - -$key='ONLINE_PAYMENT_MESSAGE_KO'; -if (! empty($conf->global->$key)) print $conf->global->$key; - -print "\n
\n"; - - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php deleted file mode 100644 index efa49ce84fc..00000000000 --- a/htdocs/public/paybox/paymentok.php +++ /dev/null @@ -1,194 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paybox/paymentok.php - * \ingroup paybox - * \brief File to show page after a successful payment - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -// Security check -if (empty($conf->paybox->enabled)) accessforbidden('', 0, 0, 1); - -$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); - -/*$source=GETPOST('source'); -$ref=GETPOST('ref'); -$PAYBOXTOKEN=GETPOST('TOKEN'); -if (empty($PAYBOXTOKEN)) $PAYBOXTOKEN=GETPOST('token'); -$PAYBOXPAYERID=GETPOST('PAYERID'); -if (empty($PAYBOXPAYERID)) $PAYBOXPAYERID=GETPOST('PayerID'); -*/ -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); - - -$object = new stdClass(); // For triggers - -$paymentmethod='paybox'; - - -/* - * Actions - */ - - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayBox payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_paybox'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); - - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - -// Show message -print ''."\n"; -print '
'."\n"; - -// Get on url call -/* -$onlinetoken = $PAYBOXTOKEN; -*/ -$fulltag = $FULLTAG; -/*$payerID = $PAYBOXPAYERID; -// Set by newpayment.php -$paymentType = $_SESSION['PaymentType']; -$currencyCodeType = $_SESSION['currencyCodeType']; -$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; -// From env -$ipaddress = $_SESSION['ipaddress']; - -dol_syslog("Call newpaymentok with token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); -*/ - - -print $langs->trans("YourPaymentHasBeenRecorded")."

\n"; - -$key='ONLINE_PAYMENT_MESSAGE_OK'; -if (! empty($conf->global->$key)) print $conf->global->$key; - - -// Appel des triggers -include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; -$interface=new Interfaces($db); -$result=$interface->run_triggers('PAYBOX_PAYMENT_OK', $object, $user, $langs, $conf); -if ($result < 0) { $error++; $errors=$interface->errors; } -// Fin appel triggers - -$tmptag=dolExplodeIntoArray($fulltag, '.', '='); - -// Send an email -if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) -{ - $sendto=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $content=""; - if (! empty($tmptag['MEM'])) - { - $langs->load("members"); - $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
\n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; - $content.=$langs->trans("Link").': '.$url.''."
\n"; - } - else - { - $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; - } - $content.="
\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; - $content.="tag=".$fulltag."
\n"; - - $ishtml=dol_textishtml($content); // May contain urls - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - - // Send an email - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); - } -} - - - -print "\n
\n"; - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/paypal/index.php b/htdocs/public/paypal/index.php deleted file mode 100644 index 0cba12e6aa2..00000000000 --- a/htdocs/public/paypal/index.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paypal/index.php - * \ingroup core - * \brief A redirect page to an error - * \author Laurent Destailleur - */ - -require '../../master.inc.php'; - -header("Location: ".DOL_URL_ROOT.'/public/error-404.php'); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php deleted file mode 100644 index ce6bb62500b..00000000000 --- a/htdocs/public/paypal/newpayment.php +++ /dev/null @@ -1,52 +0,0 @@ - - * Copyright (C) 2006-2017 Laurent Destailleur - * Copyright (C) 2009-2012 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * For paypal test: https://developer.paypal.com/ - * For paybox test: ??? - */ - -/** - * \file htdocs/public/paypal/newpayment.php - * \ingroup paypal - * \brief File to offer a way to make a payment for a particular Dolibarr entity - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -// Security check -if (empty($conf->paypal->enabled)) accessforbidden('', 0, 0, 1); - -$newurl = $_SERVER['REQUEST_URI']; -$newurl = preg_replace('/\/paypal\/newpayment/', '/payment/newpayment', $newurl); -header("Location: ".$newurl.(preg_match('/\?/', $newurl)?'&':'?').'paymentmethod=paypal'); -exit; diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php deleted file mode 100644 index 2a80f5e5ba4..00000000000 --- a/htdocs/public/paypal/paymentko.php +++ /dev/null @@ -1,173 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paypal/paymentko.php - * \ingroup paypal - * \brief File to show page after a failed payment. - * This page is called by paypal with url provided to payal competed with parameter TOKEN=xxx - * This token can be used to get more informations. - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -// Security check -if (empty($conf->paypal->enabled)) accessforbidden('', 0, 0, 1); - -$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); - -$PAYPALTOKEN=GETPOST('TOKEN'); -if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); -$PAYPALPAYERID=GETPOST('PAYERID'); -if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); - - -$object = new stdClass(); // For triggers - -$paymentmethod='paypal'; - - -/* - * Actions - */ - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_paypal'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); - -if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice -{ - // Get on url call - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; - $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; - // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; - $currencyCodeType = $_SESSION['currencyCodeType']; - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYPAL_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - // Send an email - $sendemail = ''; - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - - if ($sendemail) - { - $sendto=$sendemail; - $from=$conf->global->MAILING_EMAIL_FROM; - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentFailed"); - $content=""; - $content.=$langs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); - } - } - - unset($_SESSION['ipaddress']); -} - - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - -// Show ko message -print ''."\n"; -print '
'."\n"; -print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; - -$key='ONLINE_PAYMENT_MESSAGE_KO'; -if (! empty($conf->global->$key)) print $conf->global->$key; - -print "\n
\n"; - - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php deleted file mode 100644 index 6319945ce00..00000000000 --- a/htdocs/public/paypal/paymentok.php +++ /dev/null @@ -1,332 +0,0 @@ - - * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/paypal/paymentok.php - * \ingroup paypal - * \brief File to show page after a successful payment - * This page is called by paypal with url provided to payal completed with parameter TOKEN=xxx - * This token can be used to get more informations. - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -// Security check -if (empty($conf->paypal->enabled)) accessforbidden('', 0, 0, 1); - -$langs->loadLangs(array("main","other","dict","bills","companies","paybox","paypal","stripe")); - -// Clean parameters -$PAYPAL_API_USER=""; -if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; -$PAYPAL_API_PASSWORD=""; -if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; -$PAYPAL_API_SIGNATURE=""; -if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; -$PAYPAL_API_SANDBOX=""; -if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; -$PAYPAL_API_OK=""; -if ($urlok) $PAYPAL_API_OK=$urlok; -$PAYPAL_API_KO=""; -if ($urlko) $PAYPAL_API_KO=$urlko; -if (empty($PAYPAL_API_USER)) -{ - dol_print_error('', "Paypal setup param PAYPAL_API_USER not defined"); - return -1; -} -if (empty($PAYPAL_API_PASSWORD)) -{ - dol_print_error('', "Paypal setup param PAYPAL_API_PASSWORD not defined"); - return -1; -} -if (empty($PAYPAL_API_SIGNATURE)) -{ - dol_print_error('', "Paypal setup param PAYPAL_API_SIGNATURE not defined"); - return -1; -} - -$source=GETPOST('source'); -$ref=GETPOST('ref'); -$PAYPALTOKEN=GETPOST('TOKEN'); -if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); -$PAYPALPAYERID=GETPOST('PAYERID'); -if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); - - -$object = new stdClass(); // For triggers - -$paymentmethod='paypal'; - - -/* - * Actions - */ - - - -/* - * View - */ - -dol_syslog("Callback url when a PayPal payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_paypal'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); - - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - -// Show message -print ''."\n"; -print '
'."\n"; - -if ($PAYPALTOKEN) -{ - // Get on url call - $onlinetoken = $PAYPALTOKEN; - $fulltag = $FULLTAG; - $payerID = $PAYPALPAYERID; - // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; - $currencyCodeType = $_SESSION['currencyCodeType']; - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - - dol_syslog("Call paymentok with token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); - - - // Validate record - if (! empty($paymentType)) - { - dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_paypal'); - $resArray=getDetails($onlinetoken); - //var_dump($resarray); - - dol_syslog("We call DoExpressCheckoutPayment token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); - $resArray=confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag); - - $ack = strtoupper($resArray["ACK"]); - if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") - { - $object->source = $source; - $object->ref = $ref; - $object->payerID = $payerID; - $object->fulltag = $fulltag; - $object->resArray = $resArray; - - // resArray was built from a string like that - // TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None - $PAYMENTSTATUS=urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed' - $TRANSACTIONID=urldecode($resArray["TRANSACTIONID"]); - $TAXAMT=urldecode($resArray["TAXAMT"]); - $NOTE=urldecode($resArray["NOTE"]); - - print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; - print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."

\n"; - - $key='ONLINE_PAYMENT_MESSAGE_OK'; - if (! empty($conf->global->$key)) print $conf->global->$key; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYPAL_PAYMENT_OK', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - $tmptag=dolExplodeIntoArray($fulltag, '.', '='); - - // Send an email - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) - { - $sendto=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $content=""; - if (! empty($tmptag['MEM'])) - { - $langs->load("members"); - $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
\n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; - $content.=$langs->trans("Link").': '.$url.''."
\n"; - } - else - { - $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; - } - $content.="
\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - - $ishtml=dol_textishtml($content); // May contain urls - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); - } - } - } - else - { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYPAL_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - //Display a user friendly Error on the page using any of the following error information returned by PayPal - $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); - $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); - $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); - $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - - echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
\n"; - echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; - echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; - echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; - echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; - - if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; - - $tmptag=dolExplodeIntoArray($fulltag, '.', '='); - - // Send an email - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) - { - $sendto=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("ValidationOfPaymentFailed"); - $content=""; - $content.=$langs->transnoentitiesnoconv("PaymentSystemConfirmPaymentPageWasCalledButFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - - $ishtml=dol_textishtml($content); // May contain urls - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); - } - } - } - } - else - { - dol_print_error('', 'Session expired'); - } -} -else -{ - // No TOKEN parameter in URL - dol_print_error('', 'No TOKEN parameter in URL'); -} - -print "\n
\n"; - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 2f44c6390ff..7b57c315e34 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -146,7 +146,7 @@ $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; -dol_syslog("Stripe IPN was called with event->type = ".$event->type); +dol_syslog("***** Stripe IPN was called with event->type = ".$event->type); if ($event->type == 'payout.created') { @@ -404,18 +404,7 @@ elseif ($event->type == 'charge.failed') { // TODO: Redirect to paymentko.php } elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) { - - $fulltag=$event->data->object->metadata->FULLTAG; - dol_syslog("fulltag=".$fulltag); - // Save into $tmptag all metadata - $tmptag=dolExplodeIntoArray($fulltag, '.', '='); - - $stripe=new Stripe($db); - /* - $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) - $stripecu = $stripe->getStripeCustomerAccount($tmptag['CUS'], $servicestatus); // Get thirdparty cu_... - $charge=$stripe->createPaymentStripe($event->data->object->amount/100, $event->data->object->currency, $origin, $item, $event->data->object->id, $stripecu, $stripeacc, $servicestatus); - */ + // This event is deprecated. } http_response_code(200); // PHP 5.4 or greater diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php deleted file mode 100644 index 38f76865cb7..00000000000 --- a/htdocs/public/stripe/newpayment.php +++ /dev/null @@ -1,51 +0,0 @@ - - * Copyright (C) 2017 Saasprov - * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2017 Ferran Marcet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Page is called with payment parameters then called with action='dopayment', then called with action='charge' then redirect is done on urlok/jo - */ - -/** - * \file htdocs/public/stripe/newpayment.php - * \ingroup Stripe - * \brief Page to do payment with Stripe - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -// Security check -if (empty($conf->stripe->enabled)) accessforbidden('', 0, 0, 1); - -$newurl = $_SERVER['REQUEST_URI']; -$newurl = preg_replace('/\/stripe\/newpayment/', '/stripe/newpayment', $newurl); -header("Location: ".$newurl.(preg_match('/\?/', $newurl)?'&':'?').'paymentmethod=stripe'); -exit; diff --git a/htdocs/public/stripe/paymentko.php b/htdocs/public/stripe/paymentko.php deleted file mode 100644 index fa4eb5730eb..00000000000 --- a/htdocs/public/stripe/paymentko.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/stripe/paymentko.php - * \ingroup core - * \brief File to show page after a failed payment. - * This page is called by payment system with url provided to it competed with parameter FULLTAG=xxx - * More data like token are saved into session. This token can be used to get more informations. - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); - -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); - -// Security check -if (empty($conf->stripe->enabled)) accessforbidden('', 0, 0, 1); - -$object = new stdClass(); // For triggers - -$paymentmethod='stripe'; - - -/* - * Actions - */ - - - - -/* - * View - */ - -dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_stripe'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_stripe'); - -if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice -{ - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; - $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; - $currencyCodeType = $_SESSION['currencyCodeType']; - $paymentType = $_SESSION['paymentType']; - $FinalPaymentAmt = $_SESSION['FinalPaymentAmt']; - $ipaddress = $_SESSION['ipaddress']; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('STRIPE_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - // Send an email - $sendemail = ''; - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - - if ($sendemail) - { - // Get on url call - $sendto=$sendemail; - $from=$conf->global->MAILING_EMAIL_FROM; - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentFailed"); - $content=""; - $content.=$langs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_stripe'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_stripe'); - } - } - - unset($_SESSION['ipaddress']); -} - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - -// Show ko message -print ''."\n"; -print '
'."\n"; -print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; - -$key='ONLINE_PAYMENT_MESSAGE_KO'; -if (! empty($conf->global->$key)) print $conf->global->$key; - -print "\n
\n"; - - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/stripe/paymentok.php b/htdocs/public/stripe/paymentok.php deleted file mode 100644 index 76df44be576..00000000000 --- a/htdocs/public/stripe/paymentok.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/stripe/paymentok.php - * \ingroup core - * \brief File to show page after a successful payment - * This page is called by payment system with url provided to it completed with parameter FULLTAG=xxx - * More data like token are saved into session. This token can be used to get more informations. - */ - -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// For MultiCompany module. -// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - -$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); - -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); -$source=GETPOST('source'); -$ref=GETPOST('ref'); - -// Security check -if (empty($conf->stripe->enabled)) accessforbidden('', 0, 0, 1); - - -$ispaymentok = false; -// If payment is ok -$PAYMENTSTATUS=$TRANSACTIONID=$TAXAMT=$NOTE=''; -// If payment is ko -$ErrorCode=$ErrorShortMsg=$ErrorLongMsg=$ErrorSeverityCode=''; - - -$object = new stdClass(); // For triggers - -$paymentmethod='stripe'; - - -/* - * Actions - */ - - - -/* - * View - */ - -dol_syslog("Callback url when a payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_stripe'); - -$tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; -dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_stripe'); - -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; - -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; - -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); - - - -// Show message -print ''."\n"; -print '
'."\n"; - -$ispaymentok = true; // We call this page if payment is ok -if ($ispaymentok) -{ - // Get on url call - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; - $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; - // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; - $currencyCodeType = $_SESSION['currencyCodeType']; - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - $TRANSACTIONID = $_SESSION['TRANSACTIONID']; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('STRIPE_PAYMENT_OK', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers - - - print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; - print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."

\n"; - - $key='ONLINE_PAYMENT_MESSAGE_OK'; - if (! empty($conf->global->$key)) print $conf->global->$key; - - $sendemail = ''; - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; - - $tmptag=dolExplodeIntoArray($fulltag, '.', '='); - - // Send an email - if ($sendemail) - { - $sendto=$sendemail; - $from=$conf->global->MAILING_EMAIL_FROM; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli=$conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - else $appli.=" ".DOL_VERSION; - } - else $appli.=" ".DOL_VERSION; - - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $content=""; - if (! empty($tmptag['MEM'])) - { - $langs->load("members"); - $url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
\n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; - $content.=$langs->trans("Link").': '.$url.''."
\n"; - } - else - { - $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; - } - $content.="
\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - - $ishtml=dol_textishtml($content); // May contain urls - - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_stripe'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_stripe'); - } - } -} - - -print "\n
\n"; - - -htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - -$db->close(); diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index b7d17244c2a..b2434e7d826 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -138,9 +138,9 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { $object->message = GETPOST("message", "none"); $object->origin_email = $origin_email; - $object->type_code = GETPOST("type_code", 'az09'); - $object->category_code = GETPOST("category_code", 'az09'); - $object->severity_code = GETPOST("severity_code", 'az09'); + $object->type_code = GETPOST("type_code", 'aZ09'); + $object->category_code = GETPOST("category_code", 'aZ09'); + $object->severity_code = GETPOST("severity_code", 'aZ09'); if (is_array($searched_companies)) { $object->fk_soc = $searched_companies[0]->id; } diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 02565a23dd0..bb9a54a9bf0 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -87,6 +87,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + $error = 0; + if ($action == 'add_element_resource' && ! $cancel) { $res = 0; @@ -100,8 +102,68 @@ if (empty($reshook)) { $objstat = fetchObjectByElement($element_id, $element, $element_ref); $objstat->element = $element; // For externals module, we need to keep @xx - $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + + // TODO : add this check at update_linked_resource and when modifying event start or end date + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { + $eventDateStart = $objstat->datep; + $eventDateEnd = $objstat->datef; + $isFullDayEvent = intval($objstat->fulldayevent); + if (empty($eventDateEnd)) { + if ($isFullDayEvent) { + $eventDateStartArr = dol_getdate($eventDateStart); + $eventDateStart = dol_mktime(0, 0, 0, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + $eventDateEnd = dol_mktime(23, 59, 59, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + } + } + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) . "'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($objstat->element) . "'"; + $sql .= " WHERE er.resource_id = " . $resource_id; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $objstat->error = $db->lasterror(); + $objstat->errors[] = $objstat->error; + } else { + if ($db->num_rows($resql)>0) { + // already in use + $error++; + $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $objstat->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $objstat->errors[] = $objstat->error; + } + $db->free($resql); + } + } + + if (!$error) { + $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + } } + if (! $error && $res > 0) { setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); @@ -123,18 +185,73 @@ if (empty($reshook)) $object->busy = $busy; $object->mandatory = $mandatory; - $result = $object->update_element_resource($user); + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { + $eventDateStart = $object->objelement->datep; + $eventDateEnd = $object->objelement->datef; + $isFullDayEvent = intval($objstat->fulldayevent); + if (empty($eventDateEnd)) { + if ($isFullDayEvent) { + $eventDateStartArr = dol_getdate($eventDateStart); + $eventDateStart = dol_mktime(0, 0, 0, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + $eventDateEnd = dol_mktime(23, 59, 59, $eventDateStartArr['mon'], $eventDateStartArr['mday'], $eventDateStartArr['year']); + } + } - if ($result >= 0) - { + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($object->resource_type) . "'"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element_type) . "'"; + $sql .= " WHERE er.resource_id = " . $object->resource_id; + $sql .= " AND ac.id != " . $object->element_id; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql)>0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + } + $object->errors[] = $objstat->error; + } + $db->free($resql); + } + } + + if (!$error) { + $result = $object->update_element_resource($user); + if ($result < 0) $error++; + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); exit; } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f2d507059b9..6181b69866d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3935,17 +3935,17 @@ class Societe extends CommonObject while($obj=$this->db->fetch_object($resql)) { $tmpobject->id=$obj->rowid; - if ($obj->fk_statut != Facture::STATUS_DRAFT // Not a draft - && ! ($obj->fk_statut == Facture::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice + if ($obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft + && ! ($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice ) { $outstandingTotal+= $obj->total_ht; $outstandingTotalIncTax+= $obj->total_ttc; } if ($obj->paye == 0 - && $obj->fk_statut != Facture::STATUS_DRAFT // Not a draft - && $obj->fk_statut != Facture::STATUS_ABANDONED // Not abandonned - && $obj->fk_statut != Facture::STATUS_CLOSED) // Not classified as paid + && $obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft + && $obj->fk_statut != $tmpobject::STATUS_ABANDONED // Not abandonned + && $obj->fk_statut != $tmpobject::STATUS_CLOSED) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { $paiement = $tmpobject->getSommePaiement(); @@ -3956,7 +3956,11 @@ class Societe extends CommonObject } //if credit note is converted but not used - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + // TODO Do this also for customer ? + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) + { + $outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 4657a3e3f64..2010edeb217 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -288,7 +288,7 @@ if ($result) print ''; // Name - print ''; + print ''; print $thirdparty_static->getNomUrl(1); print "\n"; // Type diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 90d90b388ac..a9f0d9aed0b 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -486,7 +486,7 @@ if (empty($reshook)) $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha'); $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); } - https://dashboard.stripe.com/search?query=risk_level%3Ahighest&account=acct_1CVGWQLYhjvFj9Sz + $id = $socid; $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissioncreate=$user->rights->societe->creer; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 02039f3edc2..c3c008a5874 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -221,7 +221,7 @@ if (empty($conf->stripeconnect->enabled)) $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID); $endpoint->enabled_events = $stripearrayofwebhookevents; if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) { - if (empty(GETPOST('status', 'alpha'))) { + if (! GETPOST('status', 'alpha')) { $endpoint->disabled = true; } else { $endpoint->disabled = false; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9c0bc9ebae3..cff5f17494b 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -60,6 +60,7 @@ class Stripe extends CommonObject public $type; public $code; + public $declinecode; public $message; @@ -305,16 +306,18 @@ class Stripe extends CommonObject * @param string $currency_code Currency code * @param string $tag Tag * @param string $description Description - * @param Societe $object Object to pay with Stripe + * @param mixed $object Object to pay with Stripe * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt * @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) + * @param string $payment_method 'pm_....' (if known) + * @param string $off_session If we use an already known payment method to pay off line. * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ - public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false) + public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0) { global $conf; @@ -335,7 +338,7 @@ class Stripe extends CommonObject } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); + if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100); else $stripefee = round($fee); $paymentintent = null; @@ -411,6 +414,16 @@ class Stripe extends CommonObject // payment_method = // payment_method_types = array('card') //var_dump($dataforintent); + if ($off_session) + { + unset($dataforintent['setup_future_usage']); + $dataforintent["off_session"] = true; + } + if (! is_null($payment_method)) + { + $dataforintent["payment_method"] = $payment_method; + $description.=' - '.$payment_method; + } if ($conf->entity!=$conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) { @@ -434,7 +447,6 @@ class Stripe extends CommonObject $paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description", "stripe_account" => $key)); //$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("stripe_account" => $key)); } - //var_dump($paymentintent->id); // Store the payment intent if (is_object($object)) @@ -479,19 +491,29 @@ class Stripe extends CommonObject $_SESSION["stripe_payment_intent"] = $paymentintent; } } + catch(Stripe\Error\Card $e) + { + $error++; + $this->error = $e->getMessage(); + $this->code = $e->getStripeCode(); + $this->declinecode = $e->getDeclineCode(); + } catch(Exception $e) { /*var_dump($dataforintent); var_dump($description); var_dump($key); var_dump($paymentintent); - var_dump($e->getMessage());*/ - $error++; + var_dump($e->getMessage()); + var_dump($e);*/ + $error++; $this->error = $e->getMessage(); + $this->code = ''; + $this->declinecode = ''; } } - dol_syslog("getPaymentIntent return error=".$error, LOG_INFO, -1); + dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); if (! $error) { @@ -654,7 +676,7 @@ class Stripe extends CommonObject * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card - * @return \Stripe\StripeCard|null Stripe Card or null if not found + * @return \Stripe\StripeCard|\Stripe\PaymentMethod|null Stripe Card or null if not found */ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) { @@ -680,10 +702,24 @@ class Stripe extends CommonObject { try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $card = $cu->sources->retrieve($cardref); + if (! preg_match('/^pm_/', $cardref)) + { + $card = $cu->sources->retrieve($cardref); + } + else + { + $card = \Stripe\PaymentMethod::retrieve($cardref); + } } else { - //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided - $card = $cu->sources->retrieve($cardref); + if (! preg_match('/^pm_/', $cardref)) + { + //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided + $card = $cu->sources->retrieve($cardref); + } + else { + //$card = \Stripe\PaymentMethod::retrieve($cardref, array("stripe_account" => $stripeacc)); // Don't know if this works + $card = \Stripe\PaymentMethod::retrieve($cardref); + } } } catch(Exception $e) @@ -707,12 +743,28 @@ class Stripe extends CommonObject //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($stripeacc);exit; - dol_syslog("Try to create card dataforcard = ".json_encode($dataforcard)); + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $card = $cu->sources->create($dataforcard); + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $card = $cu->sources->create($dataforcard); + } + else + { + // TODO + dol_syslog("Error: This case is not supported", LOG_ERR); + } } else { - $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + } + else + { + // TODO + dol_syslog("Error: This case is not supported", LOG_ERR); + } } if ($card) @@ -752,13 +804,12 @@ class Stripe extends CommonObject /** * Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API - * This is using old Stripe API charge. * * @param int $amount Amount to pay * @param string $currency EUR, GPB... * @param string $origin Object type to pay (order, invoice, contract...) * @param int $item Object id to pay - * @param string $source src_xxxxx or card_xxxxx + * @param string $source src_xxxxx or card_xxxxx or pm_xxxxx * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() * @param int $status Status (0=test, 1=live) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 6811df8d589..41f802062a2 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -28,7 +28,7 @@ /** * \file htdocs/stripe/payment.php * \ingroup stripe - * \brief Payment page for customers invoices + * \brief Payment page for customers invoices. TODO Seems deprecated and bugged ! */ // Load Dolibarr environment @@ -71,6 +71,7 @@ if ($user->societe_id > 0) } $object=new Facture($db); +$stripe=new Stripe($db); // Load object if ($facid > 0) @@ -78,9 +79,9 @@ if ($facid > 0) $ret=$object->fetch($facid); } -if (! empty($conf->stripe->enabled)) +if (empty($conf->stripe->enabled)) { - access_forbidden(); + accessforbidden(); } if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) @@ -306,7 +307,7 @@ if (empty($reshook)) elseif (preg_match('/src_/i', $source)) { - $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); if ($src->type=='card') { @@ -1082,7 +1083,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (! GETPOST('action')) { - if ($page == -1) $page = 0 ; + if ($page == -1 || empty($page)) $page = 0 ; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $offset = $limit * $page ; diff --git a/htdocs/takepos/ajax.php b/htdocs/takepos/ajax.php index 74f69618a0f..1cb91f6edac 100644 --- a/htdocs/takepos/ajax.php +++ b/htdocs/takepos/ajax.php @@ -52,7 +52,7 @@ elseif ($action=="search" && $term != '') { $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product'; $sql.= ' WHERE entity IN ('.getEntity('product').')'; $sql.= ' AND tosell = 1'; - $sql.= natural_search(array('label','barcode'), $term); + $sql.= natural_search(array('ref','label','barcode'), $term); $resql = $db->query($sql); $rows = array(); while ($row = $db->fetch_array($resql)) { diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index 041f4f56bee..71ad5b61362 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -129,6 +129,14 @@ table.postablelines tr td { height: 40px !important; } +div.paymentbordline +{ + width:50%; + background-color:#666; + border-radius: 8px; + margin-bottom: 4px; +} + @media only screen and (max-aspect-ratio: 6/4) { div.description{ min-height:20%; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 672f17ca81b..f23f71552c3 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -137,6 +137,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $bankaccount=$conf->global->$accountname; } $now=dol_now(); + $res = 0; $invoice = new Facture($db); $invoice->fetch($placeid); @@ -179,41 +180,42 @@ if ($action == 'valid' && $user->rights->facture->creer) $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $invoice->validate($user, '', $conf->global->$constantforkey); + $res = $invoice->validate($user, '', $conf->global->$constantforkey); $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; } else { - $invoice->validate($user); + $res = $invoice->validate($user); } // Add the payment - $payment=new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; + if ($res > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; - // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->total_ttc; + // If user has not used change control, add total invoice payment + if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->total_ttc; - $payment->paiementid=$paiementid; - $payment->num_payment=$invoice->ref; + $payment->paiementid=$paiementid; + $payment->num_payment=$invoice->ref; - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay == 0) - { - dol_syslog("Invoice is paid, so we set it to pay"); - $result = $invoice->set_paid($user); - if ($result > 0) $invoice->paye = 1; - } - else - { - dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); - } + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to pay"); + $result = $invoice->set_paid($user); + if ($result > 0) $invoice->paye = 1; + } else { + dol_syslog("Invoice is not paid, remain to pay = " . $remaintopay); + } + } else { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } } if ($action == 'history') diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 83f4aefb5f5..aa75ed5a2c4 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -181,18 +181,18 @@ else print "var received=0;";
-
+
trans('TotalTTC');?>: total_ttc, 1, '', 1, -1, -1) ?>
total_ttc) { ?> -
+
trans('RemainToPay');?>:
-
-
trans("Received"); ?>:
+
+
trans("Received"); ?>:
-
+
trans("Change"); ?>:
@@ -225,7 +225,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -238,7 +238,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -253,7 +253,7 @@ $button = array_pop($action_buttons); if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + - + px; + margin-left: 8px; + margin-right: 8px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after, #mainmenutd_menu::after { + content: unset !important; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { border-top: none !important; border-left: none !important; @@ -1504,9 +1548,6 @@ li.tmenu, li.tmenusel { li.menuhider:hover { background-image: none !important; } -li.tmenusel, li.tmenu:hover { - /* background: rgba(0, 0, 0, 0.1); */ -} li.tmenusel::after, li.tmenu:hover::after{ content: ""; @@ -1559,7 +1600,7 @@ div.tmenucenter padding-top: 2px; height: px; - width: 100%; + /* width: 100%; */ } #menu_titre_logo { padding-top: 0; @@ -1965,8 +2006,8 @@ div.login_block_other { padding-top: 0; text-align: right; margin-right: 8px; } float: right; vertical-align: top; padding: 0px 3px 0px 4px !important; - line-height: 50px; - height: 50px; + line-height: px; + height: px; } .atoplogin, .atoplogin:hover { color: # !important; @@ -2003,8 +2044,8 @@ img.login, img.printer, img.entity { font-weight: bold; } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ - width: 32px; - height: 32px; + width: px; + height: px; border-radius: 50%; background-size: contain; background-size: contain; @@ -2618,7 +2659,7 @@ table.liste th, table.noborder th, table.noborder tr.liste_titre td, table.nobor } table.liste td, table.noborder td, div.noborder form div, table.tableforservicepart1 td, table.tableforservicepart2 td { padding: 7px 8px 7px 8px; /* t r b l */ - line-height: 22px; + /* line-height: 22px; This create trouble on cell login on list of last events of a contract*/ height: 22px; } div.liste_titre_bydiv .divsearchfield { @@ -4673,6 +4714,10 @@ div.dataTables_length select { -webkit-box-shadow: none !important; box-shadow: none !important; } +.select2-dropdown { + border: 1px solid #ccc; + box-shadow: 5px 5px 15px #ddd; +} .select2-dropdown-open { background-color: #fff; } @@ -4973,6 +5018,7 @@ dl.dropdown { list-style:none; max-height: 264px; overflow: auto; + border-radius: 2px; } .dropdown dd ul li { white-space: nowrap; @@ -5641,7 +5687,7 @@ div.tabsElem a.tab { /* nboftopmenuentries = , fontsize= */ /* rule to reduce top menu - 1st reduction: Reduce width of top menu icons */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1) ? round($nbtopmenuentries * 90, 0) + 240 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1; ?>px) /* reduction 1 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1) ? round($nbtopmenuentries * 90, 0) + 340 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC1; ?>px) /* reduction 1 */ { div.tmenucenter { width: px; /* size of viewport */ @@ -5674,8 +5720,11 @@ div.tabsElem a.tab { } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2) ? round($nbtopmenuentries * 69, 0) + 140 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC2; ?>px) /* reduction 2 */ { + li.tmenucompanylogo { + display: none; + } div.mainmenu { height: 23px; } @@ -5698,7 +5747,7 @@ div.tabsElem a.tab { } } /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ -@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 40 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ +@media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 140 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ { .side-nav { z-index: 200; diff --git a/htdocs/theme/md/main_menu_fa_icons.inc.php b/htdocs/theme/md/main_menu_fa_icons.inc.php index 681c90c75ae..4386d607050 100644 --- a/htdocs/theme/md/main_menu_fa_icons.inc.php +++ b/htdocs/theme/md/main_menu_fa_icons.inc.php @@ -9,7 +9,7 @@ font-variant: normal; text-rendering: auto; line-height: 26px; - font-size: ; + font-size: 1.5em; -webkit-font-smoothing: antialiased; text-align:center; text-decoration:none; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ebf6b1df23d..4d0fbe1d09f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1083,6 +1083,7 @@ select.selectarrowonleft option { .maxwidth75onsmartphone { max-width: 50px; } .maxwidth100onsmartphone { max-width: 70px; } .maxwidth150onsmartphone { max-width: 120px; } + .maxwidth150onsmartphoneimp { max-width: 120px !important; } .maxwidth200onsmartphone { max-width: 200px; } .maxwidth300onsmartphone { max-width: 300px; } .maxwidth400onsmartphone { max-width: 400px; } @@ -1948,6 +1949,11 @@ foreach($mainmenuusedarray as $val) display: none; } +.topmenuimage { + + display: none; + +} a.tmenuimage { display: block; } @@ -2232,6 +2238,41 @@ div.blockvmenulogo { border-bottom: 0 !important; } +.backgroundforcompanylogo { + margin: px; + margin-left: 12px; + margin-right: 6px; + background-color: rgba(255,255,255,0.7); + padding: 0; + border-radius: 5px; + height: px; + /* width: 100px; */ + max-width: 100px; + vertical-align: middle; +} +.backgroundforcompanylogo img.mycompany { + object-fit: contain; + width: inherit; + height: inherit; +} +#mainmenutd_companylogo::after { + content: unset; +} +li#mainmenutd_companylogo .tmenucenter { + width: unset; +} +li#mainmenutd_companylogo { + min-width: unset !important; +} + + li#mainmenutd_home { + min-width: unset !important; + } + li#mainmenutd_home .tmenucenter { + width: unset; + } + + div.blockvmenupair, div.blockvmenuimpair { font-family: ; @@ -5624,13 +5665,13 @@ border-top-right-radius: 6px; } .menuhider { - width: 40px; + width: px; } /* nboftopmenuentries = , fontsize= */ /* disableimages = */ /* rule to reduce top menu - 1st reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { div.tmenucenter { max-width: px; /* size of viewport */ @@ -5657,8 +5698,12 @@ border-top-right-radius: 6px; } } /* rule to reduce top menu - 2nd reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { + li.tmenucompanylogo { + display: none; + } + div.tmenucenter { max-width: px; /* size of viewport */ text-overflow: clip; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index b770e2fec40..2c52ec513ff 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -570,9 +570,9 @@ if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') & { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - $object->type_code = GETPOST('update_value_type', 'az09'); - $object->severity_code = GETPOST('update_value_severity', 'az09'); - $object->category_code = GETPOST('update_value_category', 'az09'); + $object->type_code = GETPOST('update_value_type', 'aZ09'); + $object->severity_code = GETPOST('update_value_severity', 'aZ09'); + $object->category_code = GETPOST('update_value_category', 'aZ09'); $ret = $object->update($user); if ($ret > 0) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6de4271ec83..2d36370ae54 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -54,7 +54,6 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $mode = GETPOST('mode', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$subaction = GETPOST('subaction', 'alpha'); $group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useracard'; // To manage different context of search @@ -196,14 +195,14 @@ if (empty($reshook)) { } if (!$error) { - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->api_key = GETPOST("api_key", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear')); + $object->lastname = GETPOST("lastname", 'alphanohtml'); + $object->firstname = GETPOST("firstname", 'alphanohtml'); + $object->login = GETPOST("login", 'alphanohtml'); + $object->api_key = GETPOST("api_key", 'alphanohtml'); + $object->gender = GETPOST("gender", 'aZ09'); + $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); $object->birth = $birth; - $object->admin = GETPOST("admin", 'alpha'); + $object->admin = GETPOST("admin", 'int'); $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); @@ -223,8 +222,9 @@ if (empty($reshook)) { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } - $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); - $object->job = GETPOST("job", 'alpha'); + + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); + $object->job = GETPOST("job", 'nohtml'); $object->signature = GETPOST("signature", 'none'); $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml'); $object->note = GETPOST("note", 'none'); @@ -239,10 +239,10 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : ''; $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : ''; - $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); $object->dateemployment = $dateemployment; - $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth'), GETPOST('dateemploymentendday'), GETPOST('dateemploymentendyear')); + $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $object->dateemploymentend = $dateemploymentend; $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); @@ -354,15 +354,15 @@ if (empty($reshook)) { $db->begin(); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear')); + $object->lastname = GETPOST("lastname", 'alphanohtml'); + $object->firstname = GETPOST("firstname", 'alphanohtml'); + $object->login = GETPOST("login", 'alphanohtml'); + $object->gender = GETPOST("gender", 'aZ09'); + $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); $object->birth = $birth; $object->pass = GETPOST("password", 'none'); - $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; - if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request + $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; + if (! empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); @@ -371,21 +371,21 @@ if (empty($reshook)) { $object->office_phone = GETPOST("office_phone", 'alphanohtml'); $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); + //$object->skype = GETPOST("skype", 'alphanohtml'); + //$object->twitter = GETPOST("twitter", 'alphanohtml'); + //$object->facebook = GETPOST("facebook", 'alphanohtml'); + //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } - $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); - $object->job = GETPOST("job", 'alpha'); + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); + $object->job = GETPOST("job", 'nohtml'); $object->signature = GETPOST("signature", 'none'); - $object->accountancy_code = GETPOST("accountancy_code", 'alpha'); - $object->openid = GETPOST("openid", 'alpha'); + $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml'); + $object->openid = GETPOST("openid", 'alphanohtml'); $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0; $object->employee = GETPOST('employee', 'int'); @@ -395,7 +395,7 @@ if (empty($reshook)) { $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : ''; $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : ''; - $object->color = GETPOST("color", 'alpha') != '' ? GETPOST("color", 'alpha') : ''; + $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : ''; $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); $object->dateemployment = $dateemployment; $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); @@ -1237,7 +1237,7 @@ if ($action == 'create' || $action == 'adduserldap') // Position/Job print ''.$langs->trans("PostOrFunction").''; print ''; - print ''; + print ''; print ''; // Default warehouse diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 2560ccc7f04..137ac659fd7 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -58,7 +58,8 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $socid=0; if (isset($user->societe_id) && $user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); -if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms))) // A user can always read its own card if not advanced perms enabled, or if he has advanced perms +// A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin +if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) { accessforbidden(); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5d4c259bf9c..db5ecd2ca7a 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2237,7 +2237,7 @@ if (! GETPOST('hide_websitemenu')) $formquestion = array( array('type' => 'checkbox', 'name' => 'delete_also_js', 'label' => $langs->trans("DeleteAlsoJs"), 'value' => 0), array('type' => 'checkbox', 'name' => 'delete_also_medias', 'label' => $langs->trans("DeleteAlsoMedias"), 'value' => 0), - //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), + //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); @@ -2252,7 +2252,7 @@ if (! GETPOST('hide_websitemenu')) $formquestion = array( array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite") ,'value'=> 'copy_of_'.$object->ref), //array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("SiteIsANewTranslation"), 'value' => 0), - //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), + //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); @@ -2266,7 +2266,7 @@ if (! GETPOST('hide_websitemenu')) // Confirmation to clone if ($action == 'createpagefromclone') { // Create an array for form - $preselectedlanguage = GETPOST('newlang', 'az09') ? GETPOST('newlang', 'az09') : ($objectpage->lang ? $objectpage->lang : $langs->defaultlang); + $preselectedlanguage = GETPOST('newlang', 'aZ09') ? GETPOST('newlang', 'aZ09') : ($objectpage->lang ? $objectpage->lang : $langs->defaultlang); $formquestion = array( array('type' => 'hidden', 'name' => 'sourcepageurl', 'value'=> $objectpage->pageurl), array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), @@ -3308,7 +3308,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''.$langs->trans("Container").''; print ''; - print ''.$answerrecord->title.''; + print ''.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).''; print ''; print ''.$answerrecord->description; print ''; @@ -3319,7 +3319,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''.$answerrecord['type'].''; print ''; - $backtopageurl = $_SERVER["PHP_SELF"].'?action=replacesiteconfirm&searchstring='.urlencode($searchkey).'&optioncontent='.GETPOST('optioncontent', 'az09').'&optionmeta='.GETPOST('optionmeta', 'az09').'&optionsitefiles='.GETPOST('optionsitefiles', 'az09'); + $backtopageurl = $_SERVER["PHP_SELF"].'?action=replacesiteconfirm&searchstring='.urlencode($searchkey).'&optioncontent='.GETPOST('optioncontent', 'aZ09').'&optionmeta='.GETPOST('optionmeta', 'aZ09').'&optionsitefiles='.GETPOST('optionsitefiles', 'aZ09'); print 'ref.'&backtopage='.urlencode($backtopageurl).'">'.$langs->trans("EditCss").''; print ''; print ''; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index b457c4c0fa7..68b93c6ec88 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -130,6 +130,24 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } + /** + * testSetLang + * + * @return string + */ + public function testSetLang() + { + global $conf; + $conf=$this->savconf; + + $tmplangs = new Translate('', $conf); + + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "' malicious text with quote"; + $tmplangs->setDefaultLang('auto'); + print __METHOD__.' $tmplangs->defaultlang='.$tmplangs->defaultlang."\n"; + $this->assertEquals($tmplangs->defaultlang, 'malicioustextwithquote_MALICIOUSTEXTWITHQUOTE'); + } + /** * testGETPOST *