From 1ecff0a608ee91b34406156a04e1d75c03e57644 Mon Sep 17 00:00:00 2001 From: jpb Date: Fri, 23 Oct 2020 11:14:18 +0200 Subject: [PATCH 001/247] add list and crud --- htdocs/core/class/html.form.class.php | 7 +- htdocs/core/lib/multicurrency.lib.php | 4 + htdocs/langs/en_US/multicurrency.lang | 16 + .../class/multicurrency.class.php | 6 +- htdocs/multicurrency/multicurrency_rate.php | 548 ++++++++++++++++++ 5 files changed, 578 insertions(+), 3 deletions(-) create mode 100644 htdocs/multicurrency/multicurrency_rate.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 14251ce2912..0ce9c883d5e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5023,9 +5023,11 @@ class Form * @param string $selected preselected currency code * @param string $htmlname name of HTML select list * @param integer $useempty 1=Add empty line + * @param string $filter Optional filters criteras (example: 'code <> x', ' in (1,3)') + * @param bool $excludeConfCurrency false = If company current currency not in table, we add it into list. Should always be available. true = we are in currency_rate update , we don't want to see conf->currency in select * @return string */ - public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) + public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0, $filter= '',$excludeConfCurrency = false) { global $db, $conf, $langs, $user; @@ -5035,6 +5037,7 @@ class Form $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; $sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; + if ($filter) $sql .= " AND ".$filter; $resql = $db->query($sql); if ($resql) { @@ -5045,7 +5048,7 @@ class Form $out .= ''; + + print ' ' . $langs->trans('Codemulticurrency') . ''; + print '' . $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true) . ''; + + print ' ' . $langs->trans('rate') . ''; + print ' '; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; +} + +if ($action == "updateRate"){ + $current_rate = new CurrencyRate($db); + $current_rate->fetch(intval($id_rate_selected)); + + if ($current_rate) { + $curr = new MultiCurrency($db); + $resultcurrentCurrency = $curr->fetch($current_rate->fk_multicurrency); + + if ($resultcurrentCurrency){ + $currency_code = $curr->code; + }else{ + $currency_code = ''; + } + + print ''; + print ''; + print '' . "\n"; + print '
' . $langs->trans("FormUpdateRate") . '
'; + + $form = new Form($db); + print '
'; + print ''; + print ' '; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print '
' . $langs->trans('date') . '' . $langs->trans('Codemulticurrency') . '' . $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true) . '' . $langs->trans('rate') . ''; + print ''; + print ''; + print ''; + print '' .$langs->trans('CancelUpdate') . ''; + + print '
'; + print '
'; + }else{ + dol_syslog("currency_rate:list:update", LOG_WARNING); + } +} + + +$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; + +// 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.'multicurrency_rate as cr '; +$sql .=" INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; + + +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); + +if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); +if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); +if ($search_code) $sql .= natural_search('m.code', $search_code); + +$sql.= ' WHERE m.code != \''.$conf->currency. '\''; + +// 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; +$sql.= " GROUP BY cr.rowid, cr.date_sync, cr.rate, m.code, cr.entity "; + +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= $db->order($sortfield, $sortorder); + + +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + + if ($result){ + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } + }else{ + setEventMessage($langs->trans('No_record_on_multicurrency_rate'), 'warnings'); + } +} + +$sql.= $db->plimit($limit + 1, $offset); + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $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 ($sall) $param.="&sall=".urlencode($sall); + + if ($search_date_sync) $param="&search_date_sync=".urlencode($search_date_sync); + if ($search_rate) $param="&search_rate=".urlencode($search_rate); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); + + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + + if ($user->admin) $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 ''; + print ''; + + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_currency.png', 0, $newcardbutton, '', $limit); + + 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).'
'; + } + + // Filter on categories + $moreforfilter=''; + + + $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; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $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); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + + // date + if (! empty($arrayfields['cr.date_sync']['checked'])) + { + print ''; + } + // code + if (! empty($arrayfields['m.code']['checked'])) + { + print ''; + } + // rate + if (! empty($arrayfields['cr.rate']['checked'])) + { + print ''; + } + + // 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; + + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['cr.date_sync']['checked'])) print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.code']['checked'])) print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['cr.rate']['checked'])) print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); + + // 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; + + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + + $i = 0; + $totalarray=array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + print ''; + + // date_sync + if (! empty($arrayfields['cr.date_sync']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) + { + print '\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + // 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; + + // Action + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + $i++; + } + + $db->free($resql); + + print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; + print $obj->date_sync; + print "'; + print $obj->code ." ". $obj->name; + print "'; + print $obj->rate; + 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 'rowid.'" class="like-link " style="margin-right:15px;important">' . img_picto('edit', 'edit') . ''; + print 'rowid.'" class="like-link" style="margin-right:45px;important">' . img_picto('delete', 'delete') . ''; + print ''; + } + print '
"; + print "
"; + + print '
'; +} +else +{ + dol_print_error($db); +} + + +llxFooter(); +$db->close(); From 47351c3cb310603773500ab363ed67580996baae Mon Sep 17 00:00:00 2001 From: jpb Date: Fri, 23 Oct 2020 13:55:55 +0200 Subject: [PATCH 002/247] Fix : stickler-ci --- htdocs/core/class/html.form.class.php | 2 +- htdocs/multicurrency/multicurrency_rate.php | 25 ++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 295fb3dc46b..11aefda225b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5053,7 +5053,7 @@ class Form * @param bool $excludeConfCurrency false = If company current currency not in table, we add it into list. Should always be available. true = we are in currency_rate update , we don't want to see conf->currency in select * @return string */ - public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0, $filter= '',$excludeConfCurrency = false) + public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0, $filter = '', $excludeConfCurrency = false) { global $db, $conf, $langs, $user; diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 68ff8fb3be5..64f426b93b2 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -116,7 +116,7 @@ if ($action == "create"){ dol_syslog("currencyRate:createRate", LOG_WARNING); setEventMessage($langs->trans('successRateCreate')); } - }else{ + } else { setEventMessage($langs->trans('NoEmptyRate'), "errors"); } } @@ -133,10 +133,10 @@ if ($action == 'update'){ $res = $currencyRate->update(); if ($res){ setEventMessage($langs->trans('successUpdateRate')); - }else{ + }else { setEventMessage($langs->trans('errorUpdateRate'), "errors"); } - }else{ + }else { setEventMessage($langs->trans(''), "warnings"); } } @@ -158,10 +158,10 @@ if ($action == "deleteRate"){ 0, 1 ); - }else{ + }else { dol_syslog("Multicurrency::fetch", LOG_WARNING); } - }else{ + }else { setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings"); } } @@ -173,10 +173,10 @@ if ($action == "confirm_delete"){ $result = $current_rate->delete(); if ($result){ setEventMessage($langs->trans('successRateDelete')); - }else{ + }else { setEventMessage($langs->trans('errorRateDelete')); } - }else{ + }else { setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings"); dol_syslog($langs->trans('NoCurrencyRateSelected'), LOG_WARNING); } @@ -270,7 +270,7 @@ if ($action == "updateRate"){ if ($resultcurrentCurrency){ $currency_code = $curr->code; - }else{ + }else { $currency_code = ''; } @@ -300,7 +300,7 @@ if ($action == "updateRate"){ print ''; print ''; print ''; - }else{ + }else { dol_syslog("currency_rate:list:update", LOG_WARNING); } } @@ -350,7 +350,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $page = 0; $offset = 0; } - }else{ + }else { setEventMessage($langs->trans('No_record_on_multicurrency_rate'), 'warnings'); } } @@ -396,7 +396,7 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; } @@ -538,8 +538,7 @@ if ($resql) print ''; } -else -{ +else { dol_print_error($db); } From 1b82b6af4d35b528d2ab6fa2f4d43884b5162120 Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Sun, 25 Oct 2020 22:16:42 -0600 Subject: [PATCH 003/247] FIX #15111 Fix special characters output in PDF --- htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 51fd70c9fa1..02ed2369acd 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -660,11 +660,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3; $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); - $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L'); + $pdf->MultiCell($larg_sign, 2, $outputlangs->transnoentities("For") . ' ' . $outputlangs->convToOutputCharset($mysoc->name) . ":", '', 'L'); $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2); - $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L'); + $pdf->MultiCell($larg_sign, 2, $outputlangs->transnoentities("ForCustomer") . ':', '', 'L'); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From 5694a19c6a315aa1373b8a61d257e93744d8ec79 Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 26 Oct 2020 14:51:13 +0100 Subject: [PATCH 004/247] FIX table making extrafield input too small advtargetmailing --- htdocs/core/tpl/advtarget.tpl.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index b6c9033cad4..893832b32ac 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -75,7 +75,7 @@ print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index bf1a514df90..5dd541b34b5 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -103,7 +103,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index ff3953822f4..35dd1002b12 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -802,7 +802,7 @@ print ''; print "\n"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index e4f87bbd4be..7ef9e216ad9 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -140,7 +140,7 @@ _updateBtn(); print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 87319d7b5dd..44b7034064b 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -282,7 +282,7 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - dol_fiche_end(); + print dol_get_fiche_end(); // End of page llxFooter(); $db->close(); @@ -501,7 +501,7 @@ print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 4c7ef209e21..1205b592e5f 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Holidays"), -1, 'ho require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index 598bab92c10..e70d8eadbba 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -93,7 +93,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 8bab5c4e968..b8c207644c6 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -251,7 +251,7 @@ print ''.$langs->trans('Password').' (ex: secret)'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 8923bb26d20..b29fa00e49e 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -246,7 +246,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 9a3aa4c706a..9de9c195f8f 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -180,7 +180,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 3bcd6c27dbc..214a4f2cb9b 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -366,7 +366,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 3641947d6d1..489e6047f9b 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -162,7 +162,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index a46c98645e1..efb34cca413 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -336,7 +336,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 89d0c58e4df..82e28f3cf73 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -201,7 +201,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY { if (!empty($aCurrencies) && count($aCurrencies) > 1) { - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 977d27c0866..58e904f02ce 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -198,7 +198,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -212,7 +212,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) $link .= ''; print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index c3792812210..cc81c78255d 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -506,7 +506,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -737,7 +737,7 @@ if ($action == 'edit') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); // Actions button @@ -892,7 +892,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); // References print ''.$langs->trans("EMailsWillHaveMessageID").': '; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index ebc3201dcdf..a464c0fca8e 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -384,7 +384,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -475,7 +475,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) @@ -599,7 +599,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 6f80706276e..4556ec80bff 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -645,7 +645,7 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n print $formfile->showdocuments('massfilesarea_emailsenderprofile', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 4dfdc413af5..8cbd9675160 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -953,7 +953,7 @@ print '
'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 0be41dce273..e0a42ee3a2d 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -361,7 +361,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -441,7 +441,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) @@ -565,7 +565,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index a62385bf2ca..9bdc497c776 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -206,7 +206,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index f56bf284fc9..70d2f4bcda6 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -398,7 +398,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -507,7 +507,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); // Bouton print '
'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 065146489a7..9aec5ef0c29 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -554,7 +554,7 @@ if ($mode == 'changelog') print $text; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index db4a2d85d8e..e281cb21155 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -883,7 +883,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -916,7 +916,7 @@ if ($mode == 'marketplace') print "\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -1136,7 +1136,7 @@ if ($mode == 'deploy') } } - dol_fiche_end(); + print dol_get_fiche_end(); } if ($mode == 'develop') @@ -1170,7 +1170,7 @@ if ($mode == 'develop') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index 4078043c001..e81c7f1cf75 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index cfd93b195b3..af352558a71 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -141,7 +141,7 @@ foreach ($list as $key) print ''."\n"; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index f0fdeb28760..99510f4b7c8 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -402,7 +402,7 @@ if ($mode == 'userconf' && $user->admin) print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 8435e801902..81d0312ab69 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -77,7 +77,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'orde require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 3d228baeb57..734d617f564 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Orders"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 35e738754bf..8edf851f49e 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -262,7 +262,7 @@ print "\n"; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 718e64e6446..6a419d39e53 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -361,7 +361,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 41b0cc75ab1..3677daa38a5 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -260,7 +260,7 @@ if ($result) print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 50d01924364..c16b5c30c47 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -368,7 +368,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index a9205cb9e5f..71bd50ef5ce 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -197,7 +197,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 0e3008c57cd..3f66d04ca01 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -354,7 +354,7 @@ if ($mode == 'config' && $user->admin) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -460,7 +460,7 @@ if ($mode == 'template' && $user->admin) { } print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 27f33be8157..605b8cf465e 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -83,7 +83,7 @@ print dol_get_fiche_head($head, 'attributes_reception', $langs->trans("Reception require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index 286e6d15565..ecf72df9b37 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -142,7 +142,7 @@ print ''; //RESOURCE_HIDE_ADD_CONTACT_USER //RESOURCE_HIDE_ADD_CONTACT_THIPARTY -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index d0e2a3e5b0a..d7287b53019 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -77,7 +77,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index fba88d768c4..fc2c4e141d5 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -177,7 +177,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index ff0ca0006af..2e4f1f05229 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -184,7 +184,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index 3d959b04b83..faf8897126f 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -108,7 +108,7 @@ foreach ($arrayofsocialnetworks as $snkey => $snlabel) { } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index 772d4e32707..fe98d4bfe9e 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -146,7 +146,7 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) form_constantes($constantes, 2); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -160,7 +160,7 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) $link .= ''; print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index bda90d0ac74..c0c04eb9430 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -454,7 +454,7 @@ print "\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 10de9a09735..d84779c7477 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 576e3f7b3b3..ac40ef66e09 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -80,7 +80,7 @@ print dol_get_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers") require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index a35820806fb..c46eebfb037 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 8043c56bcd2..7017bebf61f 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -79,7 +79,7 @@ print dol_get_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 03b590a318c..e8da4a8d736 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -186,7 +186,7 @@ print dol_get_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1 print ''.$langs->trans("TicketSetupDictionaries").' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index ad88e5adbf8..4a50beaa32e 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -75,7 +75,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 8de245ab8db..50ff514c6a7 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -175,7 +175,7 @@ print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; -dol_fiche_end(); +print dol_get_fiche_end(); $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index e6f667a169b..edd5ca95026 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -547,7 +547,7 @@ if ($mode == 'searchkey') print '
'; } -dol_fiche_end(); +print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index b6fc6f43ae9..a22e585f972 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -328,7 +328,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index e9cdcaf09b6..e73e01ccbdf 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -260,7 +260,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 01ef915d137..208caf85666 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -621,7 +621,7 @@ if ($id) } } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index 479bbdbe7b9..738fd5bc998 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -140,7 +140,7 @@ if ($action == 'edit') } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 393f028f950..3334610b927 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -70,7 +70,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'gene require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index 2b67be78e2b..25d7df8e1a7 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -69,7 +69,7 @@ print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 6cda5f6eaa7..6fec16ef0a0 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -105,7 +105,7 @@ if ($action == 'edit') print '
'; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 8b087297b79..0fa78edf9ce 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -180,7 +180,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -218,7 +218,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -297,7 +297,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 021f54a1ad2..4c2e36aed9a 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -135,7 +135,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'asset'; //$permission = $user->rights->asset->create; diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 0cca7015573..d211cf0dbad 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -82,7 +82,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index b1665d7fcc4..514e05bff72 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -146,7 +146,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 3c6773f5992..28f2ce59df0 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -382,7 +382,7 @@ if ($action == 'create') print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -490,7 +490,7 @@ if ($rowid > 0) print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons @@ -595,7 +595,7 @@ if ($rowid > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 674c5b771d0..b6ce9cda1bc 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -170,7 +170,7 @@ print ''; if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '

'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index b4e26337c50..0a77c6ddf3b 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -582,7 +582,7 @@ if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->glob if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '

'; diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index d5e929796e5..317fd6f9032 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -185,7 +185,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 37db34f283c..7970911d84d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -275,7 +275,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -311,7 +311,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -535,7 +535,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 0f2a88366aa..f6a34a9c25d 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -130,7 +130,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bom'; $permission = $user->rights->bom->write; diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index e69be248a1d..78b38732f7f 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -144,7 +144,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1506dd70269..30ccc6cdd75 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -177,7 +177,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -295,7 +295,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 404d35d6065..9bc1dd685ff 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -72,7 +72,7 @@ print dol_get_fiche_head($head, 'attributes_categories', $langs->trans("Categori require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 8949ba25ef4..4c17c56c9d0 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -270,7 +270,7 @@ if ($user->rights->categorie->creer) print ''; - dol_fiche_end(''); + print dol_get_fiche_end(''); print '
'; print ''; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 9f7aebf7fec..a06517c8cda 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -170,7 +170,7 @@ if (empty($reshook)) { print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
 
'; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 0011b4c1f5f..5bd8f6c9d24 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -95,7 +95,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 0c7c35da1fe..73c7664f6c2 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -161,7 +161,7 @@ if ($object->id) print "\n"; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index c690cfcab84..660dbf9317d 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -223,7 +223,7 @@ print ''; print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 1985e756d45..280b278657c 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -267,7 +267,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7e9e63895aa..a46e302bd4b 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1291,7 +1291,7 @@ if ($action == 'create') print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1782,7 +1782,7 @@ if ($id > 0) print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2095,7 +2095,7 @@ if ($id > 0) print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 0c3ff22801a..613ac76380e 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -254,7 +254,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'actions'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 65123586e89..e62f411d786 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -417,7 +417,7 @@ print ''; //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -//dol_fiche_end(); +//print dol_get_fiche_end(); $viewmode = ''; $viewmode .= ''; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 813e3240b7a..292c0ea94ce 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -112,7 +112,7 @@ print '
'; dol_print_object_info($object); print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ed96a3a2d4f..582f1c538f0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -454,7 +454,7 @@ if ($resql) //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - //dol_fiche_end(); + //print dol_get_fiche_end(); // Add link to show birthdays $link = ''; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index f926afb56a9..79836087775 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -72,7 +72,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Proposals"), -1, 'p require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index aa6dac82910..fa12fe9b555 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -79,7 +79,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 63a6a24aeaa..df7e96fc742 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1256,7 +1256,7 @@ if ($object->id > 0) print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 812dea03f43..bb74fb686aa 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -741,7 +741,7 @@ if ($action == 'create') $doleditor->Create(); print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -923,7 +923,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Clone confirmation @@ -1064,7 +1064,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print dol_set_focus('#sendto'); } @@ -1122,7 +1122,7 @@ if ($action == 'create') } else print dol_htmlentitiesbr($object->body); print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { /* * Edition mode mailing (CKeditor or HTML source) @@ -1195,7 +1195,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); @@ -1289,7 +1289,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 2b59550cf2b..7c219cc448a 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -305,7 +305,7 @@ if ($object->fetch($id) >= 0) print "
"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 05ae0885ba8..199a5caad8b 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -81,7 +81,7 @@ if ($object->fetch($id) >= 0) //print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 6bd1fe715e3..bd4c16f89ca 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -105,7 +105,7 @@ if ($_socid > 0) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1f813b6c6ad..7190168b513 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1771,7 +1771,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); $langs->load("bills"); print '
'; @@ -2382,7 +2382,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 7d1cd05c706..9c491c7227c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -188,7 +188,7 @@ if ($object->id > 0) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Contacts lines (modules that overwrite templates must declare this into descriptor) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index f1eef2164a0..309c2a44ad4 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -172,7 +172,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'propal'; $permission = $user->rights->propal->creer; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index fd9595f3579..e56a5129c5c 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -126,7 +126,7 @@ dol_print_object_info($object); print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 1435d7f7f30..80b991a2526 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -140,7 +140,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } } } diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index fe847f6ff64..e439056de5f 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -355,7 +355,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 753e22a5ce8..21f06e7bc1d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -121,7 +121,7 @@ if ($socid > 0) if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -189,7 +189,7 @@ if ($socid > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 1ee05562bf7..922e384af4d 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -261,7 +261,7 @@ if ($socid > 0) if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -336,7 +336,7 @@ if ($socid > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($user->rights->societe->creer) @@ -375,7 +375,7 @@ if ($socid > 0) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); } if ($user->rights->societe->creer) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 795a120cee6..eb93a125fb5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1828,7 +1828,7 @@ if ($action == 'create' && $usercancreate) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); // Button "Create Draft" print '
'; @@ -2474,7 +2474,7 @@ if ($action == 'create' && $usercancreate) print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons for actions diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 51b94d82d23..84c4eb5626a 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -188,7 +188,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 20f49195e10..c3afff9e00d 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -175,7 +175,7 @@ if ($id > 0 || !empty($ref)) print "
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'commande'; $permission = $user->rights->commande->creer; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 9001a3ffb51..dd31e547569 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -127,7 +127,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 9542e432d7e..c996aea7601 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 13657c61553..1da32f13e80 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -388,7 +388,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 221299fe8b7..ac31d091833 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -567,7 +567,7 @@ print ' 0 || !empty($ref)) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bank'; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 6db4714db3d..f190ddb1471 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -166,7 +166,7 @@ if (!empty($id)) print $langs->trans("AllAccounts"); } -dol_fiche_end(); +print dol_get_fiche_end(); // Affiche tableau diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index e4bed6376f1..5d0df32cd3e 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -436,7 +436,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 7bddd7915cb..8b086516351 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -544,7 +544,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -752,7 +752,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Barre d'actions @@ -1028,7 +1028,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 1369a629d2f..896b91545db 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -123,7 +123,7 @@ if ($id > 0 || !empty($ref)) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bank'; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 496988ba74a..9350e211284 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -762,7 +762,7 @@ if ($account) print $langs->trans("AllAccounts"); } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index eab2c1ad182..7ae7c995935 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -566,7 +566,7 @@ if ($result) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '

'; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 137712d5cec..166d69fdd30 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -251,7 +251,7 @@ if (empty($numref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f59723436d2..03844897a15 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -96,7 +96,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 7218a191d1c..8a7f5415339 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -454,7 +454,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -603,7 +603,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 32351e5fe3b..14187bf51e3 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -143,7 +143,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'banque'; $permission = $user->rights->banque->modifier; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 4b61b446045..96299886070 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -660,7 +660,7 @@ if (empty($action) || $action == "view" || $action == "close") print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action != 'close') { print '
'; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index b17c3f4f9a4..e9a2a3a93a7 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -306,7 +306,7 @@ print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 16327c8b348..54234b4a10c 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'in require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 50a7fd18586..3f85d7ba074 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 2b9e37e43c6..5b1daff5913 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 58fd39e33fe..539fb89e675 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 4a9a0a197b3..0d483665e40 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1056,7 +1056,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Autogeneration @@ -1102,7 +1102,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); $title = $langs->trans("ProductsAndServices"); @@ -1641,7 +1641,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /** diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 401a2fdd37a..74947b7c591 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3618,7 +3618,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Button "Create Draft" print '
'; @@ -5030,7 +5030,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Actions buttons diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index f50f6b85a55..fc66715dd3d 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -185,7 +185,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 548fefab0fa..e001b203296 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -174,7 +174,7 @@ if ($id > 0 || !empty($ref)) print "
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'facture'; $permission = $user->rights->facture->creer; diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index a7af3893883..f26f4ea0255 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -120,7 +120,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 76c6833c07b..a2343171d66 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 2f44b0b2437..eea3b29aa36 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -573,7 +573,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $numopen = 0; $pending = 0; $numclosed = 0; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index afbe4528b14..fb1002d45a5 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -381,7 +381,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index b787878f31d..b99e4c35d1c 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -198,7 +198,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -271,7 +271,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 21e9fba85bc..d1da6de0c3e 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -528,7 +528,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 9d0758b48bf..db942328d13 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -299,7 +299,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 21b7ac83f58..49a8cf5d61b 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -370,7 +370,7 @@ if ($action == 'new') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -719,7 +719,7 @@ if ($action == 'new') dol_print_error($db); } - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index a1640f08496..208d74a316f 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -74,7 +74,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 17970037b4a..e5941624910 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -252,7 +252,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Other unpaid charges diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 6dfa4e3be7a..5ee71863dd2 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -158,7 +158,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 69968503a5d..5d87303236a 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -250,7 +250,7 @@ if ($id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $formconfirm = ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index b1a15a766f6..1f8ecdaeced 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -150,7 +150,7 @@ if ($id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 9135616d915..fb1a9451aed 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -144,7 +144,7 @@ if ($prev_id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 151e53e4a59..81e854ef5a0 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -143,7 +143,7 @@ if ($prev_id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 71f39f6c98d..ccb60486c76 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -179,7 +179,7 @@ if ($id) } print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 8e8521e4026..3930d711a1c 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -97,7 +97,7 @@ if ($id > 0) print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 98131687cb1..8af8c54752b 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -376,7 +376,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -681,7 +681,7 @@ if ($id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index dd07afd416f..eea97c13a1d 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -156,7 +156,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'tax'; $permission = $user->rights->tax->charges->creer; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 1f20bcd28e3..7e7f236b3ab 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -293,7 +293,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -369,7 +369,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Action buttons diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 8d097e6aad5..10efd84288c 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -142,7 +142,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $permission = $user->rights->tax->charges->creer; $permtoedit = $user->rights->fournisseur->facture->creer; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 71ff7b14844..ddabf6e2b49 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -89,7 +89,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 1d42d638bc8..95ec50be24f 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -227,7 +227,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); // Actions buttons diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 746d2222c39..b4406207977 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -873,7 +873,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1237,7 +1237,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1482,7 +1482,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Barre d'actions print '
'; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index f2eb1e4cfaf..d3992296aec 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -158,7 +158,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index d2979081189..8a70ec6e2df 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -162,7 +162,7 @@ if ($object->id) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'contact'; $permission = $user->rights->societe->contact->creer; diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index fbe56cb9587..c39c20d3d25 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -77,7 +77,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 2a24d7ab518..68d810967ad 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -130,7 +130,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 2e2eefb2995..478288046e1 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -114,7 +114,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 8df4dca28d4..bbaf013efa1 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -204,7 +204,7 @@ if ($action == 'edit') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -296,7 +296,7 @@ if ($action == 'edit') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index b221aa55398..8571856362a 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Contracts"), -1, 'c require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index fba9843eea0..4b3f03ffedf 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Contracts"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 48238496721..f88b470215c 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -204,7 +204,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 64b3275379a..1187571d2d0 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1197,7 +1197,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2015,7 +2015,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 32c3dd67ada..4f69d5a2c56 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -230,7 +230,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index fb7291c5d6b..759c2080930 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -186,7 +186,7 @@ if ($object->id) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'contract'; $permission = $user->rights->contrat->creer; diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index d2f7a7e71fa..0368340bffd 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -176,7 +176,7 @@ if ($id > 0 || !empty($ref)) include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index d83aa3cc19a..8b1618c8da9 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -422,7 +422,7 @@ class FormTicket print ''; - if ($withdolfichehead) dol_fiche_end(); + if ($withdolfichehead) print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 859f6e5cac1..433ec4969ca 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -758,7 +758,7 @@ if ($sql) { print '
'; if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index f380152abdb..20ffa3f52b6 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -235,7 +235,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a3eb00a38ec..7cdf83f9961 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1258,7 +1258,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di * @param array $links Array of tabs. Currently initialized by calling a function xxx_admin_prepare_head * @param string $active Active tab name (document', 'info', 'ldap', ....) * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title @@ -1279,7 +1279,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 * @param array $links Array of tabs * @param string $active Active tab name * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 385c22146b9..b23acd76a5b 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -115,7 +115,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 69bf77262c8..4bc2bbe8d7a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -211,7 +211,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con - +
">      ">
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 396406932e7..19b5322ace5 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -298,7 +298,7 @@ if (in_array($type, array_keys($typewecanchangeinto))) - +
">      ">
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index ea72f29607b..ef288f97589 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -292,5 +292,5 @@ if ($action == 'presend') // Show form print $formmail->get_form(); - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index d81a79d7b80..68f45284582 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -160,7 +160,7 @@ if ($massaction == 'presend') print $formmail->get_form(); } - dol_fiche_end(); + print dol_get_fiche_end(); } // Allow Pre-Mass-Action hook (eg for confirmation dialog) $parameters = array( diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index 5f87e640bce..8c2d42adfaa 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -105,7 +105,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index bdb776a7100..dbe159f32d3 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -510,7 +510,7 @@ if (($action == "create") || ($action == "edit")) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -693,7 +693,7 @@ if (($action == "create") || ($action == "edit")) print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print "\n\n
\n"; diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php index f8c38bf5b6b..2d89bb09e3a 100644 --- a/htdocs/datapolicy/admin/setup.php +++ b/htdocs/datapolicy/admin/setup.php @@ -164,7 +164,7 @@ if ($action == 'edit') // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/datapolicy/admin/setupmail.php b/htdocs/datapolicy/admin/setupmail.php index 241dd9dace5..7076608898e 100644 --- a/htdocs/datapolicy/admin/setupmail.php +++ b/htdocs/datapolicy/admin/setupmail.php @@ -153,7 +153,7 @@ print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '

'; diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 440de00499e..e3c28a86dac 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -629,7 +629,7 @@ if ($action == 'create') // Create. Seems to no be used print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); //if ($object->statut == 0) // only if draft // print '
'; diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index d210f4399bc..6062d4fca26 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -70,7 +70,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Donations"), -1, 'p require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 48af083a5fb..51252e480da 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -452,7 +452,7 @@ if ($action == 'create') print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -583,7 +583,7 @@ if (!empty($id) && $action == 'edit') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
   
'; @@ -775,7 +775,7 @@ if (!empty($id) && $action != 'edit') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $remaintopay = $object->amount - $totalpaid; diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 4b7a7f052dc..4067c9a0500 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -179,7 +179,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'don'; $permission = $user->rights->don->lire; diff --git a/htdocs/don/info.php b/htdocs/don/info.php index ead0f354646..f60b8380939 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -120,7 +120,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index ff25b704dd3..1e5e2667b31 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 15146932055..fa97965ca4d 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -203,7 +203,7 @@ if ($resql) print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index d8f373cbd37..e7985ded1ff 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -231,7 +231,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * List of payments on donation diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 998de2b7793..eed3108c3db 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -296,7 +296,7 @@ print ''; print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index d63ef0397fe..53f02cede7a 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -251,7 +251,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 9a084da6cc9..8c1c0162692 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -448,7 +448,7 @@ if ($action == 'edit') print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index 69cac4d1449..145e28c5e59 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -388,7 +388,7 @@ print '
'; print ajax_autoselect('downloadinternallink'); print ajax_autoselect('downloadlink'); -dol_fiche_end(); +print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index eb65d9a997b..f1716c5020e 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -335,7 +335,7 @@ $module = 'ecm'; include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; // End of page -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index f3708fbe6df..4ee3c1fcc82 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -466,7 +466,7 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_ } -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d89d08bc1b2..77e25704a6b 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1030,7 +1030,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Shipment lines @@ -2403,7 +2403,7 @@ if ($action == 'create') } - dol_fiche_end(); + print dol_get_fiche_end(); $object->fetchObjectLinked($object->id, $object->element); diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index d2adaadf484..536f0a239ef 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -250,7 +250,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Lines of contacts echo '
'; diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index ede667279e6..fffad537b6e 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -169,7 +169,7 @@ if ($id > 0 || !empty($ref)) { print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'expedition'; $permission = $user->rights->expedition->creer; diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 64aa415c4ce..71de26fa3cf 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index d500a97ab71..8fa04c27c25 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -305,7 +305,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c0896151284..63b2977336c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1483,7 +1483,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1616,7 +1616,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2543,7 +2543,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // end edit or not edit } // end of if result else { diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 531140e1b2a..c61c55a04fd 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -142,7 +142,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'expensereport'; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 00510e4e5fd..53d1531f4b9 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -98,7 +98,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 0186bd08103..574a0382fcb 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -345,7 +345,7 @@ if ($resql) dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - dol_fiche_end(); + print dol_get_fiche_end(); if ($action != 'edit') { diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index 31667d74a4e..ebb66ce42fd 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -108,7 +108,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 4a5099cc03a..6662b1054f4 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -152,7 +152,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index 281e760684d..a654c77b6cd 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -75,7 +75,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 68c43a99ad1..a01eb50981d 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -239,7 +239,7 @@ if ($action == 'create' || empty($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print dol_get_fiche_head(); @@ -279,7 +279,7 @@ if ($action == 'create' || empty($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b789fc57345..de6c0b961d6 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -301,7 +301,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 412167c55f2..64d94eda3b9 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -516,7 +516,7 @@ if ($step == 2 && $datatoexport) print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 84dfeb7cfd3..0fa5a930f05 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Interventions"), -1 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index 5a13bdb4b32..4593de914e3 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 0a4bbfe922f..31f65be4263 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -417,7 +417,7 @@ if ($action == 'create') { print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '     '; @@ -438,7 +438,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 720e6fe71f3..da1de06cc16 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1012,7 +1012,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1053,7 +1053,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1588,7 +1588,7 @@ if ($action == 'create') print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 8dd498d5242..3f0b965b094 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -169,7 +169,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index e28345534d7..8da827132a2 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -163,7 +163,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'ficheinter'; $permission = $user->rights->ficheinter->creer; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 320a29f4171..a53c69b77bd 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -124,7 +124,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index fd18040d037..b634d7092bf 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 45d4c2c2c7d..0e4872637b8 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -320,7 +320,7 @@ print ''; print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index e6a1a6a5a8c..563f46329f5 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -767,7 +767,7 @@ if ($object->id > 0) print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 524d67e55b9..46b3d372dfd 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1765,7 +1765,7 @@ if ($action == 'create') // Bouton "Create Draft" print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2339,7 +2339,7 @@ if ($action == 'create') print '
'; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /** * Boutons actions diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 45178a656ba..3dc9a68d814 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -182,7 +182,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 6f6678b57de..8b735f6b6d8 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1080,7 +1080,7 @@ if ($id > 0 || !empty($ref)) { print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); // traitement entrepot par défaut print ''."\n"; - } + if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; + print '});'; + print ''."\n"; + } // Confirm create third party @@ -778,16 +778,16 @@ if ($rowid > 0) { if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { $tmpcompany = new Societe($db); $tmpcompany->name = $companyname; - $tmpcompany->get_codeclient($tmpcompany, 0); + $tmpcompany->get_codeclient($tmpcompany, 0); $customercode = $tmpcompany->code_client; $formquestion[] = array( - 'label' => $langs->trans("CustomerCode"), - 'type' => 'text', - 'name' => 'customercode', - 'value' => $customercode, - 'morecss' => 'minwidth300', - 'moreattr' => 'maxlength="128"', - ); + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); } // @todo Add other extrafields mandatory for thirdparty creation @@ -795,99 +795,99 @@ if ($rowid > 0) { } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print dol_get_fiche_head(''); print "\n"; - print ''; + print ''; $today = dol_now(); - $datefrom = 0; - $dateto = 0; - $paymentdate = -1; + $datefrom = 0; + $dateto = 0; + $paymentdate = -1; - // Date payment - if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { - $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); - } + // Date payment + if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { + $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); + } - print ''; - // Date start subscription - print '"; + print ''; + // Date start subscription + print '"; - // Date end subscription - if (GETPOST('endday')) { - $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - } - if (!$dateto) { - $dateto = -1; // By default, no date is suggested - } - print '"; + // Date end subscription + if (GETPOST('endday')) { + $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + if (!$dateto) { + $dateto = -1; // By default, no date is suggested + } + print '"; - if ($adht->subscription) { - // Amount - print ''; + if ($adht->subscription) { + // Amount + print ''; - // Label - print ''; - print ''; + // Label + print ''; + print ''; - // Complementary action - if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { - $company = new Societe($db); - if ($object->fk_soc) { - $result = $company->fetch($object->fk_soc); - } + // Complementary action + if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { + $company = new Societe($db); + if ($object->fk_soc) { + $result = $company->fetch($object->fk_soc); + } - // Title payments - //print ''; + // Title payments + //print ''; - // No more action - print ''; - print ''; + print ''; + print ''; } } @@ -189,7 +189,7 @@ if ($result || empty($id)) { print ''."\n"; + $langs->load("members"); + $reg = array(); + if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
\n"; + else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; + $text = ''."\n"; } if (empty($text)) { - $text .= ''."\n"; - $text .= ''."\n"; + $text .= ''."\n"; + $text .= ''."\n"; } print $text; @@ -237,9 +237,9 @@ if ($source == 'proposal') // Creditor print ''."\n"; + print ''."\n"; // Debitor @@ -266,13 +266,13 @@ print '
'.$langs->trans("DateSubscription").''; - if (GETPOST('reday')) { - $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - } - if (!$datefrom) { - $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); - } - } - print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); - print "
'.$langs->trans("DateSubscription").''; + if (GETPOST('reday')) { + $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } + if (!$datefrom) { + $datefrom = $object->datevalid; + if ($object->datefin > 0) { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } + } + print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); + print "
'.$langs->trans("DateEndSubscription").''; - print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); - print "
'.$langs->trans("DateEndSubscription").''; + print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); + print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); - print ''; - print ' '.$langs->trans("None").'
'; - // Add entry into bank accoun - if (!empty($conf->banque->enabled)) { - print ' '.$langs->trans("MoreActionBankDirect").'
'; - } - // Add invoice with no payments - if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionInvoiceOnly"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + // No more action + print '
'.$langs->trans('MoreActions'); + print ''; + print ' '.$langs->trans("None").'
'; + // Add entry into bank accoun + if (!empty($conf->banque->enabled)) { + print ' '.$langs->trans("MoreActionBankDirect").'
'; + } + // Add invoice with no payments + if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionInvoiceOnly"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); @@ -896,23 +896,23 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - // Add invoice with payments - if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + print '
'; + } + // Add invoice with payments + if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionBankViaInvoice"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 2eb2c0edad1..2705ede5540 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -88,9 +88,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity); } - $db->begin(); + $db->begin(); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); @@ -141,8 +141,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) // Create thumbs of logo (Note that PDF use original file and not thumbs) if ($isimage > 0) { - // Create thumbs - //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... + // Create thumbs + //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb, Used on logon for example $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -269,7 +269,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb $reg = array(); - // Create thumbs + // Create thumbs //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb. Used on logon for example @@ -777,8 +777,8 @@ if ($mysoc->useLocalTax(2)) $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : ""); if (!isOnlyOneLocalTax(2)) { - print '
: '; - $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); + print '
: '; + $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); } print '
: '; print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 987d7a256af..43ce69f6e02 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -881,7 +881,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if (in_array($rowidcol, array('code', 'code_iso'))) { $sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } else { - $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); } if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'"; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 036f31a99d7..05782b8ec67 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -113,17 +113,17 @@ class Asset extends CommonObject */ public $entity; - /** - * @var string Asset label - */ - public $label; + /** + * @var string Asset label + */ + public $label; public $amount; /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; /** * @var string description @@ -134,21 +134,21 @@ class Asset extends CommonObject public $note_private; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; public $import_key; @@ -381,7 +381,7 @@ class Asset extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -391,14 +391,14 @@ class Asset extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); - $labelStatus = array(); + $labelStatus = array(); $labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $labelStatusShort = array(); + $labelStatusShort = array(); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8aeaa2a9fe8..5771ead70f1 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -97,7 +97,7 @@ class FactureRec extends CommonInvoice */ public $frequency; - /** + /** * @var string Unit frequency */ public $unit_frequency; @@ -317,46 +317,46 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( - $facsrc->lines[$i]->desc, - $facsrc->lines[$i]->subprice, - $facsrc->lines[$i]->qty, + $result_insert = $this->addline( + $facsrc->lines[$i]->desc, + $facsrc->lines[$i]->subprice, + $facsrc->lines[$i]->qty, $tva_tx, - $facsrc->lines[$i]->localtax1_tx, - $facsrc->lines[$i]->localtax2_tx, - $facsrc->lines[$i]->fk_product, - $facsrc->lines[$i]->remise_percent, - 'HT', + $facsrc->lines[$i]->localtax1_tx, + $facsrc->lines[$i]->localtax2_tx, + $facsrc->lines[$i]->fk_product, + $facsrc->lines[$i]->remise_percent, + 'HT', $facsrc->lines[$i]->info_bits, - '', - 0, - $facsrc->lines[$i]->product_type, - $facsrc->lines[$i]->rang, - $facsrc->lines[$i]->special_code, - $facsrc->lines[$i]->label, + '', + 0, + $facsrc->lines[$i]->product_type, + $facsrc->lines[$i]->rang, + $facsrc->lines[$i]->special_code, + $facsrc->lines[$i]->label, $facsrc->lines[$i]->fk_unit, $facsrc->lines[$i]->multicurrency_subprice - ); + ); if ($result_insert < 0) { $error++; } else { - $objectline = new FactureLigneRec($this->db); - if ($objectline->fetch($result_insert)) - { - // Extrafields - if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { - $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); - $objectline->array_options = $facsrc->lines[$i]->array_options; - } + $objectline = new FactureLigneRec($this->db); + if ($objectline->fetch($result_insert)) + { + // Extrafields + if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { + $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); + $objectline->array_options = $facsrc->lines[$i]->array_options; + } - $result = $objectline->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + $result = $objectline->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } } } @@ -370,27 +370,27 @@ class FactureRec extends CommonInvoice { foreach ($this->linked_objects as $origin => $tmp_origin_id) { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } } } @@ -422,7 +422,7 @@ class FactureRec extends CommonInvoice return $this->id; } } else { - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -442,46 +442,46 @@ class FactureRec extends CommonInvoice */ public function update(User $user, $notrigger = 0) { - global $conf; + global $conf; - $error = 0; + $error = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql .= " fk_soc = ".$this->fk_soc; - // TODO Add missing fields - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; + $sql .= " fk_soc = ".$this->fk_soc; + // TODO Add missing fields + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('BILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('BILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } } /** @@ -498,13 +498,13 @@ class FactureRec extends CommonInvoice $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.date_lim_reglement as dlr'; $sql .= ', f.note_private, f.note_public, f.fk_user_author'; - $sql .= ', f.modelpdf'; + $sql .= ', f.modelpdf'; $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; $sql .= ', f.fk_account'; $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; - $sql .= ', f.generate_pdf'; - $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', f.generate_pdf'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; @@ -618,21 +618,21 @@ class FactureRec extends CommonInvoice */ public function getLinesArray() { - return $this->fetch_lines(); + return $this->fetch_lines(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get lines of template invoices into this->lines * * @return int 1 if OK, < 0 if KO - */ + */ public function fetch_lines() { global $extrafields; - // phpcs:enable + // phpcs:enable $this->lines = array(); // Retrieve all extrafield for line @@ -710,7 +710,7 @@ class FactureRec extends CommonInvoice $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; - $line->fk_contract_line = $objp->fk_contract_line; + $line->fk_contract_line = $objp->fk_contract_line; // Ne plus utiliser $line->price = $objp->price; @@ -750,17 +750,17 @@ class FactureRec extends CommonInvoice */ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { - $rowid = $this->id; + $rowid = $this->id; - dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - $error = 0; + $error = 0; $this->db->begin(); $main = MAIN_DB_PREFIX.'facturedet_rec'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; - dol_syslog($sqlef); + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; + dol_syslog($sqlef); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sqlef) && $this->db->query($sql)) @@ -773,8 +773,8 @@ class FactureRec extends CommonInvoice $res = $this->deleteObjectLinked(); if ($res < 0) $error = -3; // Delete extrafields - $res = $this->deleteExtraFields(); - if ($res < 0) $error = -4; + $res = $this->deleteExtraFields(); + if ($res < 0) $error = -4; } else { $this->error = $this->db->lasterror(); $error = -1; @@ -786,11 +786,11 @@ class FactureRec extends CommonInvoice if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return $error; + $this->db->rollback(); + return $error; } } @@ -798,33 +798,33 @@ class FactureRec extends CommonInvoice /** * Add a line to invoice * - * @param string $desc Description de la ligne - * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) - * @param double $qty Quantite - * @param double $txtva Taux de tva force, sinon -1 + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) + * @param double $qty Quantite + * @param double $txtva Taux de tva force, sinon -1 * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) - * @param int $fk_product Product/Service ID predefined - * @param double $remise_percent Percentage discount of the line - * @param string $price_base_type HT or TTC - * @param int $info_bits VAT npr or not ? - * @param int $fk_remise_except Id remise - * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service) - * @param int $rang Position of line - * @param int $special_code Special code - * @param string $label Label of the line - * @param string $fk_unit Unit + * @param int $fk_product Product/Service ID predefined + * @param double $remise_percent Percentage discount of the line + * @param string $price_base_type HT or TTC + * @param int $info_bits VAT npr or not ? + * @param int $fk_remise_except Id remise + * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service) + * @param int $rang Position of line + * @param int $special_code Special code + * @param string $label Label of the line + * @param string $fk_unit Unit * @param double $pu_ht_devise Unit price in currency * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @return int <0 if KO, Id of line if OK + * @return int <0 if KO, Id of line if OK */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; $facid = $this->id; @@ -1008,131 +1008,131 @@ class FactureRec extends CommonInvoice */ public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; - $facid = $this->id; + $facid = $this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; + // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; - // Check parameters - if ($type < 0) return -1; + // Check parameters + if ($type < 0) return -1; - if ($this->brouillon) - { - // Clean parameters - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - if (empty($info_bits)) $info_bits = 0; - $pu_ht = price2num($pu_ht); - $pu_ttc = price2num($pu_ttc); - $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if ($this->brouillon) + { + // Clean parameters + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($info_bits)) $info_bits = 0; + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - if ($price_base_type == 'HT') - { - $pu = $pu_ht; - } else { - $pu = $pu_ttc; - } + if ($price_base_type == 'HT') + { + $pu = $pu_ht; + } else { + $pu = $pu_ttc; + } - // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; - $pu_tva = $tabprice[4]; - $pu_ttc = $tabprice[5]; + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; - $product_type = $type; - if ($fk_product) - { - $product = new Product($this->db); - $result = $product->fetch($fk_product); - $product_type = $product->type; - } + $product_type = $type; + if ($fk_product) + { + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; - $sql .= "fk_facture = ".((int) $facid); - $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); - $sql .= ", description='".$this->db->escape($desc)."'"; - $sql .= ", price=".price2num($pu_ht); - $sql .= ", qty=".price2num($qty); - $sql .= ", tva_tx=".price2num($txtva); - $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql .= ", localtax1_tx=".$txlocaltax1; - $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql .= ", localtax2_tx=".$txlocaltax2; - $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; - $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); - $sql .= ", product_type=".$product_type; - $sql .= ", remise_percent='".price2num($remise_percent)."'"; - $sql .= ", subprice='".price2num($pu_ht)."'"; - $sql .= ", total_ht='".price2num($total_ht)."'"; - $sql .= ", total_tva='".price2num($total_tva)."'"; - $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql .= ", total_ttc='".price2num($total_ttc)."'"; - $sql .= ", date_start_fill=".((int) $date_start_fill); - $sql .= ", date_end_fill=".((int) $date_end_fill); - $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); - $sql .= ", info_bits=".$info_bits; - $sql .= ", rang=".$rang; - $sql .= ", special_code=".$special_code; - $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); - $sql .= ', multicurrency_subprice = '.$pu_ht_devise; - $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; - $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; - $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql .= " WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; + $sql .= "fk_facture = ".((int) $facid); + $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", description='".$this->db->escape($desc)."'"; + $sql .= ", price=".price2num($pu_ht); + $sql .= ", qty=".price2num($qty); + $sql .= ", tva_tx=".price2num($txtva); + $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql .= ", localtax1_tx=".$txlocaltax1; + $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", localtax2_tx=".$txlocaltax2; + $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); + $sql .= ", product_type=".$product_type; + $sql .= ", remise_percent='".price2num($remise_percent)."'"; + $sql .= ", subprice='".price2num($pu_ht)."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", date_start_fill=".((int) $date_start_fill); + $sql .= ", date_end_fill=".((int) $date_end_fill); + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", info_bits=".$info_bits; + $sql .= ", rang=".$rang; + $sql .= ", special_code=".$special_code; + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ', multicurrency_subprice = '.$pu_ht_devise; + $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; + $sql .= " WHERE rowid = ".$rowid; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->id = $facid; - $this->update_price(); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->id = $facid; + $this->update_price(); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } } @@ -1328,8 +1328,8 @@ class FactureRec extends CommonInvoice * @param int $max Maxlength of ref * @param int $short 1=Return just URL * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) @@ -1356,17 +1356,17 @@ class FactureRec extends CommonInvoice } } - $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; + $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; - if ($short) return $url; + if ($short) return $url; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } $linkstart = ''; $linkend = ''; @@ -1391,7 +1391,7 @@ class FactureRec extends CommonInvoice return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1404,7 +1404,7 @@ class FactureRec extends CommonInvoice */ public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); @@ -1553,7 +1553,7 @@ class FactureRec extends CommonInvoice $arraynow = dol_getdate($now); $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); @@ -1690,190 +1690,190 @@ class FactureRec extends CommonInvoice } /** - * Update frequency and unit - * - * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) - * @return int <0 if KO, >0 if OK - */ - public function setFrequencyAndUnit($frequency, $unit) - { - if (!$this->table_element) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - - if (!empty($frequency) && empty($unit)) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); - return -2; - } - - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); - if (!empty($unit)) { - $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + * Update frequency and unit + * + * @param int $frequency value of frequency + * @param string $unit unit of frequency (d, m, y) + * @return int <0 if KO, >0 if OK + */ + public function setFrequencyAndUnit($frequency, $unit) + { + if (!$this->table_element) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); + return -1; } - $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); - if ($this->db->query($sql)) { - $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + if (!empty($frequency) && empty($unit)) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); + return -2; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); + if (!empty($unit)) { + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + } + $sql .= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); + if ($this->db->query($sql)) { + $this->frequency = $frequency; + if (!empty($unit)) $this->unit_frequency = $unit; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the next date of execution - * - * @param datetime $date date of execution - * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done - * @return int <0 if KO, >0 if OK - */ - public function setNextDate($date, $increment_nb_gen_done = 0) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; - $sql .= ' WHERE rowid = '.$this->id; + * Update the next date of execution + * + * @param datetime $date date of execution + * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @return int <0 if KO, >0 if OK + */ + public function setNextDate($date, $increment_nb_gen_done = 0) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); + if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->date_when = $date; - if ($increment_nb_gen_done > 0) $this->nb_gen_done++; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->date_when = $date; + if ($increment_nb_gen_done > 0) $this->nb_gen_done++; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the maximum period - * - * @param int $nb number of maximum period - * @return int <0 if KO, >0 if OK - */ - public function setMaxPeriod($nb) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the maximum period + * + * @param int $nb number of maximum period + * @return int <0 if KO, >0 if OK + */ + public function setMaxPeriod($nb) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - if (empty($nb)) $nb = 0; + if (empty($nb)) $nb = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->nb_gen_max = $nb; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->nb_gen_max = $nb; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the auto validate flag of invoice - * - * @param int $validate 0 to create in draft, 1 to create and validate invoice - * @return int <0 if KO, >0 if OK - */ - public function setAutoValidate($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the auto validate flag of invoice + * + * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @return int <0 if KO, >0 if OK + */ + public function setAutoValidate($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET auto_validate = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->auto_validate = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->auto_validate = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the auto generate documents - * - * @param int $validate 0 no document, 1 to generate document - * @return int <0 if KO, >0 if OK - */ - public function setGeneratePdf($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the auto generate documents + * + * @param int $validate 0 no document, 1 to generate document + * @return int <0 if KO, >0 if OK + */ + public function setGeneratePdf($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->generate_pdf = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->generate_pdf = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the model for documents - * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK - */ - public function setModelPdf($model) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the model for documents + * + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK + */ + public function setModelPdf($model) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET modelpdf = "'.$model.'"'; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET modelpdf = "'.$model.'"'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->modelpdf = $model; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->modelpdf = $model; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } } @@ -1898,206 +1898,206 @@ class FactureLigneRec extends CommonInvoiceLine public $date_end_fill; - /** - * Delete line in database - * - * @param User $user Object user - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - $error = 0; + /** + * Delete line in database + * + * @param User $user Object user + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('LINEBILLREC_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINEBILLREC_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } if (!$error) - { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - } - } - - if (!$error) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; - - $res = $this->db->query($sql); - if ($res === false) { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; + { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + } } - } + + if (!$error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if ($res === false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Get line of template invoice - * - * @param int $rowid Id of invoice - * @return int 1 if OK, < 0 if KO - */ - public function fetch($rowid) - { - $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; - $sql .= ' l.rang, l.special_code,'; - $sql .= ' l.fk_unit, l.fk_contract_line,'; - $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql .= ' WHERE l.rowid = '.$rowid; - $sql .= ' ORDER BY l.rang'; + /** + * Get line of template invoice + * + * @param int $rowid Id of invoice + * @return int 1 if OK, < 0 if KO + */ + public function fetch($rowid) + { + $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.rowid = '.$rowid; + $sql .= ' ORDER BY l.rang'; - dol_syslog('FactureRec::fetch', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + dol_syslog('FactureRec::fetch', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->label = $objp->custom_label; // Label line - $this->desc = $objp->description; // Description line - $this->description = $objp->description; // Description line - $this->product_type = $objp->product_type; // Type of line - $this->ref = $objp->product_ref; // Ref product - $this->product_ref = $objp->product_ref; // Ref product - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; // Label product - $this->product_desc = $objp->product_desc; // Description product - $this->fk_product_type = $objp->fk_product_type; // Type of product - $this->qty = $objp->qty; - $this->price = $objp->price; - $this->subprice = $objp->subprice; - $this->fk_facture = $objp->fk_facture; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->localtax1_type = $objp->localtax1_type; - $this->localtax2_type = $objp->localtax2_type; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->date_start_fill = $objp->date_start_fill; - $this->date_end_fill = $objp->date_end_fill; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; - $this->code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->special_code = $objp->special_code; - $this->fk_unit = $objp->fk_unit; - $this->fk_contract_line = $objp->fk_contract_line; + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->qty = $objp->qty; + $this->price = $objp->price; + $this->subprice = $objp->subprice; + $this->fk_facture = $objp->fk_facture; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->date_start_fill = $objp->date_start_fill; + $this->date_end_fill = $objp->date_end_fill; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + $this->code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->fk_unit = $objp->fk_unit; + $this->fk_contract_line = $objp->fk_contract_line; - $this->db->free($result); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -3; - } - } + $this->db->free($result); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -3; + } + } - /** - * Update a line to invoice_rec. - * - * @param User $user User - * @param int $notrigger No trigger - * @return int <0 if KO, Id of line if OK - */ - public function update(User $user, $notrigger = 0) - { - global $conf; + /** + * Update a line to invoice_rec. + * + * @param User $user User + * @param int $notrigger No trigger + * @return int <0 if KO, Id of line if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf; - $error = 0; + $error = 0; - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql .= " fk_facture = ".$this->fk_facture; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", description='".$this->db->escape($this->desc)."'"; - $sql .= ", price=".price2num($this->price); - $sql .= ", qty=".price2num($this->qty); - $sql .= ", tva_tx=".price2num($this->tva_tx); - $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; - $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); - $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); - $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); - $sql .= ", product_type=".$this->product_type; - $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql .= ", subprice='".price2num($this->subprice)."'"; - $sql .= ", info_bits='".price2num($this->info_bits)."'"; - $sql .= ", date_start_fill=".(int) $this->date_start_fill; - $sql .= ", date_end_fill=".(int) $this->date_end_fill; - if (empty($this->skip_update_total)) { - $sql .= ", total_ht=".price2num($this->total_ht); - $sql .= ", total_tva=".price2num($this->total_tva); - $sql .= ", total_localtax1=".price2num($this->total_localtax1); - $sql .= ", total_localtax2=".price2num($this->total_localtax2); - $sql .= ", total_ttc=".price2num($this->total_ttc); - } - $sql .= ", rang=".$this->rang; - $sql .= ", special_code=".$this->special_code; - $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); - $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; + $sql .= " fk_facture = ".$this->fk_facture; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", description='".$this->db->escape($this->desc)."'"; + $sql .= ", price=".price2num($this->price); + $sql .= ", qty=".price2num($this->qty); + $sql .= ", tva_tx=".price2num($this->tva_tx); + $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql .= ", subprice='".price2num($this->subprice)."'"; + $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", date_start_fill=".(int) $this->date_start_fill; + $sql .= ", date_end_fill=".(int) $this->date_end_fill; + if (empty($this->skip_update_total)) { + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ttc=".price2num($this->total_ttc); + } + $sql .= ", rang=".$this->rang; + $sql .= ", special_code=".$this->special_code; + $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index b99e4c35d1c..c3700d9e994 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -61,44 +61,44 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); + $db->begin(); - $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid = GETPOST("accountid"); - $object->paymenttype = GETPOST("paiementtype"); - $object->datev = $datev; - $object->datep = $datep; - $object->amount = price2num(GETPOST("amount")); + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); $object->label = GETPOST("label"); $object->ltt = $lttype; - $ret = $object->addPayment($user); - if ($ret > 0) - { - $db->commit(); - header("Location: list.php?localTaxType=".$lttype); - exit; - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"] = "create"; - } + $ret = $object->addPayment($user); + if ($ret > 0) + { + $db->commit(); + header("Location: list.php?localTaxType=".$lttype); + exit; + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $_GET["action"] = "create"; + } } //delete payment of localtax if ($action == 'delete') { - $result = $object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { - $db->begin(); + $db->begin(); - $ret = $object->delete($user); - if ($ret > 0) - { + $ret = $object->delete($user); + if ($ret > 0) + { if ($object->fk_bank) { $accountline = new AccountLine($db); @@ -116,13 +116,13 @@ if ($action == 'delete') $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } } else { - $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; - setEventMessages($mesg, null, 'errors'); + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } @@ -149,25 +149,25 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); - print ''."\n"; - print ''; - print ''; - print ''; + print ''."\n"; + print ''; + print ''; + print ''; - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label print ''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 11b225d0896..6e018e0bb84 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -32,79 +32,79 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class ChargeSociales extends CommonObject { - /** + /** * @var string ID to identify managed object */ public $element = 'chargesociales'; - public $table = 'chargesociales'; + public $table = 'chargesociales'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'chargesociales'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'bill'; - - /** - * {@inheritdoc} - */ - protected $table_ref_field = 'ref'; - - /** - * @var integer|string $date_ech - */ - public $date_ech; - - - public $label; - public $type; - public $type_label; - public $amount; - public $paye; - public $periode; - - /** - * @var integer|string date_creation - */ - public $date_creation; - - /** - * @var integer|string $date_modification - */ - public $date_modification; - - /** - * @var integer|string $date_validation - */ - public $date_validation; - - /** - * @deprecated Use label instead - */ - public $lib; - - /** - * @var int account ID - */ - public $fk_account; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'bill'; /** - * @var int account ID (identical to fk_account) - */ - public $accountid; + * {@inheritdoc} + */ + protected $table_ref_field = 'ref'; - /** - * @var int payment type (identical to mode_reglement_id in commonobject class) - */ - public $paiementtype; + /** + * @var integer|string $date_ech + */ + public $date_ech; - /** - * @var int ID - */ + + public $label; + public $type; + public $type_label; + public $amount; + public $paye; + public $periode; + + /** + * @var integer|string date_creation + */ + public $date_creation; + + /** + * @var integer|string $date_modification + */ + public $date_modification; + + /** + * @var integer|string $date_validation + */ + public $date_validation; + + /** + * @deprecated Use label instead + */ + public $lib; + + /** + * @var int account ID + */ + public $fk_account; + + /** + * @var int account ID (identical to fk_account) + */ + public $accountid; + + /** + * @var int payment type (identical to mode_reglement_id in commonobject class) + */ + public $paiementtype; + + /** + * @var int ID + */ public $fk_project; @@ -112,73 +112,73 @@ class ChargeSociales extends CommonObject const STATUS_PAID = 1; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retrouve et charge une charge sociale - * - * @param int $id Id - * @param string $ref Ref - * @return int <0 KO >0 OK - */ - public function fetch($id, $ref = '') - { - $sql = "SELECT cs.rowid, cs.date_ech"; - $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; - $sql .= ", cs.fk_account, cs.fk_mode_reglement"; - $sql .= ", c.libelle"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; - $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; - if ($ref) $sql .= " AND cs.rowid = ".$ref; - else $sql .= " AND cs.rowid = ".$id; + /** + * Retrouve et charge une charge sociale + * + * @param int $id Id + * @param string $ref Ref + * @return int <0 KO >0 OK + */ + public function fetch($id, $ref = '') + { + $sql = "SELECT cs.rowid, cs.date_ech"; + $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; + $sql .= ", cs.fk_account, cs.fk_mode_reglement"; + $sql .= ", c.libelle"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; + $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; + if ($ref) $sql .= " AND cs.rowid = ".$ref; + else $sql .= " AND cs.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->date_ech = $this->db->jdate($obj->date_ech); - $this->lib = $obj->label; - $this->label = $obj->label; - $this->type = $obj->fk_type; - $this->type_label = $obj->libelle; - $this->fk_account = $obj->fk_account; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; - $this->amount = $obj->amount; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->date_ech = $this->db->jdate($obj->date_ech); + $this->lib = $obj->label; + $this->label = $obj->label; + $this->type = $obj->fk_type; + $this->type_label = $obj->libelle; + $this->fk_account = $obj->fk_account; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->amount = $obj->amount; $this->fk_project = $obj->fk_project; - $this->paye = $obj->paye; - $this->periode = $this->db->jdate($obj->periode); - $this->import_key = $this->import_key; + $this->paye = $obj->paye; + $this->periode = $this->db->jdate($obj->periode); + $this->import_key = $this->import_key; - $this->db->free($resql); + $this->db->free($resql); - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + return 1; + } else { + return 0; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Check if a social contribution can be created into database @@ -189,59 +189,59 @@ class ChargeSociales extends CommonObject { $newamount = price2num($this->amount, 'MT'); - // Validation parametres - if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) - { - return false; - } + // Validation parametres + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) + { + return false; + } return true; } - /** - * Create a social contribution into database - * - * @param User $user User making creation - * @return int <0 if KO, id if OK - */ - public function create($user) - { - global $conf; + /** + * Create a social contribution into database + * + * @param User $user User making creation + * @return int <0 if KO, id if OK + */ + public function create($user) + { + global $conf; $error = 0; - $now = dol_now(); + $now = dol_now(); - // Nettoyage parametres - $newamount = price2num($this->amount, 'MT'); + // Nettoyage parametres + $newamount = price2num($this->amount, 'MT'); if (!$this->check()) { $this->error = "ErrorBadParameter"; return -2; } - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; - $sql .= " VALUES (".$this->type; - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); - $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; - $sql .= ", '".$this->db->idate($this->date_ech)."'"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; + $sql .= " VALUES (".$this->type; + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", '".$this->db->idate($this->date_ech)."'"; $sql .= ", '".$this->db->idate($this->periode)."'"; - $sql .= ", '".price2num($newamount)."'"; + $sql .= ", '".price2num($newamount)."'"; $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); - $sql .= ", ".$conf->entity; - $sql .= ", ".$user->id; - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ")"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); - //dol_syslog("ChargesSociales::create this->id=".$this->id); + //dol_syslog("ChargesSociales::create this->id=".$this->id); $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); if ($result < 0) $error++; @@ -252,429 +252,429 @@ class ChargeSociales extends CommonObject $this->db->rollback(); return -1 * $error; } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Delete a social contribution - * - * @param User $user Object user making delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - $error = 0; + /** + * Delete a social contribution + * + * @param User $user Object user making delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - // Get bank transaction lines for this social contributions - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account = new Account($this->db); - $lines_url = $account->get_url('', $this->id, 'sc'); + // Get bank transaction lines for this social contributions + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $account = new Account($this->db); + $lines_url = $account->get_url('', $this->id, 'sc'); - // Delete bank urls - foreach ($lines_url as $line_url) - { - if (!$error) - { - $accountline = new AccountLine($this->db); - $accountline->fetch($line_url['fk_bank']); - $result = $accountline->delete_urls($user); - if ($result < 0) - { - $error++; - } - } - } + // Delete bank urls + foreach ($lines_url as $line_url) + { + if (!$error) + { + $accountline = new AccountLine($this->db); + $accountline->fetch($line_url['fk_bank']); + $result = $accountline->delete_urls($user); + if ($result < 0) + { + $error++; + } + } + } - // Delete payments - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + // Delete payments + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Update social or fiscal contribution - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - $error = 0; - $this->db->begin(); + /** + * Update social or fiscal contribution + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; - $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; - $sql .= ", periode='".$this->db->idate($this->periode)."'"; - $sql .= ", amount='".price2num($this->amount, 'MT')."'"; - $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); - $sql .= ", fk_user_modif=".$user->id; - $sql .= " WHERE rowid=".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; + $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; + $sql .= ", periode='".$this->db->idate($this->periode)."'"; + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); + $sql .= ", fk_user_modif=".$user->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } - } + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + } - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Calculate amount remaining to pay by year - * - * @param int $year Year - * @return number - */ - public function solde($year = 0) - { - global $conf; + /** + * Calculate amount remaining to pay by year + * + * @param int $year Year + * @return number + */ + public function solde($year = 0) + { + global $conf; - $sql = "SELECT SUM(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql .= " WHERE f.entity = ".$conf->entity; - $sql .= " AND paye = 0"; + $sql = "SELECT SUM(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND paye = 0"; - if ($year) { - $sql .= " AND f.datev >= '".((int) $year)."-01-01' AND f.datev <= '".((int) $year)."-12-31' "; - } + if ($year) { + $sql .= " AND f.datev >= '".((int) $year)."-01-01' AND f.datev <= '".((int) $year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->db->free($result); - return $obj->amount; - } else { - return 0; - } - } else { - print $this->db->error(); - return -1; - } - } + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->db->free($result); + return $obj->amount; + } else { + return 0; + } + } else { + print $this->db->error(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Tag social contribution as payed completely - * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK - */ - public function set_paid($user) - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql .= " paye = 1"; - $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; - else return -1; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Tag social contribution as payed completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_paid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove tag payed on social contribution - * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK - */ - public function set_unpaid($user) - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql .= " paye = 0"; - $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; - else return -1; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Remove tag payed on social contribution + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_unpaid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } - /** - * Retourne le libelle du statut d'une charge (impaye, payee) - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + /** + * Retourne le libelle du statut d'une charge (impaye, payee) + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - public function getLibStatut($mode = 0, $alreadypaid = -1) - { - return $this->LibStatut($this->paye, $mode, $alreadypaid); - } + * @return string Label + */ + public function getLibStatut($mode = 0, $alreadypaid = -1) + { + return $this->LibStatut($this->paye, $mode, $alreadypaid); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - public function LibStatut($status, $mode = 0, $alreadypaid = -1) - { - // phpcs:enable - global $langs; + * @return string Label + */ + public function LibStatut($status, $mode = 0, $alreadypaid = -1) + { + // phpcs:enable + global $langs; - // Load translation files required by the page - $langs->loadLangs(array("customers", "bills")); + // Load translation files required by the page + $langs->loadLangs(array("customers", "bills")); - // We reinit status array to force to redefine them because label may change according to properties values. - $this->labelStatus = array(); - $this->labelStatusShort = array(); + // We reinit status array to force to redefine them because label may change according to properties values. + $this->labelStatus = array(); + $this->labelStatusShort = array(); - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { - global $langs; - //$langs->load("mymodule"); - $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); - $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); - $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - } + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } - $statusType = 'status1'; - if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; - if ($status == 1) $statusType = 'status6'; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } - /** + /** * Return a link to the object card (with optionaly the picto) * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param int $maxlen Max length of label - * @param int $notooltip 1=Disable tooltip + * @param int $maxlen Max length of label + * @param int $notooltip 1=Disable tooltip * @param int $short 1=Return just URL - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with link - */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) - { - global $langs, $conf, $user, $form; + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with link + */ + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) + { + global $langs, $conf, $user, $form; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result = ''; + $result = ''; - $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; - if ($short) return $url; + if ($short) return $url; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - if (empty($this->ref)) $this->ref = $this->label; + if (empty($this->ref)) $this->ref = $this->label; - $label = ''.$langs->trans("SocialContribution").''; - if (!empty($this->ref)) - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->label)) - $label .= '
'.$langs->trans('Label').': '.$this->label; - if (!empty($this->type_label)) - $label .= '
'.$langs->trans('Type').': '.$this->type_label; + $label = ''.$langs->trans("SocialContribution").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
'.$langs->trans('Label').': '.$this->label; + if (!empty($this->type_label)) + $label .= '
'.$langs->trans('Type').': '.$this->type_label; - $linkclose = ''; - if (empty($notooltip) && $user->rights->facture->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SocialContribution"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->facture->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("SocialContribution"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'paiementcharge'; - $field = 'fk_charge'; + /** + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'paiementcharge'; + $field = 'fk_charge'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) $amount = $obj->amount ? $obj->amount : 0; - $this->db->free($resql); - return $amount; - } else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } - /** - * Charge les informations d'ordre info dans l'objet entrepot - * - * @param int $id Id of social contribution - * @return int <0 if KO, >0 if OK - */ - public function info($id) - { - $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; - $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; + /** + * Charge les informations d'ordre info dans l'objet entrepot + * + * @param int $id Id of social contribution + * @return int <0 if KO, >0 if OK + */ + public function info($id) + { + $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; - $sql .= " WHERE e.rowid = ".$id; + $sql .= " WHERE e.rowid = ".$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + if ($obj->fk_user_modif) { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } - if ($obj->fk_user_valid) { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - $this->import_key = $obj->import_key; - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + $this->import_key = $obj->import_key; + } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - // Initialize parameters - $this->id = 0; - $this->ref = 'SPECIMEN'; - $this->specimen = 1; - $this->paye = 0; - $this->date = dol_now(); - $this->date_ech = $this->date + 3600 * 24 * 30; - $this->periode = $this->date + 3600 * 24 * 30; - $this->amount = 100; - $this->label = 'Social contribution label'; - $this->type = 1; - $this->type_label = 'Type of social contribution'; - } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + // Initialize parameters + $this->id = 0; + $this->ref = 'SPECIMEN'; + $this->specimen = 1; + $this->paye = 0; + $this->date = dol_now(); + $this->date_ech = $this->date + 3600 * 24 * 30; + $this->periode = $this->date + 3600 * 24 * 30; + $this->amount = 100; + $this->label = 'Social contribution label'; + $this->type = 1; + $this->type_label = 'Type of social contribution'; + } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 034e436a612..c278eaeedb7 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -33,36 +33,36 @@ abstract class CommonInvoice extends CommonObject { use CommonIncoterm; - /** - * Standard invoice - */ - const TYPE_STANDARD = 0; + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; - /** - * Replacement invoice - */ - const TYPE_REPLACEMENT = 1; + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; - /** - * Credit note invoice - */ - const TYPE_CREDIT_NOTE = 2; + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; - /** - * Deposit invoice - */ - const TYPE_DEPOSIT = 3; + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; - /** - * Proforma invoice. - * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! - */ - const TYPE_PROFORMA = 4; + /** + * Proforma invoice. + * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! + */ + const TYPE_PROFORMA = 4; - /** - * Situation invoice - */ - const TYPE_SITUATION = 5; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; /** * Draft status @@ -102,16 +102,16 @@ abstract class CommonInvoice extends CommonObject */ public function getRemainToPay($multicurrency = 0) { - $alreadypaid = 0.0; - $alreadypaid += $this->getSommePaiement($multicurrency); - $alreadypaid += $this->getSumDepositsUsed($multicurrency); - $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); + $alreadypaid = 0.0; + $alreadypaid += $this->getSommePaiement($multicurrency); + $alreadypaid += $this->getSumDepositsUsed($multicurrency); + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); - $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); - if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment - $remaintopay = 0.0; - } - return $remaintopay; + $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); + if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment + $remaintopay = 0.0; + } + return $remaintopay; } /** @@ -151,7 +151,7 @@ abstract class CommonInvoice extends CommonObject /** * Return amount (with tax) of all deposits invoices used by invoice. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param int $multicurrency Return multicurrency_amount instead of amount * @return float <0 if KO, Sum of deposits amount otherwise @@ -159,21 +159,21 @@ abstract class CommonInvoice extends CommonObject public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') - { - // TODO - return 0.0; - } + { + // TODO + return 0.0; + } - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -184,16 +184,16 @@ abstract class CommonInvoice extends CommonObject */ public function getSumCreditNotesUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -204,16 +204,16 @@ abstract class CommonInvoice extends CommonObject */ public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -329,7 +329,7 @@ abstract class CommonInvoice extends CommonObject $obj = $this->db->fetch_object($resql); $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); if (!empty($field3)) { - $tmp['ref_ext'] = $obj->ref_ext; + $tmp['ref_ext'] = $obj->ref_ext; } $retarray[]=$tmp; $i++; @@ -385,7 +385,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -399,9 +399,9 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - public function is_erasable() - { - // phpcs:enable + public function is_erasable() + { + // phpcs:enable global $conf; // We check if invoice is a temporary number (PROVxxxx) @@ -486,15 +486,15 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - public function getLibType() + public function getLibType() { global $langs; - if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. - elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); + elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. + elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } @@ -510,7 +510,7 @@ abstract class CommonInvoice extends CommonObject return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -523,52 +523,52 @@ abstract class CommonInvoice extends CommonObject */ public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); $statusType = 'status0'; $prefix = 'Short'; if (!$paye) { - if ($status == 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft'); - } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid'); - $statusType = 'status5'; - } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedPaidPartially'); - $statusType = 'status9'; - } elseif ($alreadypaid == 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusNotPaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusNotPaid'); - $statusType = 'status1'; - } else { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusStarted'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusStarted'); - $statusType = 'status3'; - } + if ($status == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft'); + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid'); + $statusType = 'status5'; + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedPaidPartially'); + $statusType = 'status9'; + } elseif ($alreadypaid == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusNotPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusNotPaid'); + $statusType = 'status1'; + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusStarted'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusStarted'); + $statusType = 'status3'; + } } else { - $statusType = 'status6'; + $statusType = 'status6'; - if ($type == self::TYPE_CREDIT_NOTE) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaidBackOrConverted'); // credit note - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note - } elseif ($type == self::TYPE_DEPOSIT) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusConverted'); // deposit invoice - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusConverted'); // deposit invoice - } else { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaid'); - } + if ($type == self::TYPE_CREDIT_NOTE) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaidBackOrConverted'); // credit note + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note + } elseif ($type == self::TYPE_DEPOSIT) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusConverted'); // deposit invoice + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusConverted'); // deposit invoice + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaid'); + } } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an invoice payment deadline based on the invoice settlement * conditions and billing date. @@ -576,15 +576,15 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return integer Date limite de reglement si ok, <0 si ko */ - public function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { - // phpcs:enable + // phpcs:enable if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; $cdr_nbjour = 0; - $cdr_type = 0; - $cdr_decalage = 0; + $cdr_type = 0; + $cdr_decalage = 0; $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; @@ -643,7 +643,7 @@ abstract class CommonInvoice extends CommonObject // 2 : application of the rule, the N of the current or next month elseif ($cdr_type == 2 && !empty($cdr_decalage)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $datelim = $this->date + ($cdr_nbjour * 3600 * 24); $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7cdf83f9961..6b76148d350 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6701,10 +6701,10 @@ function setEventMessage($mesgs, $style = 'mesgs') { //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { - // If mesgs is a string + // If mesgs is a string if ($mesgs) $_SESSION['dol_events'][$style][] = $mesgs; } else { - // If mesgs is an array + // If mesgs is an array foreach ($mesgs as $mesg) { if ($mesg) $_SESSION['dol_events'][$style][] = $mesg; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 8f06c0958c0..8b37604ce20 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1641,7 +1641,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; } } else { - // Common usage + // Common usage $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name; } } diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index 638eb83b9cd..3a34d3e57c4 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -32,10 +32,10 @@ */ function loan_prepare_head($object) { - global $db, $langs, $conf; + global $db, $langs, $conf; - $tab = 0; - $head = array(); + $tab = 0; + $head = array(); $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id; $head[$tab][1] = $langs->trans('Card'); @@ -47,17 +47,17 @@ function loan_prepare_head($object) $head[$tab][2] = 'FinancialCommitment'; $tab++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->loan->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; @@ -73,14 +73,14 @@ function loan_prepare_head($object) $tab++; } - $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id; - $head[$tab][1] = $langs->trans("Info"); - $head[$tab][2] = 'info'; - $tab++; + $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id; + $head[$tab][1] = $langs->trans("Info"); + $head[$tab][2] = 'info'; + $tab++; - complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove'); - return $head; + return $head; } /** @@ -95,42 +95,42 @@ function loan_prepare_head($object) */ function loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm) { - global $conf, $db; - require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; - $object = new LoanSchedule($db); - $output = array(); + global $conf, $db; + require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; + $object = new LoanSchedule($db); + $output = array(); - // If mensuality is 0 we don't pay interests and remaining capital not modified - if ($mens == 0) { - $int = 0; - $cap_rest = $capital; - } else { - $int = ($capital * ($rate / 12)); - $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - } - $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); + // If mensuality is 0 we don't pay interests and remaining capital not modified + if ($mens == 0) { + $int = 0; + $cap_rest = $capital; + } else { + $int = ($capital * ($rate / 12)); + $int = round($int, 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); + } + $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); - $echance++; - $capital = $cap_rest; - while ($echance <= $nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); + $echance++; + $capital = $cap_rest; + while ($echance <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); - $int = ($capital * ($rate / 12)); - $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); + $int = ($capital * ($rate / 12)); + $int = round($int, 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance] = array( - 'cap_rest' => $cap_rest, - 'cap_rest_str' => price($cap_rest, 0, '', 1, -1, -1, $conf->currency), - 'interet' => $int, - 'interet_str' => price($int, 0, '', 1, -1, -1, $conf->currency), - 'mens' => $mens, - ); + $output[$echance] = array( + 'cap_rest' => $cap_rest, + 'cap_rest_str' => price($cap_rest, 0, '', 1, -1, -1, $conf->currency), + 'interet' => $int, + 'interet_str' => price($int, 0, '', 1, -1, -1, $conf->currency), + 'mens' => $mens, + ); - $capital = $cap_rest; - $echance++; - } + $capital = $cap_rest; + $echance++; + } - return $output; + return $output; } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 0a15a99dfc0..011ac381254 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -31,15 +31,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; class mod_task_universal extends ModeleNumRefTask { /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** - * @var string Error code (or message) - */ - public $error = ''; + * @var string Error code (or message) + */ + public $error = ''; /** * @var string @@ -54,17 +54,17 @@ class mod_task_universal extends ModeleNumRefTask public $name = 'Universal'; - /** - * Returns the description of the numbering model - * - * @return string Texte descripif - */ - public function info() - { - global $conf, $langs, $db; + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; // Load translation files required by the page - $langs->loadLangs(array("projects", "admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($db); @@ -93,37 +93,37 @@ class mod_task_universal extends ModeleNumRefTask $texte .= ''; return $texte; - } + } - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $conf, $langs, $mysoc; + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc, ''); $mysoc->code_client = $old_code_client; if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } return $numExample; - } + } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $object) - { + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $object) + { global $db, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -143,17 +143,17 @@ class mod_task_universal extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Next not used reference - */ - public function project_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next reference not yet used as a reference + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Next not used reference + */ + public function project_get_num($objsoc = 0, $object = '') + { + // phpcs:enable + return $this->getNextValue($objsoc, $object); + } } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index a6fa9fa987d..8d5d22482b8 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -685,7 +685,7 @@ class Don extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated // Retrieve all extrafield // fetch optionals attributes and labels diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index a01eb50981d..19f979d0f16 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -80,11 +80,11 @@ if ($action == 'add_payment') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !($accountid > 0)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); - $error++; - } + if (!empty($conf->banque->enabled) && !($accountid > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); + $error++; + } if (!$error) { @@ -101,67 +101,67 @@ if ($action == 'add_payment') } } - if (count($amounts) <= 0) - { - $error++; - $errmsg = 'ErrorNoPaymentDefined'; - } + if (count($amounts) <= 0) + { + $error++; + $errmsg = 'ErrorNoPaymentDefined'; + } - if (!$error) - { - $db->begin(); + if (!$error) + { + $db->begin(); - // Create a line of payments - $payment = new PaymentExpenseReport($db); - $payment->fk_expensereport = $expensereport->id; - $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant - $payment->total = $total; - $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); - $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); - $payment->note_public = GETPOST("note_public", 'restricthtml'); + // Create a line of payments + $payment = new PaymentExpenseReport($db); + $payment->fk_expensereport = $expensereport->id; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->total = $total; + $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); + $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); + $payment->note_public = GETPOST("note_public", 'restricthtml'); - if (!$error) - { - $paymentid = $payment->create($user); - if ($paymentid < 0) - { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } + if (!$error) + { + $paymentid = $payment->create($user); + if ($paymentid < 0) + { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } - if (!$error) - { - $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (!$result > 0) - { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } + if (!$error) + { + $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); + if (!$result > 0) + { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } - if (!$error) { - $payment->fetch($paymentid); - if ($expensereport->total_ttc - $payment->amount == 0) { - $result = $expensereport->set_paid($expensereport->id, $user); - if (!$result > 0) { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } - } + if (!$error) { + $payment->fetch($paymentid); + if ($expensereport->total_ttc - $payment->amount == 0) { + $result = $expensereport->set_paid($expensereport->id, $user); + if (!$result > 0) { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } + } - if (!$error) - { - $db->commit(); - $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } - } + if (!$error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; + header('Location: '.$loc); + exit; + } else { + $db->rollback(); + } + } } $action = 'create'; @@ -194,9 +194,9 @@ if ($action == 'create' || empty($action)) var amount = $(this).data("value"); document.getElementById($(this).data(\'rowid\')).value = amount ; });'; - print "\t});\n"; - print "\n"; - } + print "\t});\n"; + print "\n"; + } print load_fiche_titre($langs->trans("DoPayment")); @@ -206,17 +206,17 @@ if ($action == 'create' || empty($action)) print ''; print ''; - print dol_get_fiche_head(null, '0', '', -1); + print dol_get_fiche_head(null, '0', '', -1); - $linkback = ''; - // $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''; + // $linkback = '' . $langs->trans("BackToList") . ''; - dol_banner_tab($expensereport, 'ref', $linkback, 1, 'ref', 'ref', ''); + dol_banner_tab($expensereport, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
'.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); - print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); + print '
'.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">
'."\n"; + print '
'."\n"; print ''; print ''; @@ -224,7 +224,7 @@ if ($action == 'create' || empty($action)) $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id; - $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); if ($resql) { @@ -259,11 +259,11 @@ if ($action == 'create' || empty($action)) if (!empty($conf->banque->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Number diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 06cfa6edfac..2d28ac799d7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -61,13 +61,13 @@ function testSqlAndScriptInject($val, $type) // Decode string first // So debugbar->enabled) && !GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) { - global $debugbar; - include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; - $debugbar = new DolibarrDebugBar(); - $renderer = $debugbar->getRenderer(); - $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead(); + global $debugbar; + include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; + $debugbar = new DolibarrDebugBar(); + $renderer = $debugbar->getRenderer(); + $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead(); - $debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)'); + $debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)'); } // Detection browser @@ -420,7 +420,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl if (GETPOSTISSET('disablemodules')) $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha'); if (!empty($_SESSION["disablemodules"])) { - $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal'); + $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal'); $disabled_modules = explode(',', $_SESSION["disablemodules"]); foreach ($disabled_modules as $module) @@ -431,7 +431,7 @@ if (!empty($_SESSION["disablemodules"])) $conf->$module->enabled = false; foreach ($modulepartkeys as $modulepartkey) { - unset($conf->modules_parts[$modulepartkey][$module]); + unset($conf->modules_parts[$modulepartkey][$module]); } if ($module == 'fournisseur') // Special case { @@ -451,7 +451,7 @@ if (is_array($modulepart) && count($modulepart) > 0) if (in_array($module, $modulepart)) { $conf->modulepart = $module; - break; + break; } } } @@ -649,14 +649,14 @@ if (!defined('NOLOGIN')) if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED'; else { if ($_SERVER["HTTP_USER_AGENT"] == 'securitytest') { - http_response_code(401); // It makes easier to understand if session was broken during security tests + http_response_code(401); // It makes easier to understand if session was broken during security tests } dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); } exit; } - $resultFetchUser = $user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // login was retrieved previously when checking password. + $resultFetchUser = $user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // login was retrieved previously when checking password. if ($resultFetchUser <= 0) { dol_syslog('User not found, connexion refused'); @@ -757,48 +757,48 @@ if (!defined('NOLOGIN')) header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : '')); exit; } else { - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - $hookmanager->initHooks(array('main')); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); - // Code for search criteria persistence. - if (!empty($_GET['save_lastsearch_values'])) // We must use $_GET here - { - $relativepathstring = preg_replace('/\?.*$/', '', $_SERVER["HTTP_REFERER"]); - $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/', '', $relativepathstring); // Get full path except host server - // Clean $relativepathstring - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - //var_dump($relativepathstring); + // Code for search criteria persistence. + if (!empty($_GET['save_lastsearch_values'])) // We must use $_GET here + { + $relativepathstring = preg_replace('/\?.*$/', '', $_SERVER["HTTP_REFERER"]); + $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/', '', $relativepathstring); // Get full path except host server + // Clean $relativepathstring + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + //var_dump($relativepathstring); - // We click on a link that leave a page we have to save search criteria, contextpage, limit and page. We save them from tmp to no tmp - if (!empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring])) - { - $_SESSION['lastsearch_values_'.$relativepathstring] = $_SESSION['lastsearch_values_tmp_'.$relativepathstring]; - unset($_SESSION['lastsearch_values_tmp_'.$relativepathstring]); - } - if (!empty($_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring])) - { - $_SESSION['lastsearch_contextpage_'.$relativepathstring] = $_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]; - unset($_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]); - } - if (!empty($_SESSION['lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_page_tmp_'.$relativepathstring] > 0) - { - $_SESSION['lastsearch_page_'.$relativepathstring] = $_SESSION['lastsearch_page_tmp_'.$relativepathstring]; - unset($_SESSION['lastsearch_page_tmp_'.$relativepathstring]); - } - if (!empty($_SESSION['lastsearch_limit_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_limit_tmp_'.$relativepathstring] != $conf->liste_limit) - { - $_SESSION['lastsearch_limit_'.$relativepathstring] = $_SESSION['lastsearch_limit_tmp_'.$relativepathstring]; - unset($_SESSION['lastsearch_limit_tmp_'.$relativepathstring]); - } - } + // We click on a link that leave a page we have to save search criteria, contextpage, limit and page. We save them from tmp to no tmp + if (!empty($_SESSION['lastsearch_values_tmp_'.$relativepathstring])) + { + $_SESSION['lastsearch_values_'.$relativepathstring] = $_SESSION['lastsearch_values_tmp_'.$relativepathstring]; + unset($_SESSION['lastsearch_values_tmp_'.$relativepathstring]); + } + if (!empty($_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring])) + { + $_SESSION['lastsearch_contextpage_'.$relativepathstring] = $_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]; + unset($_SESSION['lastsearch_contextpage_tmp_'.$relativepathstring]); + } + if (!empty($_SESSION['lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_page_tmp_'.$relativepathstring] > 0) + { + $_SESSION['lastsearch_page_'.$relativepathstring] = $_SESSION['lastsearch_page_tmp_'.$relativepathstring]; + unset($_SESSION['lastsearch_page_tmp_'.$relativepathstring]); + } + if (!empty($_SESSION['lastsearch_limit_tmp_'.$relativepathstring]) && $_SESSION['lastsearch_limit_tmp_'.$relativepathstring] != $conf->liste_limit) + { + $_SESSION['lastsearch_limit_'.$relativepathstring] = $_SESSION['lastsearch_limit_tmp_'.$relativepathstring]; + unset($_SESSION['lastsearch_limit_tmp_'.$relativepathstring]); + } + } - $action = ''; - $reshook = $hookmanager->executeHooks('updateSession', array(), $user, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + $action = ''; + $reshook = $hookmanager->executeHooks('updateSession', array(), $user, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } } } @@ -1104,8 +1104,8 @@ if (!function_exists("llxHeader")) // If theme MD and classic layer, we open the menulayer by default. if ($conf->theme == 'md' && !in_array($conf->browser->layout, array('phone', 'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - global $mainmenu; - if ($mainmenu != 'website') $tmpcsstouse = $morecssonbody; // We do not use sidebar-collpase by default to have menuhider open by default. + global $mainmenu; + if ($mainmenu != 'website') $tmpcsstouse = $morecssonbody; // We do not use sidebar-collpase by default to have menuhider open by default. } if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) { @@ -1224,10 +1224,10 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr //print ''."\n"; if (empty($disablehead)) { - if (!is_object($hookmanager)) $hookmanager = new HookManager($db); - $hookmanager->initHooks(array("main")); + if (!is_object($hookmanager)) $hookmanager = new HookManager($db); + $hookmanager->initHooks(array("main")); - $ext = 'layout='.$conf->browser->layout.'&version='.urlencode(DOL_VERSION); + $ext = 'layout='.$conf->browser->layout.'&version='.urlencode(DOL_VERSION); print "\n"; @@ -1249,16 +1249,16 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; - // Mobile appli like icon - $manifest = DOL_URL_ROOT.'/theme/'.$conf->theme.'/manifest.json.php'; - if (!empty($manifest)) { - print ''."\n"; - } + // Mobile appli like icon + $manifest = DOL_URL_ROOT.'/theme/'.$conf->theme.'/manifest.json.php'; + if (!empty($manifest)) { + print ''."\n"; + } - if (!empty($conf->global->THEME_ELDY_TOPMENU_BACK1)) { - // TODO: use auto theme color switch - print ''."\n"; - } + if (!empty($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + // TODO: use auto theme color switch + print ''."\n"; + } // Auto refresh page if (GETPOST('autorefresh', 'int') > 0) print ''; @@ -1314,8 +1314,8 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (!defined('DISABLE_FONT_AWSOME')) { print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } print ''."\n"; @@ -1362,12 +1362,12 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr { foreach ($arrayofcss as $cssfile) { - if (preg_match('/^(http|\/\/)/i', $cssfile)) - { - $urltofile = $cssfile; - } else { - $urltofile = dol_buildpath($cssfile, 1); - } + if (preg_match('/^(http|\/\/)/i', $cssfile)) + { + $urltofile = $cssfile; + } else { + $urltofile = dol_buildpath($cssfile, 1); + } print ''."\n".''."\n"; print ''."\n"; } - // jQuery Timepicker - if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { - print ''."\n"; - print ''."\n"; - } - if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) { - // jQuery plugin "mutiselect", "multiple-select", "select2", ... - $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; - print ''."\n"; // We include full because we need the support of containerCssClass - } - if (! defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool - { - print ''."\n"; - } + // jQuery Timepicker + if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { + print ''."\n"; + print ''."\n"; + } + if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) { + // jQuery plugin "mutiselect", "multiple-select", "select2", ... + $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; + print ''."\n"; // We include full because we need the support of containerCssClass + } + if (! defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool + { + print ''."\n"; + } } - if (!$disablejs && !empty($conf->use_javascript_ajax)) { - // CKEditor - if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) - { - print ''."\n"; - $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; - $jsckeditor = 'ckeditor.js'; - if (constant('JS_CKEDITOR')) { - // To use external ckeditor 4 js lib - $pathckeditor = constant('JS_CKEDITOR'); - } - print ''."\n"; - print ''."\n"; - print ''."\n"; - } + if (!$disablejs && !empty($conf->use_javascript_ajax)) { + // CKEditor + if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) + { + print ''."\n"; + $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; + $jsckeditor = 'ckeditor.js'; + if (constant('JS_CKEDITOR')) { + // To use external ckeditor 4 js lib + $pathckeditor = constant('JS_CKEDITOR'); + } + print ''."\n"; + print ''."\n"; + print ''."\n"; + } - // Browser notifications (if NOREQUIREMENU is on, it is mostly a page for popup, so we do not enable notif too. We hide also for public pages). - if (!defined('NOBROWSERNOTIF') && !defined('NOREQUIREMENU') && !defined('NOLOGIN')) - { - $enablebrowsernotif = false; - if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif = true; - if ($conf->browser->layout == 'phone') $enablebrowsernotif = false; - if ($enablebrowsernotif) - { - print ''."\n"; - print ''."\n"; - } - } + // Browser notifications (if NOREQUIREMENU is on, it is mostly a page for popup, so we do not enable notif too. We hide also for public pages). + if (!defined('NOBROWSERNOTIF') && !defined('NOREQUIREMENU') && !defined('NOLOGIN')) + { + $enablebrowsernotif = false; + if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif = true; + if ($conf->browser->layout == 'phone') $enablebrowsernotif = false; + if ($enablebrowsernotif) + { + print ''."\n"; + print ''."\n"; + } + } - // Global js function - print ''."\n"; - print ''."\n"; + // Global js function + print ''."\n"; + print ''."\n"; - // JS forced by modules (relative url starting with /) - if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) - { - $arrayjs = (array) $conf->modules_parts['js']; - foreach ($arrayjs as $modjs => $filesjs) - { - $filesjs = (array) $filesjs; // To be sure filejs is an array - foreach ($filesjs as $jsfile) - { - // jsfile is a relative path - print ''."\n".''."\n"; - } - } - } - // JS forced by page in top_htmlhead (relative url starting with /) - if (is_array($arrayofjs)) - { - print ''."\n"; - foreach ($arrayofjs as $jsfile) - { - if (preg_match('/^(http|\/\/)/i', $jsfile)) - { - print ''."\n"; - } else { - print ''."\n"; - } - } - } - } + // JS forced by modules (relative url starting with /) + if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) + { + $arrayjs = (array) $conf->modules_parts['js']; + foreach ($arrayjs as $modjs => $filesjs) + { + $filesjs = (array) $filesjs; // To be sure filejs is an array + foreach ($filesjs as $jsfile) + { + // jsfile is a relative path + print ''."\n".''."\n"; + } + } + } + // JS forced by page in top_htmlhead (relative url starting with /) + if (is_array($arrayofjs)) + { + print ''."\n"; + foreach ($arrayofjs as $jsfile) + { + if (preg_match('/^(http|\/\/)/i', $jsfile)) + { + print ''."\n"; + } else { + print ''."\n"; + } + } + } + } - if (!empty($head)) print $head."\n"; - if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; + if (!empty($head)) print $head."\n"; + if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; - $parameters = array(); - $result = $hookmanager->executeHooks('addHtmlHeader', $parameters); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; // Replace Title to show + $parameters = array(); + $result = $hookmanager->executeHooks('addHtmlHeader', $parameters); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; // Replace Title to show - print "\n\n"; - } + print "\n\n"; + } - $conf->headerdone = 1; // To tell header was output + $conf->headerdone = 1; // To tell header was output } @@ -1759,99 +1759,99 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead */ function top_menu_user($hideloginname = 0, $urllogout = '') { - global $langs, $conf, $db, $hookmanager, $user; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $langs, $conf, $db, $hookmanager, $user; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - $userImage = $userDropDownImage = ''; - if (!empty($user->photo)) - { - $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); - $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); - } else { - $nophoto = '/public/theme/common/user_anonymous.png'; - if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; - if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; + $userImage = $userDropDownImage = ''; + if (!empty($user->photo)) + { + $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); + $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); + } else { + $nophoto = '/public/theme/common/user_anonymous.png'; + if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; + if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; - $userImage = 'No photo'; - $userDropDownImage = 'No photo'; - } + $userImage = 'No photo'; + $userDropDownImage = 'No photo'; + } - $dropdownBody = ''; - $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; - $dropdownBody .= '
'; + $dropdownBody = ''; + $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; + $dropdownBody .= '
'; - // login infos - if (!empty($user->admin)) { - $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); - } - if (!empty($user->socid)) // Add thirdparty for external users - { - $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($user->socid); - $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company - $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; - } - $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); - $dropdownBody .= '
'.$langs->trans("Type").': '.$type; - $dropdownBody .= '
'.$langs->trans("Status").': '.$user->getLibStatut(0); - $dropdownBody .= '
'; + // login infos + if (!empty($user->admin)) { + $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); + } + if (!empty($user->socid)) // Add thirdparty for external users + { + $thirdpartystatic = new Societe($db); + $thirdpartystatic->fetch($user->socid); + $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company + $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; + } + $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); + $dropdownBody .= '
'.$langs->trans("Type").': '.$type; + $dropdownBody .= '
'.$langs->trans("Status").': '.$user->getLibStatut(0); + $dropdownBody .= '
'; - $dropdownBody .= '
'.$langs->trans("Session").''; - $dropdownBody .= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); - if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; - $dropdownBody .= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); - $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); - $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - $dropdownBody .= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; - $dropdownBody .= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; - $langFlag = picto_from_langcode($langs->getDefaultLang()); - $dropdownBody .= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); - $dropdownBody .= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; - $dropdownBody .= '
'.$langs->trans("Layout").': '.$conf->browser->layout; - $dropdownBody .= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; - if ($conf->browser->layout == 'phone') $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); - if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); - $dropdownBody .= '
'; + $dropdownBody .= '
'.$langs->trans("Session").''; + $dropdownBody .= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + $dropdownBody .= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); + $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $dropdownBody .= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; + $langFlag = picto_from_langcode($langs->getDefaultLang()); + $dropdownBody .= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); + $dropdownBody .= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; + $dropdownBody .= '
'.$langs->trans("Layout").': '.$conf->browser->layout; + $dropdownBody .= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; + if ($conf->browser->layout == 'phone') $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); + if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); + $dropdownBody .= '
'; - // Execute hook - $parameters = array('user'=>$user, 'langs' => $langs); - $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks - if (is_numeric($result)) - { - if ($result == 0) { - $dropdownBody .= $hookmanager->resPrint; // add - } else { - $dropdownBody = $hookmanager->resPrint; // replace - } - } + // Execute hook + $parameters = array('user'=>$user, 'langs' => $langs); + $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks + if (is_numeric($result)) + { + if ($result == 0) { + $dropdownBody .= $hookmanager->resPrint; // add + } else { + $dropdownBody = $hookmanager->resPrint; // replace + } + } - if (empty($urllogout)) { - $urllogout = DOL_URL_ROOT.'/user/logout.php'; - } - $logoutLink = ' '.$langs->trans("Logout").''; - $profilLink = ' '.$langs->trans("Card").''; + if (empty($urllogout)) { + $urllogout = DOL_URL_ROOT.'/user/logout.php'; + } + $logoutLink = ' '.$langs->trans("Logout").''; + $profilLink = ' '.$langs->trans("Card").''; - $profilName = $user->getFullName($langs).' ('.$user->login.')'; + $profilName = $user->getFullName($langs).' ('.$user->login.')'; - if (!empty($user->admin)) { - $profilName = ' '.$profilName; - } + if (!empty($user->admin)) { + $profilName = ' '.$profilName; + } - // Define version to show - $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; + // Define version to show + $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; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $btnUser = ' + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $btnUser = ''; - } + } - if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors - { - $btnUser .= ' + if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors + { + $btnUser .= ' '; - } + } - return $btnUser; + return $btnUser; } /** @@ -2160,24 +2160,24 @@ function top_menu_quickadd() */ function top_menu_bookmark() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; $html = ''; - // Define $bookmarks + // Define $bookmarks if (empty($conf->bookmark->enabled) || empty($user->rights->bookmark->lire)) return $html; if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors - { - include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; - $langs->load("bookmarks"); + { + include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; + $langs->load("bookmarks"); - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $html .= ''; - } else { - $html .= ' + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $html .= ''; + } else { + $html .= ''; - } elseif ($conf->use_javascript_ajax && !empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { - $searchform = '
'; - $searchform .= '' . "\n"; - $searchform .= '
'; - } - } + $searchform .= ''; + } + } // Left column print ''."\n"; @@ -2474,37 +2474,37 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; + $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; $bugbaseurl .= '&title='; $bugbaseurl .= urlencode("Bug: "); - $bugbaseurl .= '&body='; - $bugbaseurl .= urlencode("# Instructions\n"); - $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); - $bugbaseurl .= urlencode("*Please:*\n"); - $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); - $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("# Bug\n"); - $bugbaseurl .= urlencode("[*Short description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Environment\n"); - $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); - $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); - $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); - $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); - $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); - $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Expected and actual behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); - $bugbaseurl .= urlencode("[*Files*]\n"); - $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= '&body='; + $bugbaseurl .= urlencode("# Instructions\n"); + $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); + $bugbaseurl .= urlencode("*Please:*\n"); + $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); + $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("# Bug\n"); + $bugbaseurl .= urlencode("[*Short description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Environment\n"); + $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); + $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); + $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); + $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); + $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); + $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Expected and actual behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); + $bugbaseurl .= urlencode("[*Files*]\n"); + $bugbaseurl .= urlencode("\n"); // Execute hook printBugtrackInfo @@ -2563,35 +2563,35 @@ function main_area($title = '') if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED)); - // Permit to add user company information on each printed document by set SHOW_SOCINFO_ON_PRINT - if (!empty($conf->global->SHOW_SOCINFO_ON_PRINT) && GETPOST('optioncss', 'aZ09') == 'print' && empty(GETPOST('disable_show_socinfo_on_print', 'az09'))) - { - global $hookmanager; - $hookmanager->initHooks(array('showsocinfoonprint')); - $parameters = array(); - $reshook = $hookmanager->executeHooks('showSocinfoOnPrint', $parameters); - if (empty($reshook)) - { - print ''."\n"; - print '
'."\n"; - print '
'.$langs->trans("Period").''.get_date_range($expensereport->date_debut, $expensereport->date_fin, "", $langs, 0).'
'.$langs->trans("Amount").''.price($expensereport->total_ttc, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('AccountToDebit').''; - $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : $expensereport->accountid, "accountid", 0, '', 2); // Show open bank account list - print '
'.$langs->trans('AccountToDebit').''; + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : $expensereport->accountid, "accountid", 0, '', 2); // Show open bank account list + print '
'."\n"; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - if (!empty($conf->global->MAIN_INFO_SOCIETE_TEL)) print ''; - if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL)) print ''; - if (!empty($conf->global->MAIN_INFO_SOCIETE_WEB)) print ''; - print ''; - print '
'; - if ($conf->global->MAIN_SHOW_LOGO && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($conf->global->MAIN_INFO_SOCIETE_LOGO)) { - print ''; - } - print '
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM).'
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ADDRESS).'
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP).' '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN).'
'.$langs->trans("Phone").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'
'.$langs->trans("Email").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'
'.$langs->trans("Web").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'
'."\n"; - print ''."\n"; - print ''."\n"; - } - } + // Permit to add user company information on each printed document by set SHOW_SOCINFO_ON_PRINT + if (!empty($conf->global->SHOW_SOCINFO_ON_PRINT) && GETPOST('optioncss', 'aZ09') == 'print' && empty(GETPOST('disable_show_socinfo_on_print', 'az09'))) + { + global $hookmanager; + $hookmanager->initHooks(array('showsocinfoonprint')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('showSocinfoOnPrint', $parameters); + if (empty($reshook)) + { + print ''."\n"; + print '
'."\n"; + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + if (!empty($conf->global->MAIN_INFO_SOCIETE_TEL)) print ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL)) print ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_WEB)) print ''; + print ''; + print '
'; + if ($conf->global->MAIN_SHOW_LOGO && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($conf->global->MAIN_INFO_SOCIETE_LOGO)) { + print ''; + } + print '
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM).'
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ADDRESS).'
'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP).' '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN).'
'.$langs->trans("Phone").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'
'.$langs->trans("Email").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'
'.$langs->trans("Web").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'
'."\n"; + print '
'."\n"; + print ''."\n"; + } + } } @@ -2906,5 +2906,5 @@ if (!function_exists("llxFooter")) print "\n"; print "\n"; - } + } } diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index f0833fd5f3e..00db8797a1f 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -42,15 +42,15 @@ function paypaladmin_prepare_head() $object = new stdClass(); - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'paypaladmin'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'paypaladmin', 'remove'); - return $head; + return $head; } @@ -67,14 +67,14 @@ function showPaypalPaymentUrl($type, $ref) global $conf, $langs; $langs->load("paypal"); - $langs->load("paybox"); - $servicename = 'PayPal'; - $out = '

'; - $out .= img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; - $url = getPaypalPaymentUrl(0, $type, $ref); - $out .= ''; - $out .= ajax_autoselect("paypalurl", 0); - return $out; + $langs->load("paybox"); + $servicename = 'PayPal'; + $out = '

'; + $out .= img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; + $url = getPaypalPaymentUrl(0, $type, $ref); + $out .= ''; + $out .= ajax_autoselect("paypalurl", 0); + return $out; } @@ -94,88 +94,88 @@ function getPaypalPaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $ref = str_replace(' ', '', $ref); - if ($type == 'free') - { - $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); - if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else $out .= '&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - } - } - if ($type == 'order') - { - $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode ? '' : ''); - if ($mode == 1) $out .= 'order_ref'; - if ($mode == 0) $out .= urlencode($ref); - $out .= ($mode ? '' : ''); - if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else { - $out .= '&securekey='.($mode ? '' : ''); - if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); - $out .= ($mode ? '' : ''); - } - } - } - if ($type == 'invoice') - { - $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode ? '' : ''); - if ($mode == 1) $out .= 'invoice_ref'; - if ($mode == 0) $out .= urlencode($ref); - $out .= ($mode ? '' : ''); - if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else { - $out .= '&securekey='.($mode ? '' : ''); - if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); - $out .= ($mode ? '' : ''); - } - } - } - if ($type == 'contractline') - { - $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode ? '' : ''); - if ($mode == 1) $out .= 'contractline_ref'; - if ($mode == 0) $out .= urlencode($ref); - $out .= ($mode ? '' : ''); - if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else { - $out .= '&securekey='.($mode ? '' : ''); - if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); - $out .= ($mode ? '' : ''); - } - } - } - if ($type == 'membersubscription') - { - $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); - if ($mode == 1) $out .= 'member_ref'; - if ($mode == 0) $out .= urlencode($ref); - $out .= ($mode ? '' : ''); - if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else { - $out .= '&securekey='.($mode ? '' : ''); - if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); - $out .= ($mode ? '' : ''); - } - } - } + if ($type == 'free') + { + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else $out .= '&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } + } + if ($type == 'order') + { + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'order_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else { + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); + } + } + } + if ($type == 'invoice') + { + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'invoice_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else { + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); + } + } + } + if ($type == 'contractline') + { + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'contractline_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else { + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); + } + } + } + if ($type == 'membersubscription') + { + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'member_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else { + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); + } + } + } - // For multicompany - $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + // For multicompany + $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities - return $out; + return $out; } @@ -192,93 +192,93 @@ function getPaypalPaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag */ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag) { - //declaring of global variables - global $conf, $langs; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - global $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum; - global $email, $desc; + global $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum; + global $email, $desc; - //'------------------------------------ - //' Calls the SetExpressCheckout API call - //' - //'------------------------------------------------- + //'------------------------------------ + //' Calls the SetExpressCheckout API call + //' + //'------------------------------------------------- - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; - $solutionType = 'Sole'; - $landingPage = 'Billing'; - // For payment with Paypal only - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') - { - $solutionType = 'Mark'; - $landingPage = 'Login'; - } - // For payment with Credit card or Paypal - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') - { - $solutionType = 'Sole'; - $landingPage = 'Billing'; - } - // For payment with Credit card - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') - { - $solutionType = 'Sole'; - $landingPage = 'Billing'; - } + $solutionType = 'Sole'; + $landingPage = 'Billing'; + // For payment with Paypal only + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + $solutionType = 'Mark'; + $landingPage = 'Login'; + } + // For payment with Credit card or Paypal + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + $solutionType = 'Sole'; + $landingPage = 'Billing'; + } + // For payment with Credit card + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') + { + $solutionType = 'Sole'; + $landingPage = 'Billing'; + } - dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); - $resArray = callSetExpressCheckout( - $paymentAmount, - $currencyCodeType, - $paymentType, - $returnURL, - $cancelURL, - $tag, - $solutionType, - $landingPage, - $shipToName, - $shipToStreet, - $shipToCity, - $shipToState, - $shipToCountryCode, - $shipToZip, - $shipToStreet2, - $phoneNum, - $email, - $desc - ); + dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); + $resArray = callSetExpressCheckout( + $paymentAmount, + $currencyCodeType, + $paymentType, + $returnURL, + $cancelURL, + $tag, + $solutionType, + $landingPage, + $shipToName, + $shipToStreet, + $shipToCity, + $shipToState, + $shipToCountryCode, + $shipToZip, + $shipToStreet2, + $phoneNum, + $email, + $desc + ); - $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { - $token = $resArray["TOKEN"]; + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") + { + $token = $resArray["TOKEN"]; - // Redirect to paypal.com here - $payPalURL = $API_Url.$token; - header("Location: ".$payPalURL); - exit; - } else { - //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"]); + // Redirect to paypal.com here + $payPalURL = $API_Url.$token; + header("Location: ".$payPalURL); + exit; + } else { + //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"]); - if ($ErrorCode == 10729) - { - $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; - } else { - $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
\n"; - $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n"; - $mesg .= $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
\n"; - $mesg .= $langs->trans('ErrorCode').": ".$ErrorCode."
\n"; - $mesg .= $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
\n"; - } + if ($ErrorCode == 10729) + { + $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + } else { + $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
\n"; + $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n"; + $mesg .= $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
\n"; + $mesg .= $langs->trans('ErrorCode').": ".$ErrorCode."
\n"; + $mesg .= $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
\n"; + } - return $mesg; - } + return $mesg; + } } /** @@ -324,103 +324,103 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, */ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum, $email = '', $desc = '') { - //------------------------------------------------------------------------------------------------------------------------------------ - // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation + //------------------------------------------------------------------------------------------------------------------------------------ + // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation - //declaring of global variables - global $conf, $langs, $mysoc; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs, $mysoc; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - $nvpstr = ''; - //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call - $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL); - $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL); - if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) - { - $nvpstr = $nvpstr."&ALLOWNOTE=0"; - } - if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) - { - $nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted - } else { - $nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) - } - $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType); - $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage); - if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) - { - $nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number - } + $nvpstr = ''; + //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call + $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL); + $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL); + if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) + { + $nvpstr = $nvpstr."&ALLOWNOTE=0"; + } + if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) + { + $nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted + } else { + $nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) + } + $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType); + $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage); + if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) + { + $nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number + } - $paypalprefix = 'PAYMENTREQUEST_0_'; - //$paypalprefix = ''; + $paypalprefix = 'PAYMENTREQUEST_0_'; + //$paypalprefix = ''; if (!empty($paypalprefix) && $paymentType == 'Sole') $paymentType = 'Sale'; $nvpstr = $nvpstr."&AMT=".urlencode($paymentAmount); // Total for all elements - $nvpstr = $nvpstr."&".$paypalprefix."INVNUM=".urlencode($tag); - $nvpstr = $nvpstr."&".$paypalprefix."AMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr."&".$paypalprefix."ITEMAMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr."&".$paypalprefix."PAYMENTACTION=".urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION - $nvpstr = $nvpstr."&".$paypalprefix."CURRENCYCODE=".urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE + $nvpstr = $nvpstr."&".$paypalprefix."INVNUM=".urlencode($tag); + $nvpstr = $nvpstr."&".$paypalprefix."AMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."ITEMAMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."PAYMENTACTION=".urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr."&".$paypalprefix."CURRENCYCODE=".urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE - $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; - $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); - $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); - $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTONAME=".urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET=".urlencode($shipToStreet); // - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET2=".urlencode($shipToStreet2); - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCITY=".urlencode($shipToCity); - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTATE=".urlencode($shipToState); - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode); - $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip); - $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum); - if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL - if (!empty($desc)) $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTONAME=".urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET=".urlencode($shipToStreet); // + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET2=".urlencode($shipToStreet2); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCITY=".urlencode($shipToCity); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTATE=".urlencode($shipToState); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip); + $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum); + if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + if (!empty($desc)) $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC - if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) - { - global $dolibarr_main_url_root; + if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) + { + global $dolibarr_main_url_root; - // 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 $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 - $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); - $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo); - } - if (!empty($conf->global->PAYPAL_BRANDNAME)) - { - $nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME - } - if (!empty($conf->global->PAYPAL_NOTETOBUYER)) - { - $nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER - } + $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); + $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo); + } + if (!empty($conf->global->PAYPAL_BRANDNAME)) + { + $nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME + } + if (!empty($conf->global->PAYPAL_NOTETOBUYER)) + { + $nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER + } $_SESSION["FinalPaymentAmt"] = $paymentAmount; - $_SESSION["currencyCodeType"] = $currencyCodeType; - $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' - $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip + $_SESSION["currencyCodeType"] = $currencyCodeType; + $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' + $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip - //'--------------------------------------------------------------------------------------------------------------- - //' Make the API call to PayPal - //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. - //' If an error occured, show the resulting errors - //'--------------------------------------------------------------------------------------------------------------- - $resArray = hash_call("SetExpressCheckout", $nvpstr); - $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { - $token = urldecode($resArray["TOKEN"]); - $_SESSION['TOKEN'] = $token; - } + //'--------------------------------------------------------------------------------------------------------------- + //' Make the API call to PayPal + //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + //' If an error occured, show the resulting errors + //'--------------------------------------------------------------------------------------------------------------- + $resArray = hash_call("SetExpressCheckout", $nvpstr); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") + { + $token = urldecode($resArray["TOKEN"]); + $_SESSION['TOKEN'] = $token; + } - return $resArray; + return $resArray; } /** @@ -431,39 +431,39 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, */ function getDetails($token) { - //'-------------------------------------------------------------- - //' At this point, the buyer has completed authorizing the payment - //' at PayPal. The function will call PayPal to obtain the details - //' of the authorization, incuding any shipping information of the - //' buyer. Remember, the authorization is not a completed transaction - //' at this state - the buyer still needs an additional step to finalize - //' the transaction - //'-------------------------------------------------------------- + //'-------------------------------------------------------------- + //' At this point, the buyer has completed authorizing the payment + //' at PayPal. The function will call PayPal to obtain the details + //' of the authorization, incuding any shipping information of the + //' buyer. Remember, the authorization is not a completed transaction + //' at this state - the buyer still needs an additional step to finalize + //' the transaction + //'-------------------------------------------------------------- - //declaring of global variables - global $conf, $langs; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - //'--------------------------------------------------------------------------- - //' Build a second API request to PayPal, using the token as the - //' ID to get the details on the payment authorization - //'--------------------------------------------------------------------------- - $nvpstr = "&TOKEN=".$token; + //'--------------------------------------------------------------------------- + //' Build a second API request to PayPal, using the token as the + //' ID to get the details on the payment authorization + //'--------------------------------------------------------------------------- + $nvpstr = "&TOKEN=".$token; - //'--------------------------------------------------------------------------- - //' Make the API call and store the results in an array. - //' If the call was a success, show the authorization details, and provide - //' an action to complete the payment. - //' If failed, show the error - //'--------------------------------------------------------------------------- - $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); - $ack = strtoupper($resArray["ACK"]); - if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") - { - $_SESSION['payer_id'] = $resArray['PAYERID']; - } - return $resArray; + //'--------------------------------------------------------------------------- + //' Make the API call and store the results in an array. + //' If the call was a success, show the authorization details, and provide + //' an action to complete the payment. + //' If failed, show the error + //'--------------------------------------------------------------------------- + $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") + { + $_SESSION['payer_id'] = $resArray['PAYERID']; + } + return $resArray; } @@ -481,37 +481,37 @@ function getDetails($token) */ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag) { - /* Gather the information to make the final call to + /* Gather the information to make the final call to finalize the PayPal payment. The variable nvpstr holds the name value pairs */ - //declaring of global variables - global $conf, $langs; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - $nvpstr = ''; - $nvpstr .= '&TOKEN='.urlencode($token); - $nvpstr .= '&PAYERID='.urlencode($payerID); - $nvpstr .= '&PAYMENTACTION='.urlencode($paymentType); - $nvpstr .= '&AMT='.urlencode($FinalPaymentAmt); - $nvpstr .= '&CURRENCYCODE='.urlencode($currencyCodeType); - $nvpstr .= '&IPADDRESS='.urlencode($ipaddress); - $nvpstr .= '&INVNUM='.urlencode($tag); + $nvpstr = ''; + $nvpstr .= '&TOKEN='.urlencode($token); + $nvpstr .= '&PAYERID='.urlencode($payerID); + $nvpstr .= '&PAYMENTACTION='.urlencode($paymentType); + $nvpstr .= '&AMT='.urlencode($FinalPaymentAmt); + $nvpstr .= '&CURRENCYCODE='.urlencode($currencyCodeType); + $nvpstr .= '&IPADDRESS='.urlencode($ipaddress); + $nvpstr .= '&INVNUM='.urlencode($tag); - /* Make the call to PayPal to finalize payment + /* Make the call to PayPal to finalize payment If an error occured, show the resulting errors */ - $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); + $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); - /* Display the API response back to the browser. + /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ - $ack = strtoupper($resArray["ACK"]); + $ack = strtoupper($resArray["ACK"]); - return $resArray; + return $resArray; } /** @@ -575,20 +575,20 @@ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCar */ function hash_call($methodName, $nvpStr) { - //declaring of global variables - global $conf, $langs; - global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT, $PROXY_USER, $PROXY_PASS; - global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; + //declaring of global variables + global $conf, $langs; + global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT, $PROXY_USER, $PROXY_PASS; + global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; - // TODO problem with triggers - $API_version = "98.0"; + // TODO problem with triggers + $API_version = "98.0"; if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' { - $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; - $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; + $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; + $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; } else { - $API_Endpoint = "https://api-3t.paypal.com/nvp"; - $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; + $API_Endpoint = "https://api-3t.paypal.com/nvp"; + $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; } // Clean parameters @@ -602,73 +602,73 @@ function hash_call($methodName, $nvpStr) if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; // TODO END problem with triggers - dol_syslog("Paypal API endpoint ".$API_Endpoint); + dol_syslog("Paypal API endpoint ".$API_Endpoint); - //setting the curl parameters. - $ch = curl_init(); + //setting the curl parameters. + $ch = curl_init(); - /*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."
"; + /*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."
"; print $USE_PROXY."-".$gv_ApiErrorURL."
"; print $nvpStr; exit;*/ - curl_setopt($ch, CURLOPT_URL, $API_Endpoint); - curl_setopt($ch, CURLOPT_VERBOSE, 1); - // TLSv1 by default or change to TLSv1.2 in module configuration - curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION) ? 1 : $conf->global->PAYPAL_SSLVERSION)); + curl_setopt($ch, CURLOPT_URL, $API_Endpoint); + curl_setopt($ch, CURLOPT_VERBOSE, 1); + // TLSv1 by default or change to TLSv1.2 in module configuration + curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION) ? 1 : $conf->global->PAYPAL_SSLVERSION)); - //turning off the server and peer verification(TrustManager Concept). - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + //turning off the server and peer verification(TrustManager Concept). + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); - //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled. - if ($USE_PROXY) - { - dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); - //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 - curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); - if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); - } + //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled. + if ($USE_PROXY) + { + dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); + //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); + if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); + } - //NVPRequest for submitting to server - $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($API_version)."&PWD=".urlencode($PAYPAL_API_PASSWORD)."&USER=".urlencode($PAYPAL_API_USER)."&SIGNATURE=".urlencode($PAYPAL_API_SIGNATURE).$nvpStr; - $nvpreq .= "&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); - //$nvpreq.="&BRANDNAME=".urlencode(); // Override merchant name - //$nvpreq.="&NOTIFYURL=".urlencode(); // For Instant Payment Notification url + //NVPRequest for submitting to server + $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($API_version)."&PWD=".urlencode($PAYPAL_API_PASSWORD)."&USER=".urlencode($PAYPAL_API_USER)."&SIGNATURE=".urlencode($PAYPAL_API_SIGNATURE).$nvpStr; + $nvpreq .= "&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); + //$nvpreq.="&BRANDNAME=".urlencode(); // Override merchant name + //$nvpreq.="&NOTIFYURL=".urlencode(); // For Instant Payment Notification url - dol_syslog("Paypal API hash_call nvpreq=".$nvpreq); + dol_syslog("Paypal API hash_call nvpreq=".$nvpreq); - //setting the nvpreq as POST FIELD to curl - curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); + //setting the nvpreq as POST FIELD to curl + curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); - //getting response from server - $response = curl_exec($ch); + //getting response from server + $response = curl_exec($ch); - $nvpReqArray = deformatNVP($nvpreq); - $_SESSION['nvpReqArray'] = $nvpReqArray; + $nvpReqArray = deformatNVP($nvpreq); + $_SESSION['nvpReqArray'] = $nvpReqArray; - //convrting NVPResponse to an Associative Array - dol_syslog("Paypal API hash_call Response nvpresp=".$response); - $nvpResArray = deformatNVP($response); + //convrting NVPResponse to an Associative Array + dol_syslog("Paypal API hash_call Response nvpresp=".$response); + $nvpResArray = deformatNVP($response); - if (curl_errno($ch)) { - // moving to display page to display curl errors - $_SESSION['curl_error_no'] = curl_errno($ch); - $_SESSION['curl_error_msg'] = curl_error($ch); + if (curl_errno($ch)) { + // moving to display page to display curl errors + $_SESSION['curl_error_no'] = curl_errno($ch); + $_SESSION['curl_error_msg'] = curl_error($ch); - //Execute the Error handling module to display errors. - } else { - //closing the curl - curl_close($ch); - } + //Execute the Error handling module to display errors. + } else { + //closing the curl + curl_close($ch); + } - return $nvpResArray; + return $nvpResArray; } @@ -681,24 +681,24 @@ function hash_call($methodName, $nvpStr) */ function deformatNVP($nvpstr) { - $intial = 0; - $nvpArray = array(); + $intial = 0; + $nvpArray = array(); - while (strlen($nvpstr)) - { - //postion of Key - $keypos = strpos($nvpstr, '='); - //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); + while (strlen($nvpstr)) + { + //postion of Key + $keypos = strpos($nvpstr, '='); + //position of value + $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); - /*getting the Key and Value values and storing in a Associative Array*/ - $keyval = substr($nvpstr, $intial, $keypos); - $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); - //decoding the respose - $nvpArray[urldecode($keyval)] = urldecode($valval); - $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); - } - return $nvpArray; + /*getting the Key and Value values and storing in a Associative Array*/ + $keyval = substr($nvpstr, $intial, $keypos); + $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); + //decoding the respose + $nvpArray[urldecode($keyval)] = urldecode($valval); + $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); + } + return $nvpArray; } /** diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 24a6d7d36b8..d4df28e0902 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -79,31 +79,31 @@ $htmlother = new FormOther($db); $object = new Product($db); if (!$id && empty($ref)) { - llxHeader("", $langs->trans("ProductStatistics")); + llxHeader("", $langs->trans("ProductStatistics")); - $type = GETPOST('type', 'int'); + $type = GETPOST('type', 'int'); $helpurl = ''; - if ($type == '0') { - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - //$title=$langs->trans("StatisticsOfProducts"); - $title = $langs->trans("Statistics"); - } elseif ($type == '1') { - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - //$title=$langs->trans("StatisticsOfServices"); - $title = $langs->trans("Statistics"); - } else { - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - //$title=$langs->trans("StatisticsOfProductsOrServices"); - $title = $langs->trans("Statistics"); - } + if ($type == '0') { + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + //$title=$langs->trans("StatisticsOfProducts"); + $title = $langs->trans("Statistics"); + } elseif ($type == '1') { + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfServices"); + $title = $langs->trans("Statistics"); + } else { + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); + $title = $langs->trans("Statistics"); + } - $picto = 'product'; - if ($type == 1) $picto = 'service'; + $picto = 'product'; + if ($type == 1) $picto = 'service'; - print load_fiche_titre($title, $mesg, $picto); + print load_fiche_titre($title, $mesg, $picto); } else { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref); $title = $langs->trans('ProductServiceCard'); $helpurl = ''; @@ -176,12 +176,12 @@ if ($result || empty($id)) { // Tag if ($conf->categorie->enabled) { - print '
'.$langs->trans("Categories").''; - //$moreforfilter.='
'; - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); - //$moreforfilter.='
'; - print $moreforfilter; - print '
'.$langs->trans("Categories").''; + //$moreforfilter.='
'; + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + //$moreforfilter.='
'; + print $moreforfilter; + print '
'.$langs->trans("Year").''; $arrayyears = array(); for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) { - $arrayyears[$year] = $year; + $arrayyears[$year] = $year; } if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -299,16 +299,16 @@ if ($result || empty($id)) { if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) { // TODO Load cachefile $graphfiles[$key]['file'] } else { - $morefilters = ''; - if ($search_categ > 0) { - $categ = new Categorie($db); - $categ->fetch($search_categ); - $listofprodids = $categ->getObjectsInCateg('product', 1); - $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; - } - if ($search_categ == -2) { - $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; - } + $morefilters = ''; + if ($search_categ > 0) { + $categ = new Categorie($db); + $categ->fetch($search_categ); + $listofprodids = $categ->getObjectsInCateg('product', 1); + $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; + } + if ($search_categ == -2) { + $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; + } if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); if ($key == 'orders') $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); @@ -371,10 +371,10 @@ if ($result || empty($id)) { // Date generation if ($graphfiles[$key]['output'] && !$px->isGraphKo()) { - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); - else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); + else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); } else { - $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); + $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); } $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8a4697be2a1..0567c34a759 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -41,14 +41,14 @@ class MouvementStock extends CommonObject public $table_element = 'stock_mouvement'; - /** - * @var int ID product - */ + /** + * @var int ID product + */ public $product_id; - /** - * @var int ID warehouse - */ + /** + * @var int ID warehouse + */ public $warehouse_id; public $qty; @@ -65,18 +65,18 @@ class MouvementStock extends CommonObject public $price; /** - * @var int ID user author - */ + * @var int ID user author + */ public $fk_user_author; /** - * @var string stock movements label - */ - public $label; + * @var string stock movements label + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_origin; public $origintype; @@ -113,11 +113,11 @@ class MouvementStock extends CommonObject - /** + /** * Constructor * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -147,10 +147,10 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null or product id does not exists, >0 if OK */ - public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) { - // phpcs:disable - global $conf, $langs; + // phpcs:disable + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; @@ -227,114 +227,114 @@ class MouvementStock extends CommonObject // If not found, we add record $sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".MAIN_DB_PREFIX."product_lot as pb"; $sql .= " WHERE pb.fk_product = ".$fk_product." AND pb.batch = '".$this->db->escape($batch)."'"; - dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - if ($num > 0) - { - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - if ($obj->eatby) - { - if ($eatby) - { - $tmparray = dol_getdate($eatby, true); - $eatbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility - { - // If found and eatby/sellby defined into table and provided and differs, return error - $langs->load("stocks"); - $this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatbywithouthour, 'dayhour')); - dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR); - $this->db->rollback(); - return -3; - } - } else { - $eatby = $obj->eatby; // If found and eatby/sellby defined into table and not provided, we take value from table - } - } else { - if ($eatby) // If found and eatby/sellby not defined into table and provided, we update table - { - $productlot = new Productlot($this->db); - $result = $productlot->fetch($obj->rowid); - $productlot->eatby = $eatby; - $result = $productlot->update($user); - if ($result <= 0) - { - $this->error = $productlot->error; - $this->errors = $productlot->errors; - $this->db->rollback(); - return -5; - } - } - } - if ($obj->sellby) - { - if ($sellby) - { - $tmparray = dol_getdate($sellby, true); - $sellbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility - { - // If found and eatby/sellby defined into table and provided and differs, return error - $this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)); - dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR); - $this->db->rollback(); - return -3; - } - } else { - $sellby = $obj->sellby; // If found and eatby/sellby defined into table and not provided, we take value from table - } - } - else - { - if ($sellby) // If found and eatby/sellby not defined into table and provided, we update table - { - $productlot = new Productlot($this->db); - $result = $productlot->fetch($obj->rowid); - $productlot->sellby = $sellby; - $result = $productlot->update($user); - if ($result <= 0) - { - $this->error = $productlot->error; - $this->errors = $productlot->errors; - $this->db->rollback(); - return -5; - } - } - } - - $i++; - } - } - else // If not found, we add record - { - $productlot = new Productlot($this->db); - $productlot->entity = $conf->entity; - $productlot->fk_product = $fk_product; - $productlot->batch = $batch; - // If we are here = first time we manage this batch, so we used dates provided by users to create lot - $productlot->eatby = $eatby; - $productlot->sellby = $sellby; - $result = $productlot->create($user); - if ($result <= 0) - { - $this->error = $productlot->error; - $this->errors = $productlot->errors; - $this->db->rollback(); - return -4; - } - } - } - else + dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { - dol_print_error($this->db); - $this->db->rollback(); - return -1; + $num = $this->db->num_rows($resql); + $i = 0; + if ($num > 0) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($obj->eatby) + { + if ($eatby) + { + $tmparray = dol_getdate($eatby, true); + $eatbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility + { + // If found and eatby/sellby defined into table and provided and differs, return error + $langs->load("stocks"); + $this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatbywithouthour, 'dayhour')); + dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR); + $this->db->rollback(); + return -3; + } + } else { + $eatby = $obj->eatby; // If found and eatby/sellby defined into table and not provided, we take value from table + } + } else { + if ($eatby) // If found and eatby/sellby not defined into table and provided, we update table + { + $productlot = new Productlot($this->db); + $result = $productlot->fetch($obj->rowid); + $productlot->eatby = $eatby; + $result = $productlot->update($user); + if ($result <= 0) + { + $this->error = $productlot->error; + $this->errors = $productlot->errors; + $this->db->rollback(); + return -5; + } + } + } + if ($obj->sellby) + { + if ($sellby) + { + $tmparray = dol_getdate($sellby, true); + $sellbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility + { + // If found and eatby/sellby defined into table and provided and differs, return error + $this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)); + dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR); + $this->db->rollback(); + return -3; + } + } else { + $sellby = $obj->sellby; // If found and eatby/sellby defined into table and not provided, we take value from table + } + } + else + { + if ($sellby) // If found and eatby/sellby not defined into table and provided, we update table + { + $productlot = new Productlot($this->db); + $result = $productlot->fetch($obj->rowid); + $productlot->sellby = $sellby; + $result = $productlot->update($user); + if ($result <= 0) + { + $this->error = $productlot->error; + $this->errors = $productlot->errors; + $this->db->rollback(); + return -5; + } + } + } + + $i++; + } + } + else // If not found, we add record + { + $productlot = new Productlot($this->db); + $productlot->entity = $conf->entity; + $productlot->fk_product = $fk_product; + $productlot->batch = $batch; + // If we are here = first time we manage this batch, so we used dates provided by users to create lot + $productlot->eatby = $eatby; + $productlot->sellby = $sellby; + $result = $productlot->create($user); + if ($result <= 0) + { + $this->error = $productlot->error; + $this->errors = $productlot->errors; + $this->db->rollback(); + return -4; + } + } + } + else + { + dol_print_error($this->db); + $this->db->rollback(); + return -1; } } @@ -346,41 +346,41 @@ class MouvementStock extends CommonObject // Note that qty should be > 0 with type 0 or 3, < 0 with type 1 or 2. if ($movestock && $qty < 0 && empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) { - if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch) - { - $foundforbatch = 0; - $qtyisnotenough = 0; - foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) - { - if ($batch != $batchcursor) continue; - $foundforbatch = 1; - if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty; - break; - } - if (!$foundforbatch || $qtyisnotenough) - { - $langs->load("stocks"); - include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; - $tmpwarehouse = new Entrepot($this->db); - $tmpwarehouse->fetch($entrepot_id); + if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch) + { + $foundforbatch = 0; + $qtyisnotenough = 0; + foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) + { + if ($batch != $batchcursor) continue; + $foundforbatch = 1; + if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty; + break; + } + if (!$foundforbatch || $qtyisnotenough) + { + $langs->load("stocks"); + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + $tmpwarehouse = new Entrepot($this->db); + $tmpwarehouse->fetch($entrepot_id); - $this->error = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref); - $this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref); - $this->db->rollback(); - return -8; - } - } - else - { - if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty)) - { - $langs->load("stocks"); - $this->error = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; - $this->errors[] = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; - $this->db->rollback(); - return -8; - } - } + $this->error = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref); + $this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref); + $this->db->rollback(); + return -8; + } + } + else + { + if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty)) + { + $langs->load("stocks"); + $this->error = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; + $this->errors[] = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; + $this->db->rollback(); + return -8; + } + } } if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after @@ -533,10 +533,10 @@ class MouvementStock extends CommonObject { if ($id_product_batch > 0) { - $result = $this->createBatch($id_product_batch, $qty); + $result = $this->createBatch($id_product_batch, $qty); } else { - $param_batch = array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch); - $result = $this->createBatch($param_batch, $qty); + $param_batch = array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch); + $result = $this->createBatch($param_batch, $qty); } if ($result < 0) $error++; } @@ -548,7 +548,7 @@ class MouvementStock extends CommonObject // $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; // $sql.= " WHERE rowid = ".$fk_product; - // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql + // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.","; $sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql .= " WHERE rowid = ".$fk_product; @@ -562,11 +562,11 @@ class MouvementStock extends CommonObject } } - // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine - // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; - $resql = $this->db->query($sql); - // We do not test error, it can fails if there is child in batch details + // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine + // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; + $resql = $this->db->query($sql); + // We do not test error, it can fails if there is child in batch details } // Add movement for sub products (recursive call) @@ -577,10 +577,10 @@ class MouvementStock extends CommonObject if ($movestock && !$error) { - // Call trigger - $result = $this->call_trigger('STOCK_MOVEMENT', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('STOCK_MOVEMENT', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) @@ -607,80 +607,80 @@ class MouvementStock extends CommonObject */ public function fetch($id) { - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= " t.tms,"; - $sql .= " t.datem,"; - $sql .= " t.fk_product,"; - $sql .= " t.fk_entrepot,"; - $sql .= " t.value,"; - $sql .= " t.price,"; - $sql .= " t.type_mouvement,"; - $sql .= " t.fk_user_author,"; - $sql .= " t.label,"; - $sql .= " t.fk_origin,"; - $sql .= " t.origintype,"; - $sql .= " t.inventorycode,"; - $sql .= " t.batch,"; - $sql .= " t.eatby,"; - $sql .= " t.sellby,"; - $sql .= " t.fk_projet as fk_project"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE 1 = 1'; - //if (null !== $ref) { - //$sql .= ' AND t.ref = ' . '\'' . $ref . '\''; - //} else { - $sql .= ' AND t.rowid = '.$id; - //} + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + $sql .= " t.tms,"; + $sql .= " t.datem,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.value,"; + $sql .= " t.price,"; + $sql .= " t.type_mouvement,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.label,"; + $sql .= " t.fk_origin,"; + $sql .= " t.origintype,"; + $sql .= " t.inventorycode,"; + $sql .= " t.batch,"; + $sql .= " t.eatby,"; + $sql .= " t.sellby,"; + $sql .= " t.fk_projet as fk_project"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE 1 = 1'; + //if (null !== $ref) { + //$sql .= ' AND t.ref = ' . '\'' . $ref . '\''; + //} else { + $sql .= ' AND t.rowid = '.$id; + //} - $resql = $this->db->query($sql); - if ($resql) { - $numrows = $this->db->num_rows($resql); - if ($numrows) { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - $this->product_id = $obj->fk_product; - $this->warehouse_id = $obj->fk_entrepot; - $this->qty = $obj->value; - $this->type = $obj->type_mouvement; + $this->product_id = $obj->fk_product; + $this->warehouse_id = $obj->fk_entrepot; + $this->qty = $obj->value; + $this->type = $obj->type_mouvement; - $this->tms = $this->db->jdate($obj->tms); - $this->datem = $this->db->jdate($obj->datem); - $this->price = $obj->price; - $this->fk_user_author = $obj->fk_user_author; - $this->label = $obj->label; - $this->fk_origin = $obj->fk_origin; - $this->origintype = $obj->origintype; - $this->inventorycode = $obj->inventorycode; - $this->batch = $obj->batch; - $this->eatby = $this->db->jdate($obj->eatby); - $this->sellby = $this->db->jdate($obj->sellby); - $this->fk_project = $obj->fk_project; - } + $this->tms = $this->db->jdate($obj->tms); + $this->datem = $this->db->jdate($obj->datem); + $this->price = $obj->price; + $this->fk_user_author = $obj->fk_user_author; + $this->label = $obj->label; + $this->fk_origin = $obj->fk_origin; + $this->origintype = $obj->origintype; + $this->inventorycode = $obj->inventorycode; + $this->batch = $obj->batch; + $this->eatby = $this->db->jdate($obj->eatby); + $this->sellby = $this->db->jdate($obj->sellby); + $this->fk_project = $obj->fk_project; + } - // Retrieve all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); - // $this->fetch_lines(); + // $this->fetch_lines(); - $this->db->free($resql); + $this->db->free($resql); - if ($numrows) { - return 1; - } else { - return 0; - } - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); - return -1; - } + return -1; + } } @@ -774,7 +774,7 @@ class MouvementStock extends CommonObject */ public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode = '') { - global $conf; + global $conf; $skip_batch = empty($conf->productbatch->enabled); @@ -800,11 +800,11 @@ class MouvementStock extends CommonObject */ public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode = '') { - global $conf; + global $conf; - $skip_batch = empty($conf->productbatch->enabled); + $skip_batch = empty($conf->productbatch->enabled); - return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); + return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } @@ -869,7 +869,7 @@ class MouvementStock extends CommonObject */ private function createBatch($dluo, $qty) { - global $user; + global $user; $pdluo = new Productbatch($this->db); @@ -932,7 +932,7 @@ class MouvementStock extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return Url link of origin object * @@ -942,8 +942,8 @@ class MouvementStock extends CommonObject */ public function get_origin($fk_origin, $origintype) { - // phpcs:enable - $origin = ''; + // phpcs:enable + $origin = ''; switch ($origintype) { case 'commande': @@ -982,10 +982,10 @@ class MouvementStock extends CommonObject default: if ($origintype) { - // Separate originetype with "@" : left part is class name, right part is module name - $origintype_array = explode('@', $origintype); - $classname = ucfirst($origintype_array[0]); - $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1]; + // Separate originetype with "@" : left part is class name, right part is module name + $origintype_array = explode('@', $origintype); + $classname = ucfirst($origintype_array[0]); + $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1]; $result = dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); if ($result) { @@ -1034,21 +1034,21 @@ class MouvementStock extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - global $user, $langs, $conf, $mysoc; + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + global $user, $langs, $conf, $mysoc; - // Initialize parameters - $this->id = 0; + // Initialize parameters + $this->id = 0; - // There is no specific properties. All data into insert are provided as method parameter. - } + // There is no specific properties. All data into insert are provided as method parameter. + } /** * Return a link (with optionaly the picto) @@ -1099,7 +1099,7 @@ class MouvementStock extends CommonObject return $this->LibStatut($mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -1108,7 +1108,7 @@ class MouvementStock extends CommonObject */ public function LibStatut($mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0 || $mode == 1) { diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index e398b23935c..923c57b4692 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -70,8 +70,8 @@ $langs->loadLangs(array("main", "members", "companies", "install", "other")); if (empty($conf->adherent->enabled)) accessforbidden('', 0, 0, 1); if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { - print $langs->trans("Auto subscription form for public visitors has not been enabled"); - exit; + print $langs->trans("Auto subscription form for public visitors has not been enabled"); + exit; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -97,39 +97,39 @@ $user->loadDefaultValues(); */ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '') { - global $user, $conf, $langs, $mysoc; + global $user, $conf, $langs, $mysoc; - top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers - print ''; + print ''; - // Define urllogo - $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; + // Define urllogo + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); - } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { - $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; - } + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); + } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; + } print '
'; - // Output html code for logo - if ($urllogo) { - print '
'; - print '
'; - print ''; - print '
'; - if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { - print ''; - } - print '
'; - } - print '
'; + // Output html code for logo + if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; + } + print ''; - print '
'; + print '
'; } /** @@ -139,12 +139,12 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ */ function llxFooterVierge() { - print '
'; + print '
'; - printCommonFooter('public'); + printCommonFooter('public'); - print "\n"; - print "\n"; + print "\n"; + print "\n"; } @@ -156,7 +156,7 @@ $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } // Action called when page is submitted @@ -166,164 +166,164 @@ if (empty($reshook) && $action == 'add') { $db->begin(); - // test if login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - if (!GETPOST('login')) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."
\n"; - } - $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'"; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - } - if ($num != 0) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."
\n"; - } - if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"] != $_POST["pass2"]) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; - } - if (!GETPOST("email")) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; - } - } - if (GETPOST('type') <= 0) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; - } - if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; - } - if (empty($_POST["lastname"])) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; - } - if (empty($_POST["firstname"])) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; - } - if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; - } - $birthday = dol_mktime($_POST["birthhour"], $_POST["birthmin"], $_POST["birthsec"], $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); - if ($_POST["birthmonth"] && empty($birthday)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; - } - if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."
\n"; - } - } + // test if login already exists + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (!GETPOST('login')) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."
\n"; + } + $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num != 0) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."
\n"; + } + if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"] != $_POST["pass2"]) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; + } + if (!GETPOST("email")) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; + } + } + if (GETPOST('type') <= 0) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; + } + if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; + } + if (empty($_POST["lastname"])) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; + } + if (empty($_POST["firstname"])) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; + } + if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; + } + $birthday = dol_mktime($_POST["birthhour"], $_POST["birthmin"], $_POST["birthsec"], $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + if ($_POST["birthmonth"] && empty($birthday)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; + } + if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."
\n"; + } + } - if (isset($public)) $public = 1; - else $public = 0; + if (isset($public)) $public = 1; + else $public = 0; - if (!$error) { - // email a peu pres correct et le login n'existe pas - $adh = new Adherent($db); - $adh->statut = -1; - $adh->public = $public; - $adh->firstname = $_POST["firstname"]; - $adh->lastname = $_POST["lastname"]; - $adh->gender = $_POST["gender"]; - $adh->civility_id = $_POST["civility_id"]; - $adh->societe = $_POST["societe"]; - $adh->address = $_POST["address"]; - $adh->zip = $_POST["zipcode"]; - $adh->town = $_POST["town"]; - $adh->email = $_POST["email"]; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $adh->login = $_POST["login"]; - $adh->pass = $_POST["pass1"]; - } - $adh->photo = $_POST["photo"]; - $adh->country_id = $_POST["country_id"]; - $adh->state_id = $_POST["state_id"]; - $adh->typeid = $_POST["type"]; - $adh->note_private = $_POST["note_private"]; - $adh->morphy = $_POST["morphy"]; - $adh->birth = $birthday; + if (!$error) { + // email a peu pres correct et le login n'existe pas + $adh = new Adherent($db); + $adh->statut = -1; + $adh->public = $public; + $adh->firstname = $_POST["firstname"]; + $adh->lastname = $_POST["lastname"]; + $adh->gender = $_POST["gender"]; + $adh->civility_id = $_POST["civility_id"]; + $adh->societe = $_POST["societe"]; + $adh->address = $_POST["address"]; + $adh->zip = $_POST["zipcode"]; + $adh->town = $_POST["town"]; + $adh->email = $_POST["email"]; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + $adh->login = $_POST["login"]; + $adh->pass = $_POST["pass1"]; + } + $adh->photo = $_POST["photo"]; + $adh->country_id = $_POST["country_id"]; + $adh->state_id = $_POST["state_id"]; + $adh->typeid = $_POST["type"]; + $adh->note_private = $_POST["note_private"]; + $adh->morphy = $_POST["morphy"]; + $adh->birth = $birthday; - // Fill array 'array_options' with data from add form - $extrafields->fetch_name_optionals_label($adh->table_element); - $ret = $extrafields->setOptionalsFromPost(null, $adh); + // Fill array 'array_options' with data from add form + $extrafields->fetch_name_optionals_label($adh->table_element); + $ret = $extrafields->setOptionalsFromPost(null, $adh); if ($ret < 0) $error++; - $result = $adh->create($user); - if ($result > 0) { + $result = $adh->create($user); + if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $object = $adh; + $object = $adh; - $adht = new AdherentType($db); - $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $adht->fetch($object->typeid); - if ($object->email) { - $subject = ''; - $msg = ''; + if ($object->email) { + $subject = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); - if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; + if ($subjecttosend && $texttosend) { + $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } - /*if ($result < 0) { + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + } + /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ - } + } - // Send email to the foundation to say a new member subscribed with autosubscribe form - if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && - !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { - // 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 { + // Send email to the foundation to say a new member subscribed with autosubscribe form + if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && + !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { + // 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; - } + } - $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); - $from = $conf->global->ADHERENT_MAIL_FROM; + $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); + $from = $conf->global->ADHERENT_MAIL_FROM; $mailfile = new CMailFile( '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, @@ -338,103 +338,103 @@ if (empty($reshook) && $action == 'add') { -1 ); - if (!$mailfile->sendfile()) { - dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); - } - } + if (!$mailfile->sendfile()) { + dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); + } + } - if (!empty($backtopage)) { + if (!empty($backtopage)) { $urlback = $backtopage; } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) { - $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... - } else { + $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; + // TODO Make replacement of __AMOUNT__, etc... + } else { $urlback = $_SERVER["PHP_SELF"]."?action=added"; } - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { - if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { - $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { - $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; - if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } else { - dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment"); - exit; - } - } + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { + if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { + $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); + if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); + } else { + $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); + } + } + } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { + $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); + if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); + } else { + $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); + } + } + } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { + $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); + if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); + } else { + $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); + } + } + } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { + $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; + if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email')); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); + } else { + $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); + } + } + } else { + dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment"); + exit; + } + } - if (!empty($entity)) $urlback .= '&entity='.$entity; - dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); - } else { - $error++; - $errmsg .= join('
', $adh->errors); - } - } + if (!empty($entity)) $urlback .= '&entity='.$entity; + dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); + } else { + $error++; + $errmsg .= join('
', $adh->errors); + } + } - if (!$error) { - $db->commit(); + if (!$error) { + $db->commit(); - Header("Location: ".$urlback); - exit; - } else { - $db->rollback(); - } + Header("Location: ".$urlback); + exit; + } else { + $db->rollback(); + } } // Action called after a submitted was send and member created successfully // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url. // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url. if (empty($reshook) && $action == 'added') { - llxHeaderVierge($langs->trans("NewMemberForm")); + llxHeaderVierge($langs->trans("NewMemberForm")); - // Si on a pas ete redirige - print '
'; - print '
'; - print $langs->trans("NewMemberbyWeb"); - print '
'; + // Si on a pas ete redirige + print '
'; + print '
'; + print $langs->trans("NewMemberbyWeb"); + print '
'; - llxFooterVierge(); - exit; + llxFooterVierge(); + exit; } @@ -460,9 +460,9 @@ print '
'; print '
'; if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) { - print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n"; + print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n"; } else { - print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n"; + print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n"; } print '
'; @@ -510,31 +510,31 @@ print ''." // Type if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { $defaulttype = $tmp[0]; $isempty = 0; } - print ''."\n"; + print ''."\n"; } else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; + print ''."\n"; } else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; } // Civility print ''; print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; + print ''; } // EMail print ''."\n"; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } // Birthday print ''."\n"; // Add specific fields used by Dolibarr foundation for example if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; + print ''."\n"; } if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount = 0; - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount + $amount = 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; - } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''; + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; + } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; } print "
'.$langs->trans("Type").' *'; - print $form->selectarray("type", $adht->liste_array(), GETPOST('type') ?GETPOST('type') : $defaulttype, $isempty); - print '
'.$langs->trans("Type").' *'; + print $form->selectarray("type", $adht->liste_array(), GETPOST('type') ?GETPOST('type') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans('UserTitle').''; @@ -564,34 +564,34 @@ print '
'.$langs->trans('Country').''; $country_id = GETPOST('country_id'); if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); } if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) $country_id = $new_country_id; - } + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) $country_id = $new_country_id; + } } $country_code = getCountry($country_id, 2, $db, $langs); print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans('State').''; - if ($country_code) print $formcompany->select_state(GETPOST("state_id"), $country_code); - else print ''; - print '
'.$langs->trans('State').''; + if ($country_code) print $formcompany->select_state(GETPOST("state_id"), $country_code); + else print ''; + print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateToBirth").''; @@ -612,12 +612,12 @@ print '
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print '
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; - print ''; - print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; - } - print ' '.$langs->trans("Currency".$conf->currency); - print '
'.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print '
\n"; @@ -682,7 +682,7 @@ print dol_get_fiche_end(); print '
'; print ''; if (!empty($backtopage)) { - print '     '; + print '     '; } print '
'; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 7c58d0ef944..1291035760f 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -64,11 +64,11 @@ if (empty($source)) $source = 'proposal'; if (!$action) { - if ($source && !$ref) - { - print $langs->trans('ErrorBadParameters')." - ref missing"; - exit; - } + if ($source && !$ref) + { + print $langs->trans('ErrorBadParameters')." - ref missing"; + exit; + } } @@ -83,18 +83,18 @@ $SECUREKEY = GETPOST("securekey"); // Secure key if (!empty($source)) { - $urlok .= 'source='.urlencode($source).'&'; - $urlko .= 'source='.urlencode($source).'&'; + $urlok .= 'source='.urlencode($source).'&'; + $urlko .= 'source='.urlencode($source).'&'; } if (!empty($REF)) { - $urlok .= 'ref='.urlencode($REF).'&'; - $urlko .= 'ref='.urlencode($REF).'&'; + $urlok .= 'ref='.urlencode($REF).'&'; + $urlko .= 'ref='.urlencode($REF).'&'; } if (!empty($SECUREKEY)) { - $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; - $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; } if (!empty($entity)) { @@ -114,7 +114,7 @@ $creditor = $mysoc->name; if ($action == 'dosign') { - // TODO + // TODO } @@ -134,12 +134,12 @@ llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'on // Check link validity for param 'source' if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { - $langs->load("errors"); - dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); - // End of page - llxFooter(); - $db->close(); - exit; + $langs->load("errors"); + dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); + // End of page + llxFooter(); + $db->close(); + exit; } print ''."\n"; @@ -194,16 +194,16 @@ if ($urllogo) $text = ''; if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) { - $langs->load("members"); - $reg = array(); - if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
\n"; - else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; - $text = '

'.$text.'

'.$text.'

'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'


'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

'.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
'.$creditor.''; + print ''; + print '
'."\n"; print "\n"; if ($action != 'dosign') { - if ($found && !$error) { - // We are in a management option and no error - } else { - dol_print_error_email('ERRORNEWONLINESIGN'); - } + if ($found && !$error) { + // We are in a management option and no error + } else { + dol_print_error_email('ERRORNEWONLINESIGN'); + } } else { - // Print + // Print } print ''."\n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index a44428808a4..90ded9e8008 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -417,42 +417,42 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) dol_syslog("POST vatnumber = ".$vatnumber, LOG_DEBUG, 0, '_stripe'); $error = 0; - $errormessage = ''; + $errormessage = ''; - // When using the Charge API architecture - if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - try { - $metadata = array( - 'dol_version' => DOL_VERSION, - 'dol_entity' => $conf->entity, - 'dol_company' => $mysoc->name, // Usefull when using multicompany - 'dol_tax_num' => $vatnumber, - 'ipaddress'=> getUserRemoteIP() - ); + // When using the Charge API architecture + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + try { + $metadata = array( + 'dol_version' => DOL_VERSION, + 'dol_entity' => $conf->entity, + 'dol_company' => $mysoc->name, // Usefull when using multicompany + 'dol_tax_num' => $vatnumber, + 'ipaddress'=> getUserRemoteIP() + ); - if (!empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id; + if (!empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id; - if ($thirdparty_id > 0) - { - dol_syslog("Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); + if ($thirdparty_id > 0) + { + dol_syslog("Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } - $thirdparty = new Societe($db); - $thirdparty->fetch($thirdparty_id); + $thirdparty = new Societe($db); + $thirdparty->fetch($thirdparty_id); - // Create Stripe customer - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + // Create Stripe customer + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); if (empty($customer)) { $error++; @@ -461,51 +461,51 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) $action = ''; } - // Create Stripe card from Token - if (!$error) - { - if ($savesource) { - $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); - } else { - $card = $stripeToken; - } + // Create Stripe card from Token + if (!$error) + { + if ($savesource) { + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { + $card = $stripeToken; + } - if (empty($card)) - { - $error++; - dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to create card record', null, 'errors'); - $action = ''; - } else { - if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; + if (empty($card)) + { + $error++; + dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to create card record', null, 'errors'); + $action = ''; + } else { + if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; - dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'customer' => $customer->id, - 'source' => $card, - 'statement_descriptor_suffix' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action = ''; - } - } - } - } else { - $vatcleaned = $vatnumber ? $vatnumber : null; + dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'customer' => $customer->id, + 'source' => $card, + 'statement_descriptor_suffix' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action = ''; + } + } + } + } else { + $vatcleaned = $vatnumber ? $vatnumber : null; - /*$taxinfo = array('type'=>'vat'); + /*$taxinfo = array('type'=>'vat'); if ($vatcleaned) { $taxinfo["tax_id"] = $vatcleaned; @@ -514,18 +514,18 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) if (empty($vatcleaned)) $taxinfo=null; */ - dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); + dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); - $customer = \Stripe\Customer::create(array( - 'email' => $email, - 'description' => ($email ? 'Anonymous customer for '.$email : 'Anonymous customer'), - 'metadata' => $metadata, - 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) - )); - // Return $customer = array('id'=>'cus_XXXX', ...) + $customer = \Stripe\Customer::create(array( + 'email' => $email, + 'description' => ($email ? 'Anonymous customer for '.$email : 'Anonymous customer'), + 'metadata' => $metadata, + 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) + )); + // Return $customer = array('id'=>'cus_XXXX', ...) - // Create the VAT record in Stripe - /* We don't know country of customer, so we can't create tax + // Create the VAT record in Stripe + /* We don't know country of customer, so we can't create tax if (! empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer { if (! empty($vatcleaned)) @@ -539,145 +539,145 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) } }*/ - if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; + if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; - // The customer was just created with a source, so we can make a charge - // with no card defined, the source just used for customer creation will be used. - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'customer' => $customer->id, - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action = ''; - } - } - } catch (\Stripe\Error\Card $e) { - // Since it's a decline, \Stripe\Error\Card will be caught - $body = $e->getJsonBody(); - $err = $body['error']; + // The customer was just created with a source, so we can make a charge + // with no card defined, the source just used for customer creation will be used. + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'customer' => $customer->id, + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action = ''; + } + } + } catch (\Stripe\Error\Card $e) { + // Since it's a decline, \Stripe\Error\Card will be caught + $body = $e->getJsonBody(); + $err = $body['error']; - print('Status is:'.$e->getHttpStatus()."\n"); - print('Type is:'.$err['type']."\n"); - print('Code is:'.$err['code']."\n"); - // param is '' in this case - print('Param is:'.$err['param']."\n"); - print('Message is:'.$err['message']."\n"); + print('Status is:'.$e->getHttpStatus()."\n"); + print('Type is:'.$err['type']."\n"); + print('Code is:'.$err['code']."\n"); + // param is '' in this case + print('Param is:'.$err['param']."\n"); + print('Message is:'.$err['message']."\n"); - $error++; - $errormessage = "ErrorCard ".$e->getMessage()." err=".var_export($err, true); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\RateLimit $e) { - // Too many requests made to the API too quickly - $error++; - $errormessage = "ErrorRateLimit ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\InvalidRequest $e) { - // Invalid parameters were supplied to Stripe's API - $error++; - $errormessage = "ErrorInvalidRequest ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\Authentication $e) { - // Authentication with Stripe's API failed - // (maybe you changed API keys recently) - $error++; - $errormessage = "ErrorAuthentication ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\ApiConnection $e) { - // Network communication with Stripe failed - $error++; - $errormessage = "ErrorApiConnection ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\Base $e) { - // Display a very generic error to the user, and maybe send - // yourself an email - $error++; - $errormessage = "ErrorBase ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (Exception $e) { - // Something else happened, completely unrelated to Stripe - $error++; - $errormessage = "ErrorException ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } - } + $error++; + $errormessage = "ErrorCard ".$e->getMessage()." err=".var_export($err, true); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\RateLimit $e) { + // Too many requests made to the API too quickly + $error++; + $errormessage = "ErrorRateLimit ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\InvalidRequest $e) { + // Invalid parameters were supplied to Stripe's API + $error++; + $errormessage = "ErrorInvalidRequest ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\Authentication $e) { + // Authentication with Stripe's API failed + // (maybe you changed API keys recently) + $error++; + $errormessage = "ErrorAuthentication ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\ApiConnection $e) { + // Network communication with Stripe failed + $error++; + $errormessage = "ErrorApiConnection ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\Base $e) { + // Display a very generic error to the user, and maybe send + // yourself an email + $error++; + $errormessage = "ErrorBase ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (Exception $e) { + // Something else happened, completely unrelated to Stripe + $error++; + $errormessage = "ErrorException ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } + } - // When using the PaymentIntent API architecture - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); + // When using the PaymentIntent API architecture + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); - // We go here if $conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is set. - // In such a case, payment is always ok when we call the "charge" action. - $paymentintent_id = GETPOST("paymentintent_id", "alpha"); + // We go here if $conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is set. + // In such a case, payment is always ok when we call the "charge" action. + $paymentintent_id = GETPOST("paymentintent_id", "alpha"); - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); - try { - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id); - } else { - $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array("stripe_account" => $stripeacc)); - } - } catch (Exception $e) - { - $error++; - $errormessage = "CantRetrievePaymentIntent ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id); + } else { + $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array("stripe_account" => $stripeacc)); + } + } catch (Exception $e) + { + $error++; + $errormessage = "CantRetrievePaymentIntent ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } - if ($paymentintent->status != 'succeeded') - { - $error++; - $errormessage = "StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status; - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($paymentintent->status, null, 'errors'); - $action = ''; - } else { - // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method - // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. - //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); - } - } + if ($paymentintent->status != 'succeeded') + { + $error++; + $errormessage = "StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status; + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($paymentintent->status, null, 'errors'); + $action = ''; + } else { + // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method + // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. + //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); + } + } $remoteip = getUserRemoteIP(); @@ -727,8 +727,8 @@ if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_r $langs->load("errors"); dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -1394,9 +1394,9 @@ if ($source == 'membersubscription') print ''."\n"; if ($object->datefin > 0) { - print ''.$langs->trans("DateEndSubscription"); - print ''.dol_print_date($member->datefin, 'day'); - print ''."\n"; + print ''.$langs->trans("DateEndSubscription"); + print ''.dol_print_date($member->datefin, 'day'); + print ''."\n"; } if ($member->last_subscription_date || $member->last_subscription_amount) @@ -1667,13 +1667,13 @@ if ($action != 'dopayment') { print '

'.$langs->trans("DonationPaid").''; } else { - // Membership can be paid and we still allow to make renewal - if ($source == 'membersubscription' && $object->datefin > dol_now()) - { - $langs->load("members"); - print '
'.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
'; - print '
'.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
'; - } + // Membership can be paid and we still allow to make renewal + if ($source == 'membersubscription' && $object->datefin > dol_now()) + { + $langs->load("members"); + print '
'.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
'; + print '
'.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
'; + } // Buttons for all payments registration methods @@ -1862,48 +1862,48 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) //{ - print ' + print ' '; - print '
'; - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
'; - } + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
'; + } - print '
'; - print ''; + print '
'; + print ''; - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
'; - } + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
'; + } - print '
+ print '
'; - print ' + print '
'; - print '
'; - print ''; - print ''; + print '
'; + print ''; + print ''; - print '
'; + print ''; + print ''; //} if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - if (empty($paymentintent)) - { - print '
'.$langs->trans("Error").'
'; - } else { - print ''; - //$_SESSION["paymentintent_id"] = $paymentintent->id; - } + if (empty($paymentintent)) + { + print '
'.$langs->trans("Error").'
'; + } else { + print ''; + //$_SESSION["paymentintent_id"] = $paymentintent->id; + } } print ''."\n"; @@ -1916,71 +1916,71 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); } else { print ''; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; - // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. - print ''; + print ''; } } // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index a5be30aab49..504ecadfc71 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -22,15 +22,15 @@ */ if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); + define('NOCSRFCHECK', '1'); } // Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); + define('NOREQUIREMENU', '1'); } // If there is no need to load and show top and left menu if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); + define("NOLOGIN", '1'); } if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 91ce8993bef..bd7b5416efb 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -69,7 +69,7 @@ $parameters = array( // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } // Add file in email form if (empty($reshook) && GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 6e27164ba23..ffe2a1373e8 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -57,7 +57,7 @@ class RecruitmentJobPosition extends CommonObject */ public $isextrafieldmanaged = 1; - /** + /** * @var string String with name of icon for recruitmentjobposition. Must be the part after the 'object_' into object_recruitmentjobposition.png */ public $picto = 'recruitmentjobposition'; @@ -126,30 +126,30 @@ class RecruitmentJobPosition extends CommonObject ); public $rowid; - /** - * @var string ref - */ + /** + * @var string ref + */ public $ref; public $entity; - /** - * @var string label - */ + /** + * @var string label + */ public $label; public $qty; public $fk_soc; public $fk_project; public $fk_user_recruiter; - /** - * @var string recruiter email - */ - public $email_recruiter; + /** + * @var string recruiter email + */ + public $email_recruiter; - /** - * @var string suggested remuneration - */ - public $remuneration_suggested; + /** + * @var string suggested remuneration + */ + public $remuneration_suggested; public $fk_user_supervisor; public $fk_establishment; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index d392375fdd0..ef4252f41df 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -52,8 +52,8 @@ class Dolresource extends CommonObject public $mandatory; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_create; public $type_label; @@ -63,75 +63,75 @@ class Dolresource extends CommonObject public $oldcopy; - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs, $hookmanager; - $error = 0; + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs, $hookmanager; + $error = 0; - // Clean parameters + // Clean parameters - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->description)) $this->description = trim($this->description); - if (!is_numeric($this->country_id)) $this->country_id = 0; - if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->description)) $this->description = trim($this->description); + if (!is_numeric($this->country_id)) $this->country_id = 0; + if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; - $sql .= "entity,"; - $sql .= "ref,"; - $sql .= "description,"; - $sql .= "fk_country,"; - $sql .= "fk_code_type_resource,"; - $sql .= "note_public,"; - $sql .= "note_private"; - $sql .= ") VALUES ("; - $sql .= $conf->entity.", "; - $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; - $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; - $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; - $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; - $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; - $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); - $sql .= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; + $sql .= "entity,"; + $sql .= "ref,"; + $sql .= "description,"; + $sql .= "fk_country,"; + $sql .= "fk_code_type_resource,"; + $sql .= "note_public,"; + $sql .= "note_private"; + $sql .= ") VALUES ("; + $sql .= $conf->entity.", "; + $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; + $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; + $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; + $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; + $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; + $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); + $sql .= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - } + if (!$error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + } - if (!$error) - { - $action = 'create'; + if (!$error) + { + $action = 'create'; - // Actions on extra fields + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -139,100 +139,100 @@ class Dolresource extends CommonObject { $error++; } - } - } + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('RESOURCE_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('RESOURCE_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Load object in memory from database - * - * @param int $id Id of object - * @param string $ref Ref of object - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $ref = '') - { - global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; - $sql .= " t.entity,"; - $sql .= " t.ref,"; - $sql .= " t.description,"; + /** + * Load object in memory from database + * + * @param int $id Id of object + * @param string $ref Ref of object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $ref = '') + { + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.entity,"; + $sql .= " t.ref,"; + $sql .= " t.description,"; $sql .= " t.fk_country,"; - $sql .= " t.fk_code_type_resource,"; - $sql .= " t.note_public,"; - $sql .= " t.note_private,"; - $sql .= " t.tms,"; - $sql .= " ty.label as type_label"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; - if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id); - else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'"; + $sql .= " t.fk_code_type_resource,"; + $sql .= " t.note_public,"; + $sql .= " t.note_private,"; + $sql .= " t.tms,"; + $sql .= " ty.label as type_label"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; + if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id); + else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->description = $obj->description; - $this->country_id = $obj->fk_country; - $this->fk_code_type_resource = $obj->fk_code_type_resource; - $this->note_public = $obj->note_public; - $this->note_private = $obj->note_private; - $this->type_label = $obj->type_label; + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; + $this->description = $obj->description; + $this->country_id = $obj->fk_country; + $this->fk_code_type_resource = $obj->fk_code_type_resource; + $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->type_label = $obj->type_label; - // Retrieve all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - } - $this->db->free($resql); + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + } + $this->db->free($resql); - return $this->id; - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); - return -1; - } - } + return $this->id; + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) { global $conf, $langs, $hookmanager; $error = 0; @@ -241,7 +241,7 @@ class Dolresource extends CommonObject if (isset($this->ref)) $this->ref = trim($this->ref); if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); if (isset($this->description)) $this->description = trim($this->description); - if (!is_numeric($this->country_id)) $this->country_id = 0; + if (!is_numeric($this->country_id)) $this->country_id = 0; if (empty($this->oldcopy)) { @@ -327,19 +327,19 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load object in memory from database - * - * @param int $id id object - * @return int <0 if KO, >0 if OK - */ - public function fetch_element_resource($id) - { - // phpcs:enable - global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load object in memory from database + * + * @param int $id id object + * @return int <0 if KO, >0 if OK + */ + public function fetch_element_resource($id) + { + // phpcs:enable + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; $sql .= " t.resource_id,"; $sql .= " t.resource_type,"; $sql .= " t.element_id,"; @@ -349,24 +349,24 @@ class Dolresource extends CommonObject $sql .= " t.fk_user_create,"; $sql .= " t.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as t"; - $sql .= " WHERE t.rowid = ".$this->db->escape($id); + $sql .= " WHERE t.rowid = ".$this->db->escape($id); - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->resource_id = $obj->resource_id; - $this->resource_type = $obj->resource_type; - $this->element_id = $obj->element_id; - $this->element_type = $obj->element_type; - $this->busy = $obj->busy; - $this->mandatory = $obj->mandatory; - $this->fk_user_create = $obj->fk_user_create; + $this->id = $obj->rowid; + $this->resource_id = $obj->resource_id; + $this->resource_type = $obj->resource_type; + $this->element_id = $obj->element_id; + $this->element_type = $obj->element_type; + $this->busy = $obj->busy; + $this->mandatory = $obj->mandatory; + $this->fk_user_create = $obj->fk_user_create; if ($obj->resource_id && $obj->resource_type) { $this->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type); @@ -374,27 +374,27 @@ class Dolresource extends CommonObject if ($obj->element_id && $obj->element_type) { $this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type); } - } - $this->db->free($resql); + } + $this->db->free($resql); - return $this->id; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return $this->id; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Delete a resource object - * - * @param int $rowid Id of resource line to delete - * @param int $notrigger Disable all triggers - * @return int >0 if OK, <0 if KO - */ - public function delete($rowid, $notrigger = 0) + /** + * Delete a resource object + * + * @param int $rowid Id of resource line to delete + * @param int $notrigger Disable all triggers + * @return int >0 if OK, <0 if KO + */ + public function delete($rowid, $notrigger = 0) { global $user, $langs, $conf; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -467,108 +467,108 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load resource objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '') - { - // phpcs:enable - global $conf; - - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.entity,"; - $sql .= " t.ref,"; - $sql .= " t.description,"; - $sql .= " t.fk_code_type_resource,"; - $sql .= " t.tms,"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$this->table_element]['label'])) - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); - $sql .= " ty.label as type_label"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - // Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; - } elseif (strpos($key, 'ef.') !== false) { - $sql .= $value; - } else { - $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - $this->num_all = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $this->db->query($sql); - $this->num_all = $this->db->num_rows($result); - } - if ($limit) $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - - $this->lines = array(); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - while ($obj = $this->db->fetch_object($resql)) - { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->ref = $obj->ref; - $line->description = $obj->description; - $line->country_id = $obj->fk_country; - $line->fk_code_type_resource = $obj->fk_code_type_resource; - $line->type_label = $obj->type_label; - - // fetch optionals attributes and labels - - $line->fetch_optionals(); - - $this->lines[] = $line; - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load resource objects into $this->lines + * + * @param string $sortorder sort order * @param string $sortfield sort field * @param int $limit limit page * @param int $offset page * @param array $filter filter output * @return int <0 if KO, >0 if OK - */ - public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '') - { - // phpcs:enable + */ + public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '') + { + // phpcs:enable + global $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + + $sql = "SELECT "; + $sql .= " t.rowid,"; + $sql .= " t.entity,"; + $sql .= " t.ref,"; + $sql .= " t.description,"; + $sql .= " t.fk_code_type_resource,"; + $sql .= " t.tms,"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$this->table_element]['label'])) + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= " ty.label as type_label"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; + $sql .= " WHERE t.entity IN (".getEntity('resource').")"; + // Manage filter + if (!empty($filter)) { + foreach ($filter as $key => $value) { + if (strpos($key, 'date')) { + $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } elseif (strpos($key, 'ef.') !== false) { + $sql .= $value; + } else { + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + $sql .= $this->db->order($sortfield, $sortorder); + $this->num_all = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $this->db->query($sql); + $this->num_all = $this->db->num_rows($result); + } + if ($limit) $sql .= $this->db->plimit($limit, $offset); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + + $this->lines = array(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + while ($obj = $this->db->fetch_object($resql)) + { + $line = new Dolresource($this->db); + $line->id = $obj->rowid; + $line->ref = $obj->ref; + $line->description = $obj->description; + $line->country_id = $obj->fk_country; + $line->fk_code_type_resource = $obj->fk_code_type_resource; + $line->type_label = $obj->type_label; + + // fetch optionals attributes and labels + + $line->fetch_optionals(); + + $this->lines[] = $line; + } + $this->db->free($resql); + } + return $num; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '') + { + // phpcs:enable global $conf; $sql = "SELECT "; $sql .= " t.rowid,"; @@ -593,7 +593,7 @@ class Dolresource extends CommonObject } } } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -619,7 +619,7 @@ class Dolresource extends CommonObject $line->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type); if ($obj->element_id && $obj->element_type) $line->objelement = fetchObjectByElement($obj->element_id, $obj->element_type); - $this->lines[] = $line; + $this->lines[] = $line; } $this->db->free($resql); } @@ -628,119 +628,119 @@ class Dolresource extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '') - { - // phpcs:enable - global $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '') + { + // phpcs:enable + global $conf; - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "t.rowid"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.rowid"; - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.resource_id,"; - $sql .= " t.resource_type,"; - $sql .= " t.element_id,"; - $sql .= " t.element_type,"; - $sql .= " t.busy,"; - $sql .= " t.mandatory,"; - $sql .= " t.fk_user_create,"; - $sql .= " t.tms"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; + $sql = "SELECT "; + $sql .= " t.rowid,"; + $sql .= " t.resource_id,"; + $sql .= " t.resource_type,"; + $sql .= " t.element_id,"; + $sql .= " t.element_type,"; + $sql .= " t.busy,"; + $sql .= " t.mandatory,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.tms"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; + $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - //Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; - } else { - $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + //Manage filter + if (!empty($filter)) { + foreach ($filter as $key => $value) { + if (strpos($key, 'date')) { + $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } else { + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - $this->lines = array(); - while ($obj = $this->db->fetch_object($resql)) - { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->resource_id = $obj->resource_id; - $line->resource_type = $obj->resource_type; - $line->element_id = $obj->element_id; - $line->element_type = $obj->element_type; - $line->busy = $obj->busy; - $line->mandatory = $obj->mandatory; - $line->fk_user_create = $obj->fk_user_create; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + $this->lines = array(); + while ($obj = $this->db->fetch_object($resql)) + { + $line = new Dolresource($this->db); + $line->id = $obj->rowid; + $line->resource_id = $obj->resource_id; + $line->resource_type = $obj->resource_type; + $line->element_id = $obj->element_id; + $line->element_type = $obj->element_type; + $line->busy = $obj->busy; + $line->mandatory = $obj->mandatory; + $line->fk_user_create = $obj->fk_user_create; - $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type); - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type); + } + $this->db->free($resql); + } + return $num; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch all resources available, declared by modules - * Load available resource in array $this->available_resources - * - * @return int number of available resources declared by modules - * @deprecated, remplaced by hook getElementResources - * @see getElementResources() - */ - public function fetch_all_available() - { - // phpcs:enable - global $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Fetch all resources available, declared by modules + * Load available resource in array $this->available_resources + * + * @return int number of available resources declared by modules + * @deprecated, remplaced by hook getElementResources + * @see getElementResources() + */ + public function fetch_all_available() + { + // phpcs:enable + global $conf; - if (!empty($conf->modules_parts['resources'])) - { - $this->available_resources = (array) $conf->modules_parts['resources']; + if (!empty($conf->modules_parts['resources'])) + { + $this->available_resources = (array) $conf->modules_parts['resources']; - return count($this->available_resources); - } - return 0; - } + return count($this->available_resources); + } + return 0; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update element resource into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update_element_resource($user = null, $notrigger = 0) - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update element resource into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update_element_resource($user = null, $notrigger = 0) + { + // phpcs:enable + global $conf, $langs; $error = 0; // Clean parameters @@ -751,8 +751,8 @@ class Dolresource extends CommonObject if (isset($this->busy)) $this->busy = trim($this->busy); if (isset($this->mandatory)) $this->mandatory = trim($this->mandatory); - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; $sql .= " resource_id=".(isset($this->resource_id) ? "'".$this->db->escape($this->resource_id)."'" : "null").","; $sql .= " resource_type=".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").","; $sql .= " element_id=".(isset($this->element_id) ? $this->element_id : "null").","; @@ -761,32 +761,32 @@ class Dolresource extends CommonObject $sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('RESOURCE_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('RESOURCE_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -794,201 +794,201 @@ class Dolresource extends CommonObject $this->db->commit(); return 1; } - } + } - /** - * Return an array with resources linked to the element - * - * @param string $element Element - * @param int $element_id Id - * @param string $resource_type Type - * @return array Aray of resources - */ - public function getElementResources($element, $element_id, $resource_type = '') - { - $resources = array(); + /** + * Return an array with resources linked to the element + * + * @param string $element Element + * @param int $element_id Id + * @param string $resource_type Type + * @return array Aray of resources + */ + public function getElementResources($element, $element_id, $resource_type = '') + { + $resources = array(); - // Links beetween objects are stored in this table - $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources'; - $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; - if ($resource_type) - $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'"; - $sql .= ' ORDER BY resource_type'; + // Links beetween objects are stored in this table + $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources'; + $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; + if ($resource_type) + $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'"; + $sql .= ' ORDER BY resource_type'; - dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); + dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); - $resources = array(); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resources = array(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - $resources[$i] = array( - 'rowid' => $obj->rowid, - 'resource_id' => $obj->resource_id, - 'resource_type'=>$obj->resource_type, - 'busy'=>$obj->busy, - 'mandatory'=>$obj->mandatory - ); - $i++; - } - } + $resources[$i] = array( + 'rowid' => $obj->rowid, + 'resource_id' => $obj->resource_id, + 'resource_type'=>$obj->resource_type, + 'busy'=>$obj->busy, + 'mandatory'=>$obj->mandatory + ); + $i++; + } + } - return $resources; - } + return $resources; + } - /** - * Return an int number of resources linked to the element - * - * @param string $element Element type - * @param int $element_id Element id - * @return int Nb of resources loaded - */ - public function fetchElementResources($element, $element_id) - { - $resources = $this->getElementResources($element, $element_id); - $i = 0; - foreach ($resources as $nb => $resource) { - $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']); - $i++; - } - return $i; - } + /** + * Return an int number of resources linked to the element + * + * @param string $element Element type + * @param int $element_id Element id + * @return int Nb of resources loaded + */ + public function fetchElementResources($element, $element_id) + { + $resources = $this->getElementResources($element, $element_id); + $i = 0; + foreach ($resources as $nb => $resource) { + $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']); + $i++; + } + return $i; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load in cache resource type code (setup in dictionary) - * - * @return int Number of lines loaded, 0 if already loaded, <0 if KO - */ - public function load_cache_code_type_resource() - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache resource type code (setup in dictionary) + * + * @return int Number of lines loaded, 0 if already loaded, <0 if KO + */ + public function load_cache_code_type_resource() + { + // phpcs:enable + global $langs; - if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge + if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge - $sql = "SELECT rowid, code, label, active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource"; - $sql .= " WHERE active > 0"; - $sql .= " ORDER BY rowid"; - dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); - $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; - $this->cache_code_type_resource[$obj->rowid]['label'] = $label; - $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active; - $i++; - } - return $num; - } else { - dol_print_error($this->db); - return -1; - } - } + $sql = "SELECT rowid, code, label, active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY rowid"; + dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; + $this->cache_code_type_resource[$obj->rowid]['label'] = $label; + $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active; + $i++; + } + return $num; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('compta', 'expedition', 'document', ...) - * @param string $get_params Parametres added to url - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $conf, $langs; + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $get_params Parametres added to url + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs; - $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Resource").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - /*if (isset($this->status)) { + $result = ''; + $label = img_picto('', $this->picto).' '.$langs->trans("Resource").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + /*if (isset($this->status)) { $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); }*/ - if (isset($this->type_label)) { - $label .= '
'.$langs->trans("ResourceType").": ".$this->type_label; - } + if (isset($this->type_label)) { + $label .= '
'.$langs->trans("ResourceType").": ".$this->type_label; + } - $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = '
'; - $linkend = ''; - /*$linkstart = ''; + $linkstart = ''; + $linkend = ''; + /*$linkstart = ''; $linkend = '';*/ - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du status d'un user (actif, inactif) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto - * @return string Label of status - */ - public static function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @return string Label of status + */ + public static function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; - return ''; - } + return ''; + } } diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 1d46981d8d3..4f5209eb123 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -31,668 +31,668 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class PaymentSalary extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'payment_salary'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'payment_salary'; - - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; - - public $tms; - - /** - * @var int User ID - */ - public $fk_user; - - public $datep; - public $datev; - public $amount; - - /** - * @var int ID - */ - public $fk_project; - - public $type_payment; - public $num_payment; - - /** - * @var string salary payments label - */ - public $label; - - public $datesp; - public $dateep; - - /** - * @var int ID - */ - public $fk_bank; - - /** - * @var int ID - */ - public $fk_user_author; - - /** - * @var int ID - */ - public $fk_user_modif; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->element = 'payment_salary'; - $this->table_element = 'payment_salary'; - } - - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; - - $error = 0; - - // Clean parameters - $this->amount = trim($this->amount); - $this->label = trim($this->label); - $this->note = trim($this->note); - - // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { - $this->error = 'ErrorBadParameter'; - return -1; - } - - $this->db->begin(); - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - - $sql .= " tms='".$this->db->idate($this->tms)."',"; - $sql .= " fk_user=".$this->fk_user.","; - $sql .= " datep='".$this->db->idate($this->datep)."',"; - $sql .= " datev='".$this->db->idate($this->datev)."',"; - $sql .= " amount=".price2num($this->amount).","; - $sql .= " fk_projet=".((int) $this->fk_project).","; - $sql .= " fk_typepayment=".$this->fk_typepayment."',"; - $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql .= " label='".$this->db->escape($this->label)."',"; - $sql .= " datesp='".$this->db->idate($this->datesp)."',"; - $sql .= " dateep='".$this->db->idate($this->dateep)."',"; - $sql .= " note='".$this->db->escape($this->note)."',"; - $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; - $sql .= " fk_user_author=".((int) $this->fk_user_author).","; - $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); - - $sql .= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - - // Update extrafield - if (!$error) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } - - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; - $sql .= " s.rowid,"; - - $sql .= " s.tms,"; - $sql .= " s.fk_user,"; - $sql .= " s.datep,"; - $sql .= " s.datev,"; - $sql .= " s.amount,"; - $sql .= " s.fk_projet as fk_project,"; - $sql .= " s.fk_typepayment,"; - $sql .= " s.num_payment,"; - $sql .= " s.label,"; - $sql .= " s.datesp,"; - $sql .= " s.dateep,"; - $sql .= " s.note,"; - $sql .= " s.fk_bank,"; - $sql .= " s.fk_user_author,"; - $sql .= " s.fk_user_modif,"; - $sql .= " b.fk_account,"; - $sql .= " b.fk_type,"; - $sql .= " b.rappro"; - - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql .= " WHERE s.rowid = ".$id; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; - - // Retrieve all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - } - $this->db->free($resql); - - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } - - - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - global $conf, $langs; - - $error = 0; - - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); - if ($result < 0) return -1; - // End call triggers - - // Delete donation - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; - $sql .= " WHERE fk_object=".$this->id; - - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql .= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - - return 1; - } - - - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - $this->id = 0; - - $this->tms = ''; - $this->fk_user = ''; - $this->datep = ''; - $this->datev = ''; - $this->amount = ''; - $this->label = ''; - $this->datesp = ''; - $this->dateep = ''; - $this->note = ''; - $this->fk_bank = ''; - $this->fk_user_author = ''; - $this->fk_user_modif = ''; - } - - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; - - $error = 0; - $now = dol_now(); - - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); - $this->note = trim($this->note); - $this->fk_bank = trim($this->fk_bank); - $this->fk_user_author = trim($this->fk_user_author); - $this->fk_user_modif = trim($this->fk_user_modif); - - // Check parameters - if (!$this->label) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - return -3; - } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); - return -4; - } - if ($this->amount < 0 || $this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - } - - $this->db->begin(); - - // Insert into llx_payment_salary - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql .= ", datep"; - $sql .= ", datev"; - $sql .= ", amount"; - $sql .= ", fk_projet"; - $sql .= ", salary"; - $sql .= ", fk_typepayment"; - $sql .= ", num_payment"; - if ($this->note) $sql .= ", note"; - $sql .= ", label"; - $sql .= ", datesp"; - $sql .= ", dateep"; - $sql .= ", fk_user_author"; - $sql .= ", datec"; - $sql .= ", fk_bank"; - $sql .= ", entity"; - $sql .= ") "; - $sql .= " VALUES ("; - $sql .= "'".$this->db->escape($this->fk_user)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; - $sql .= ", ".$this->amount; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); - $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql .= ", ".$this->db->escape($this->type_payment); - $sql .= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->idate($this->datesp)."'"; - $sql .= ", '".$this->db->idate($this->dateep)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", NULL"; - $sql .= ", ".$conf->entity; - $sql .= ")"; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - - if ($this->id > 0) - { - if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - - $acc = new Account($this->db); - $result = $acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); - - // Update extrafield - if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - - // Insert payment into llx_bank - // Add link 'payment_salary' in bank_url between payment and bank transaction - $bank_line_id = $acc->addline( - $this->datep, - $this->type_payment, - $this->label, - -abs($this->amount), - $this->num_payment, - '', - $user, - '', - '', - '', - $this->datev - ); - - // Update fk_bank into llx_paiement. - // So we know the payment which has generate the banking ecriture - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } else { - $this->error = $acc->error; - $error++; - } - - if (!$error) - { - // Add link 'payment_salary' in bank_url between payment and bank transaction - $url = DOL_URL_ROOT.'/salaries/card.php?id='; - - $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { - $this->error = $acc->error; - $error++; - } - } - - $fuser = new User($this->db); - $fuser->fetch($this->fk_user); - - // Add link 'user' in bank_url between operation and bank transaction - $result = $acc->add_url_line( - $bank_line_id, - $this->fk_user, - DOL_URL_ROOT.'/user/card.php?id=', - $fuser->getFullName($langs), - // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), - 'user' - ); - - if ($result <= 0) - { - $this->error = $acc->error; - $error++; - } - } - - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } else $error++; - - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update link between payment salary and line generate into llx_bank - * - * @param int $id_bank Id bank account - * @return int <0 if KO, >0 if OK - */ - public function update_fk_bank($id_bank) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; - $sql .= ' WHERE rowid = '.$this->id; - $result = $this->db->query($sql); - if ($result) - { - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } - - - /** - * Send name clicable (with possibly the picto) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - $label = ''.$langs->trans("ShowSalaryPayment").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - - $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; - - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* + /** + * @var string ID to identify managed object + */ + public $element = 'payment_salary'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'payment_salary'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; + + public $tms; + + /** + * @var int User ID + */ + public $fk_user; + + public $datep; + public $datev; + public $amount; + + /** + * @var int ID + */ + public $fk_project; + + public $type_payment; + public $num_payment; + + /** + * @var string salary payments label + */ + public $label; + + public $datesp; + public $dateep; + + /** + * @var int ID + */ + public $fk_bank; + + /** + * @var int ID + */ + public $fk_user_author; + + /** + * @var int ID + */ + public $fk_user_modif; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; + } + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; + + $error = 0; + + // Clean parameters + $this->amount = trim($this->amount); + $this->label = trim($this->label); + $this->note = trim($this->note); + + // Check parameters + if (empty($this->fk_user) || $this->fk_user < 0) + { + $this->error = 'ErrorBadParameter'; + return -1; + } + + $this->db->begin(); + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + + $sql .= " tms='".$this->db->idate($this->tms)."',"; + $sql .= " fk_user=".$this->fk_user.","; + $sql .= " datep='".$this->db->idate($this->datep)."',"; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " amount=".price2num($this->amount).","; + $sql .= " fk_projet=".((int) $this->fk_project).","; + $sql .= " fk_typepayment=".$this->fk_typepayment."',"; + $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " datesp='".$this->db->idate($this->datesp)."',"; + $sql .= " dateep='".$this->db->idate($this->dateep)."',"; + $sql .= " note='".$this->db->escape($this->note)."',"; + $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; + $sql .= " fk_user_author=".((int) $this->fk_user_author).","; + $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); + + $sql .= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + + // Update extrafield + if (!$error) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; + $sql .= " s.rowid,"; + + $sql .= " s.tms,"; + $sql .= " s.fk_user,"; + $sql .= " s.datep,"; + $sql .= " s.datev,"; + $sql .= " s.amount,"; + $sql .= " s.fk_projet as fk_project,"; + $sql .= " s.fk_typepayment,"; + $sql .= " s.num_payment,"; + $sql .= " s.label,"; + $sql .= " s.datesp,"; + $sql .= " s.dateep,"; + $sql .= " s.note,"; + $sql .= " s.fk_bank,"; + $sql .= " s.fk_user_author,"; + $sql .= " s.fk_user_modif,"; + $sql .= " b.fk_account,"; + $sql .= " b.fk_type,"; + $sql .= " b.rappro"; + + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql .= " WHERE s.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; + + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + } + $this->db->free($resql); + + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; + + $error = 0; + + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); + if ($result < 0) return -1; + // End call triggers + + // Delete donation + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; + $sql .= " WHERE fk_object=".$this->id; + + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errors[] = $this->db->lasterror(); + $error++; + } + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql .= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + + return 1; + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->tms = ''; + $this->fk_user = ''; + $this->datep = ''; + $this->datev = ''; + $this->amount = ''; + $this->label = ''; + $this->datesp = ''; + $this->dateep = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_author = ''; + $this->fk_user_modif = ''; + } + + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; + + $error = 0; + $now = dol_now(); + + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); + $this->note = trim($this->note); + $this->fk_bank = trim($this->fk_bank); + $this->fk_user_author = trim($this->fk_user_author); + $this->fk_user_modif = trim($this->fk_user_modif); + + // Check parameters + if (!$this->label) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + return -3; + } + if ($this->fk_user < 0 || $this->fk_user == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + return -4; + } + if ($this->amount < 0 || $this->amount == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -6; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -7; + } + + $this->db->begin(); + + // Insert into llx_payment_salary + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; + $sql .= ", datep"; + $sql .= ", datev"; + $sql .= ", amount"; + $sql .= ", fk_projet"; + $sql .= ", salary"; + $sql .= ", fk_typepayment"; + $sql .= ", num_payment"; + if ($this->note) $sql .= ", note"; + $sql .= ", label"; + $sql .= ", datesp"; + $sql .= ", dateep"; + $sql .= ", fk_user_author"; + $sql .= ", datec"; + $sql .= ", fk_bank"; + $sql .= ", entity"; + $sql .= ") "; + $sql .= " VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", ".$this->amount; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); + $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); + $sql .= ", ".$this->db->escape($this->type_payment); + $sql .= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->idate($this->datesp)."'"; + $sql .= ", '".$this->db->idate($this->dateep)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", NULL"; + $sql .= ", ".$conf->entity; + $sql .= ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + + if ($this->id > 0) + { + if (!empty($conf->banque->enabled) && !empty($this->amount)) + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acc = new Account($this->db); + $result = $acc->fetch($this->accountid); + if ($result <= 0) dol_print_error($this->db); + + // Update extrafield + if (!$error) { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + + // Insert payment into llx_bank + // Add link 'payment_salary' in bank_url between payment and bank transaction + $bank_line_id = $acc->addline( + $this->datep, + $this->type_payment, + $this->label, + -abs($this->amount), + $this->num_payment, + '', + $user, + '', + '', + '', + $this->datev + ); + + // Update fk_bank into llx_paiement. + // So we know the payment which has generate the banking ecriture + if ($bank_line_id > 0) + { + $this->update_fk_bank($bank_line_id); + } else { + $this->error = $acc->error; + $error++; + } + + if (!$error) + { + // Add link 'payment_salary' in bank_url between payment and bank transaction + $url = DOL_URL_ROOT.'/salaries/card.php?id='; + + $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + if ($result <= 0) + { + $this->error = $acc->error; + $error++; + } + } + + $fuser = new User($this->db); + $fuser->fetch($this->fk_user); + + // Add link 'user' in bank_url between operation and bank transaction + $result = $acc->add_url_line( + $bank_line_id, + $this->fk_user, + DOL_URL_ROOT.'/user/card.php?id=', + $fuser->getFullName($langs), + // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), + 'user' + ); + + if ($result <= 0) + { + $this->error = $acc->error; + $error++; + } + } + + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } else $error++; + + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update link between payment salary and line generate into llx_bank + * + * @param int $id_bank Id bank account + * @return int <0 if KO, >0 if OK + */ + public function update_fk_bank($id_bank) + { + // phpcs:enable + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; + $sql .= ' WHERE rowid = '.$this->id; + $result = $this->db->query($sql); + if ($result) + { + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } + + + /** + * Send name clicable (with possibly the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option link option + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + + $label = ''.$langs->trans("ShowSalaryPayment").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action, $hookmanager; - $hookmanager->initHooks(array('salarypayment')); - $parameters = array('id'=>$this->id, 'getnomurl'=>$result); - $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action, $hookmanager; + $hookmanager->initHooks(array('salarypayment')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Information on record - * - * @param int $id Id of record - * @return void - */ - public function info($id) - { - $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; - $sql .= ' WHERE ps.rowid = '.$id; + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + public function info($id) + { + $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql .= ' WHERE ps.rowid = '.$id; - dol_syslog(get_class($this).'::info', LOG_DEBUG); - $result = $this->db->query($sql); + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - $langs->load('compta'); - /*if ($mode == 0) + $langs->load('compta'); + /*if ($mode == 0) { if ($status == 0) return $langs->trans('ToValidate'); if ($status == 1) return $langs->trans('Validated'); @@ -727,6 +727,6 @@ class PaymentSalary extends CommonObject if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); }*/ - return ''; - } + return ''; + } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 50c740e7be3..c48a0c4be3c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -610,8 +610,8 @@ if (!empty($type)) if ($type == 'f') $label = 'NewSupplier'; } -if ($contextpage = 'poslist' && $type == 't' && ( !empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { - print get_htmloutput_mesg(img_warning('default') . ' ' . $langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); +if ($contextpage = 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { + print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); } // Show the new button only when this page is not opend from the Extended POS (pop-up window) @@ -1257,13 +1257,13 @@ while ($i < min($num, $limit)) { // Prospect status print '
'; - print '
' . $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; foreach ($prospectstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($obj->stcomm_id != $val['id']) print '' . img_action($titlealt, $val['code'], $val['picto']) . ''; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; } print '
'; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/takepos/smpcb.php b/htdocs/takepos/smpcb.php index f138438a707..1e02e9bc591 100644 --- a/htdocs/takepos/smpcb.php +++ b/htdocs/takepos/smpcb.php @@ -40,7 +40,7 @@ if (GETPOSTISSET('status')) { if (GETPOST('smp-status')) { print ''; print ''; - print ' + print ' The HTML5 Herald diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index d3a59962d88..7864c93243f 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -39,11 +39,11 @@ dol_syslog("Call ActionComm webservices interfaces"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -57,36 +57,36 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + ) ); $actioncomm_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), + 'id' => array('name'=>'id', 'type'=>'xsd:string'), 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), 'type_id' => array('name'=>'type_id', 'type'=>'xsd:string'), @@ -137,11 +137,11 @@ if (is_array($extrafield_array)) $actioncomm_fields = array_merge($actioncomm_fi // Define other specific objects $server->wsdl->addComplexType( - 'actioncomm', - 'complexType', - 'struct', - 'all', - '', + 'actioncomm', + 'complexType', + 'struct', + 'all', + '', $actioncomm_fields ); @@ -165,12 +165,12 @@ $server->wsdl->addComplexType( 'sequence', '', array( - 'actioncommtype' => array( - 'name' => 'actioncommtype', - 'type' => 'tns:actioncommtype', - 'minOccurs' => '0', - 'maxOccurs' => 'unbounded' - ) + 'actioncommtype' => array( + 'name' => 'actioncommtype', + 'type' => 'tns:actioncommtype', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) ) ); @@ -199,16 +199,16 @@ $server->register( // Register WSDL $server->register( - 'getActionComm', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'actioncomm'=>'tns:actioncomm'), - $ns, - $ns.'#getActionComm', - $styledoc, - $styleuse, - 'WS to get actioncomm' + 'getActionComm', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'actioncomm'=>'tns:actioncomm'), + $ns, + $ns.'#getActionComm', + $styledoc, + $styleuse, + 'WS to get actioncomm' ); // Register WSDL @@ -251,100 +251,100 @@ $server->register( */ function getActionComm($authentication, $id) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id); + dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if ($error || (!$id)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if ($error || (!$id)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $fuser->getrights(); + if (!$error) + { + $fuser->getrights(); - if ($fuser->rights->agenda->allactions->read) - { - $actioncomm = new ActionComm($db); - $result = $actioncomm->fetch($id); - if ($result > 0) - { - $actioncomm_result_fields = array( + if ($fuser->rights->agenda->allactions->read) + { + $actioncomm = new ActionComm($db); + $result = $actioncomm->fetch($id); + if ($result > 0) + { + $actioncomm_result_fields = array( 'id' => $actioncomm->id, 'ref'=> $actioncomm->ref, - 'ref_ext'=> $actioncomm->ref_ext, - 'type_id'=> $actioncomm->type_id, - 'type_code'=> $actioncomm->type_code, - 'type'=> $actioncomm->type, - 'label'=> $actioncomm->label, - 'datep'=> dol_print_date($actioncomm->datep, 'dayhourrfc'), - 'datef'=> dol_print_date($actioncomm->datef, 'dayhourrfc'), - 'datec'=> dol_print_date($actioncomm->datec, 'dayhourrfc'), - 'datem'=> dol_print_date($actioncomm->datem, 'dayhourrfc'), - 'note'=> $actioncomm->note_private, - 'percentage'=> $actioncomm->percentage, - 'author'=> $actioncomm->authorid, - 'usermod'=> $actioncomm->usermodid, - 'userownerid'=> $actioncomm->userownerid, - 'priority'=> $actioncomm->priority, - 'fulldayevent'=> $actioncomm->fulldayevent, - 'location'=> $actioncomm->location, - 'socid'=> $actioncomm->socid, - 'contactid'=> $actioncomm->contact_id, - 'projectid'=> $actioncomm->fk_project, - 'fk_element'=> $actioncomm->fk_element, - 'elementtype'=> $actioncomm->elementtype - ); + 'ref_ext'=> $actioncomm->ref_ext, + 'type_id'=> $actioncomm->type_id, + 'type_code'=> $actioncomm->type_code, + 'type'=> $actioncomm->type, + 'label'=> $actioncomm->label, + 'datep'=> dol_print_date($actioncomm->datep, 'dayhourrfc'), + 'datef'=> dol_print_date($actioncomm->datef, 'dayhourrfc'), + 'datec'=> dol_print_date($actioncomm->datec, 'dayhourrfc'), + 'datem'=> dol_print_date($actioncomm->datem, 'dayhourrfc'), + 'note'=> $actioncomm->note_private, + 'percentage'=> $actioncomm->percentage, + 'author'=> $actioncomm->authorid, + 'usermod'=> $actioncomm->usermodid, + 'userownerid'=> $actioncomm->userownerid, + 'priority'=> $actioncomm->priority, + 'fulldayevent'=> $actioncomm->fulldayevent, + 'location'=> $actioncomm->location, + 'socid'=> $actioncomm->socid, + 'contactid'=> $actioncomm->contact_id, + 'projectid'=> $actioncomm->fk_project, + 'fk_element'=> $actioncomm->fk_element, + 'elementtype'=> $actioncomm->elementtype + ); - $elementtype = 'actioncomm'; + $elementtype = 'actioncomm'; - // Retrieve all extrafield for actioncomm - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $actioncomm->fetch_optionals(); + // Retrieve all extrafield for actioncomm + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $actioncomm->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'actioncomm'=>$actioncomm_result_fields); - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; - } - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'actioncomm'=>$actioncomm_result_fields); + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + } + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -384,8 +384,8 @@ function getListActionCommType($authentication) } $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'actioncommtypes'=>$resultarray); + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'actioncommtypes'=>$resultarray); } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index c4818d050f6..9abc7b6088f 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -35,11 +35,11 @@ dol_syslog("Call Contact webservices interfaces"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -53,31 +53,31 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + ) ); $contact_fields = array( @@ -142,11 +142,11 @@ if (is_array($extrafield_array)) $contact_fields = array_merge($contact_fields, // Define other specific objects $server->wsdl->addComplexType( - 'contact', - 'complexType', - 'struct', - 'all', - '', + 'contact', + 'complexType', + 'struct', + 'all', + '', $contact_fields ); @@ -179,16 +179,16 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped // Register WSDL $server->register( - 'getContact', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref_ext'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'contact'=>'tns:contact'), - $ns, - $ns.'#getContact', - $styledoc, - $styleuse, - 'WS to get a contact' + 'getContact', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'contact'=>'tns:contact'), + $ns, + $ns.'#getContact', + $styledoc, + $styleuse, + 'WS to get a contact' ); // Register WSDL @@ -243,113 +243,113 @@ $server->register( */ function getContact($authentication, $id, $ref_ext) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext); + dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if (!$error && ($id && $ref_ext)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if (!$error && ($id && $ref_ext)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $fuser->getrights(); + if (!$error) + { + $fuser->getrights(); - $contact = new Contact($db); - $result = $contact->fetch($id, 0, $ref_ext); - if ($result > 0) - { - // Only internal user who have contact read permission - // Or for external user who have contact read permission, with restrict on societe_id - if ( - $fuser->rights->societe->contact->lire && !$fuser->societe_id - || ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid)) - ) { - $contact_result_fields = array( - 'id' => $contact->id, - 'ref_ext' => $contact->ref_ext, - 'lastname' => $contact->lastname, - 'firstname' => $contact->firstname, - 'address' => $contact->address, - 'zip' => $contact->zip, - 'town' => $contact->town, - 'state_id' => $contact->state_id, - 'state_code' => $contact->state_code, - 'state' => $contact->state, - 'country_id' => $contact->country_id, - 'country_code' => $contact->country_code, - 'country' => $contact->country, - 'socid' => $contact->socid, - 'status' => $contact->statut, - 'phone_pro' => $contact->phone_pro, - 'fax' => $contact->fax, - 'phone_perso' => $contact->phone_perso, - 'phone_mobile' => $contact->phone_mobile, - 'code' => $contact->code, - 'email' => $contact->email, - 'birthday' => $contact->birthday, - 'default_lang' => $contact->default_lang, - 'note' => $contact->note, - 'ref_facturation' => $contact->ref_facturation, - 'ref_contrat' => $contact->ref_contrat, - 'ref_commande' => $contact->ref_commande, - 'ref_propal' => $contact->ref_propal, - 'user_id' => $contact->user_id, - 'user_login' => $contact->user_login, - 'civility_id' => $contact->civility_id, - 'poste' => $contact->poste - ); + $contact = new Contact($db); + $result = $contact->fetch($id, 0, $ref_ext); + if ($result > 0) + { + // Only internal user who have contact read permission + // Or for external user who have contact read permission, with restrict on societe_id + if ( + $fuser->rights->societe->contact->lire && !$fuser->societe_id + || ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid)) + ) { + $contact_result_fields = array( + 'id' => $contact->id, + 'ref_ext' => $contact->ref_ext, + 'lastname' => $contact->lastname, + 'firstname' => $contact->firstname, + 'address' => $contact->address, + 'zip' => $contact->zip, + 'town' => $contact->town, + 'state_id' => $contact->state_id, + 'state_code' => $contact->state_code, + 'state' => $contact->state, + 'country_id' => $contact->country_id, + 'country_code' => $contact->country_code, + 'country' => $contact->country, + 'socid' => $contact->socid, + 'status' => $contact->statut, + 'phone_pro' => $contact->phone_pro, + 'fax' => $contact->fax, + 'phone_perso' => $contact->phone_perso, + 'phone_mobile' => $contact->phone_mobile, + 'code' => $contact->code, + 'email' => $contact->email, + 'birthday' => $contact->birthday, + 'default_lang' => $contact->default_lang, + 'note' => $contact->note, + 'ref_facturation' => $contact->ref_facturation, + 'ref_contrat' => $contact->ref_contrat, + 'ref_commande' => $contact->ref_commande, + 'ref_propal' => $contact->ref_propal, + 'user_id' => $contact->user_id, + 'user_login' => $contact->user_login, + 'civility_id' => $contact->civility_id, + 'poste' => $contact->poste + ); - $elementtype = 'socpeople'; + $elementtype = 'socpeople'; - //Retrieve all extrafield for thirdsparty - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $contact->fetch_optionals(); + //Retrieve all extrafield for thirdsparty + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $contact->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'contact'=>$contact_result_fields - ); - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'contact'=>$contact_result_fields + ); + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -623,11 +623,11 @@ function updateContact($authentication, $contact) $error++; $errorcode = 'KO'; $errorlabel = "Contact id or ref_ext is mandatory."; } // Check parameters - if (!$error && ($id && $ref_ext)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them."; - } + if (!$error && ($id && $ref_ext)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them."; + } if (!$error) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 327cab7bed9..224b2f00fa7 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -44,11 +44,11 @@ $langs->load("main"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

'; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -62,72 +62,72 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string') - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string') + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string') - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string') + ) ); $productorservice_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), - 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), - 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'label' => array('name'=>'label', 'type'=>'xsd:string'), - 'description' => array('name'=>'description', 'type'=>'xsd:string'), - 'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'), - 'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'), - 'note' => array('name'=>'note', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), - 'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'), - 'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), - 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), - 'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'), + 'id' => array('name'=>'id', 'type'=>'xsd:string'), + 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), + 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), + 'type' => array('name'=>'type', 'type'=>'xsd:string'), + 'label' => array('name'=>'label', 'type'=>'xsd:string'), + 'description' => array('name'=>'description', 'type'=>'xsd:string'), + 'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'), + 'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'), + 'note' => array('name'=>'note', 'type'=>'xsd:string'), + 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), + 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), + 'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'), + 'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'), + 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), + 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), + 'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'), - 'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'), - 'price' => array('name'=>'price', 'type'=>'xsd:string'), - 'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'), - 'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'), + 'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'), + 'price' => array('name'=>'price', 'type'=>'xsd:string'), + 'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'), + 'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'), - 'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'), + 'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'), - 'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'), - 'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'), - 'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'), - 'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'), + 'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'), + 'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'), + 'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'), + 'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'), - 'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'), - 'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'), - 'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'), - 'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database + 'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'), + 'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'), + 'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'), + 'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database - 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'), - 'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'), + 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'), + 'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'), - 'dir' => array('name'=>'dir', 'type'=>'xsd:string'), - 'images' => array('name'=>'images', 'type'=>'tns:ImagesArray') + 'dir' => array('name'=>'dir', 'type'=>'xsd:string'), + 'images' => array('name'=>'images', 'type'=>'tns:ImagesArray') ); @@ -158,12 +158,12 @@ if (is_array($extrafield_array)) $productorservice_fields = array_merge($product // Define other specific objects $server->wsdl->addComplexType( - 'product', - 'complexType', - 'struct', - 'all', - '', - $productorservice_fields + 'product', + 'complexType', + 'struct', + 'all', + '', + $productorservice_fields ); @@ -206,33 +206,33 @@ $server->wsdl->addComplexType( // Define other specific objects $server->wsdl->addComplexType( - 'filterproduct', - 'complexType', - 'struct', - 'all', - '', - array( - //'limit' => array('name'=>'limit','type'=>'xsd:string'), + 'filterproduct', + 'complexType', + 'struct', + 'all', + '', + array( + //'limit' => array('name'=>'limit','type'=>'xsd:string'), 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), - ) + 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), + 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), + ) ); $server->wsdl->addComplexType( - 'ProductsArray2', - 'complexType', - 'array', - 'sequence', - '', - array( - 'product' => array( - 'name' => 'product', - 'type' => 'tns:product', - 'minOccurs' => '0', - 'maxOccurs' => 'unbounded' - ) - ) + 'ProductsArray2', + 'complexType', + 'array', + 'sequence', + '', + array( + 'product' => array( + 'name' => 'product', + 'type' => 'tns:product', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) + ) ); @@ -247,72 +247,72 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped // Register WSDL $server->register( - 'getProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'product'=>'tns:product'), - $ns, - $ns.'#getProductOrService', - $styledoc, - $styleuse, - 'WS to get product or service' + 'getProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'product'=>'tns:product'), + $ns, + $ns.'#getProductOrService', + $styledoc, + $styleuse, + 'WS to get product or service' ); // Register WSDL $server->register( - 'createProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), - // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), - $ns, - $ns.'#createProductOrService', - $styledoc, - $styleuse, - 'WS to create a product or service' + 'createProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + // Exit values + array('result'=>'tns:result', 'id'=>'xsd:string'), + $ns, + $ns.'#createProductOrService', + $styledoc, + $styleuse, + 'WS to create a product or service' ); // Register WSDL $server->register( - 'updateProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), - // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), - $ns, - $ns.'#updateProductOrService', - $styledoc, - $styleuse, - 'WS to update a product or service' + 'updateProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + // Exit values + array('result'=>'tns:result', 'id'=>'xsd:string'), + $ns, + $ns.'#updateProductOrService', + $styledoc, + $styleuse, + 'WS to update a product or service' ); // Register WSDL $server->register( - 'deleteProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'), - $ns, - $ns.'#deleteProductOrService', - $styledoc, - $styleuse, - 'WS to delete a product or service' + 'deleteProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'), + $ns, + $ns.'#deleteProductOrService', + $styledoc, + $styleuse, + 'WS to delete a product or service' ); // Register WSDL $server->register( - 'getListOfProductsOrServices', - // Entry values - array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'), - // Exit values - array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), - $ns, - $ns.'#getListOfProductsOrServices', - $styledoc, - $styleuse, - 'WS to get list of all products or services id and ref' + 'getListOfProductsOrServices', + // Entry values + array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'), + // Exit values + array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), + $ns, + $ns.'#getListOfProductsOrServices', + $styledoc, + $styleuse, + 'WS to get list of all products or services id and ref' ); // Register WSDL @@ -342,131 +342,131 @@ $server->register( */ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '', $lang = '') { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); + dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); - $langs->setDefaultLang($langcode); + $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); - $langs->setDefaultLang($langcode); + if (!$error) + { + $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); - $fuser->getrights(); + $fuser->getrights(); - $nbmax = 10; - if ($fuser->rights->produit->lire || $fuser->rights->service->lire) - { - $product = new Product($db); - $result = $product->fetch($id, $ref, $ref_ext); + $nbmax = 10; + if ($fuser->rights->produit->lire || $fuser->rights->service->lire) + { + $product = new Product($db); + $result = $product->fetch($id, $ref, $ref_ext); - if ($result > 0) - { - $product->load_stock(); + if ($result > 0) + { + $product->load_stock(); - $dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output); - $pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/"; - $dir = $dir.'/'.$pdir; + $dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output); + $pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/"; + $dir = $dir.'/'.$pdir; - if (!empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; - if (!empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"]; - if (!empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"]; + if (!empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; + if (!empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"]; + if (!empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"]; - $productorservice_result_fields = array( - 'id' => $product->id, - 'ref' => $product->ref, - 'ref_ext' => $product->ref_ext, - 'label' => $product->label, - 'description' => $product->description, - 'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'), - 'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'), - 'note' => $product->note, - 'status_tosell' => $product->status, - 'status_tobuy' => $product->status_buy, - 'type' => $product->type, - 'barcode' => $product->barcode, - 'barcode_type' => $product->barcode_type, - 'country_id' => $product->country_id > 0 ? $product->country_id : '', - 'country_code' => $product->country_code, - 'custom_code' => $product->customcode, + $productorservice_result_fields = array( + 'id' => $product->id, + 'ref' => $product->ref, + 'ref_ext' => $product->ref_ext, + 'label' => $product->label, + 'description' => $product->description, + 'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'), + 'note' => $product->note, + 'status_tosell' => $product->status, + 'status_tobuy' => $product->status_buy, + 'type' => $product->type, + 'barcode' => $product->barcode, + 'barcode_type' => $product->barcode_type, + 'country_id' => $product->country_id > 0 ? $product->country_id : '', + 'country_code' => $product->country_code, + 'custom_code' => $product->customcode, - 'price_net' => $product->price, - 'price' => $product->price_ttc, - 'price_min_net' => $product->price_min, - 'price_min' => $product->price_min_ttc, - 'price_base_type' => $product->price_base_type, - 'vat_rate' => $product->tva_tx, - //! French VAT NPR - 'vat_npr' => $product->tva_npr, - //! Spanish local taxes - 'localtax1_tx' => $product->localtax1_tx, - 'localtax2_tx' => $product->localtax2_tx, + 'price_net' => $product->price, + 'price' => $product->price_ttc, + 'price_min_net' => $product->price_min, + 'price_min' => $product->price_min_ttc, + 'price_base_type' => $product->price_base_type, + 'vat_rate' => $product->tva_tx, + //! French VAT NPR + 'vat_npr' => $product->tva_npr, + //! Spanish local taxes + 'localtax1_tx' => $product->localtax1_tx, + 'localtax2_tx' => $product->localtax2_tx, - 'stock_real' => $product->stock_reel, - 'stock_virtual' => $product->stock_theorique, - 'stock_alert' => $product->seuil_stock_alerte, - 'pmp' => $product->pmp, - 'import_key' => $product->import_key, - 'dir' => $pdir, - 'images' => $product->liste_photos($dir, $nbmax) - ); + 'stock_real' => $product->stock_reel, + 'stock_virtual' => $product->stock_theorique, + 'stock_alert' => $product->seuil_stock_alerte, + 'pmp' => $product->pmp, + 'import_key' => $product->import_key, + 'dir' => $pdir, + 'images' => $product->liste_photos($dir, $nbmax) + ); - $elementtype = 'product'; + $elementtype = 'product'; - //Retrieve all extrafield for thirdsparty - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $product->fetch_optionals(); + //Retrieve all extrafield for thirdsparty + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $product->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'product'=>$productorservice_result_fields - ); - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; - } - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'product'=>$productorservice_result_fields + ); + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + } + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } //var_dump($objectresp);exit; - return $objectresp; + return $objectresp; } @@ -479,54 +479,54 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' */ function createProductOrService($authentication, $product) { - global $db, $conf, $langs; + global $db, $conf, $langs; - $now = dol_now(); + $now = dol_now(); - dol_syslog("Function: createProductOrService login=".$authentication['login']); + dol_syslog("Function: createProductOrService login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if ($product['price_net'] > 0) $product['price_base_type'] = 'HT'; - if ($product['price'] > 0) $product['price_base_type'] = 'TTC'; + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if ($product['price_net'] > 0) $product['price_base_type'] = 'HT'; + if ($product['price'] > 0) $product['price_base_type'] = 'TTC'; - if ($product['price_net'] > 0 && $product['price'] > 0) - { - $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price."; - } + if ($product['price_net'] > 0 && $product['price'] > 0) + { + $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price."; + } - if ($product['barcode'] && !$product['barcode_type']) - { - $error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode."; - } + if ($product['barcode'] && !$product['barcode_type']) + { + $error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode."; + } - if (!$error) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + if (!$error) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $newobject = new Product($db); - $newobject->ref = $product['ref']; - $newobject->ref_ext = $product['ref_ext']; - $newobject->type = $product['type']; - $newobject->label = $product['label']; - $newobject->description = $product['description']; - $newobject->note_public = $product['note_public']; - $newobject->note_private = $product['note_private']; - $newobject->status = $product['status_tosell']; - $newobject->status_buy = $product['status_tobuy']; - $newobject->price = $product['price_net']; - $newobject->price_ttc = $product['price']; - $newobject->tva_tx = $product['vat_rate']; - $newobject->price_base_type = $product['price_base_type']; - $newobject->date_creation = $now; + $newobject = new Product($db); + $newobject->ref = $product['ref']; + $newobject->ref_ext = $product['ref_ext']; + $newobject->type = $product['type']; + $newobject->label = $product['label']; + $newobject->description = $product['description']; + $newobject->note_public = $product['note_public']; + $newobject->note_private = $product['note_private']; + $newobject->status = $product['status_tosell']; + $newobject->status_buy = $product['status_tobuy']; + $newobject->price = $product['price_net']; + $newobject->price_ttc = $product['price']; + $newobject->tva_tx = $product['vat_rate']; + $newobject->price_base_type = $product['price_base_type']; + $newobject->date_creation = $now; if ($product['barcode']) { @@ -534,16 +534,16 @@ function createProductOrService($authentication, $product) $newobject->barcode_type = $product['barcode_type']; } - $newobject->stock_reel = $product['stock_real']; - $newobject->pmp = $product['pmp']; - $newobject->seuil_stock_alert = $product['stock_alert']; + $newobject->stock_reel = $product['stock_real']; + $newobject->pmp = $product['pmp']; + $newobject->seuil_stock_alert = $product['stock_alert']; - $newobject->country_id = $product['country_id']; - if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3); - $newobject->customcode = $product['customcode']; + $newobject->country_id = $product['country_id']; + if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3); + $newobject->customcode = $product['customcode']; - $newobject->canvas = $product['canvas']; - /*foreach($product['lines'] as $line) + $newobject->canvas = $product['canvas']; + /*foreach($product['lines'] as $line) { $newline=new FactureLigne($db); $newline->type=$line['type']; @@ -556,13 +556,13 @@ function createProductOrService($authentication, $product) $newline->qty=$line['qty']; $newline->fk_product=$line['product_id']; }*/ - //var_dump($product['ref_ext']); - //var_dump($product['lines'][0]['type']); + //var_dump($product['ref_ext']); + //var_dump($product['lines'][0]['type']); - $elementtype = 'product'; + $elementtype = 'product'; - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) @@ -572,17 +572,17 @@ function createProductOrService($authentication, $product) } } - $db->begin(); + $db->begin(); - $result = $newobject->create($fuser, 0); - if ($result <= 0) - { - $error++; - } + $result = $newobject->create($fuser, 0); + if ($result <= 0) + { + $error++; + } - if (!$error) - { - // Update stock if stock count is provided and differs from database after creation or update + if (!$error) + { + // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) { include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -619,25 +619,25 @@ function createProductOrService($authentication, $product) } } - if (!$error) - { - $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $newobject->error; - } - } + if (!$error) + { + $db->commit(); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $newobject->error; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -728,15 +728,15 @@ function updateProductOrService($authentication, $product) } } - $db->begin(); + $db->begin(); - $result = $newobject->update($newobject->id, $fuser); - if ($result <= 0) - { - $error++; - } - else { - // Update stock if stock count is provided and differs from database after creation or update + $result = $newobject->update($newobject->id, $fuser); + if ($result <= 0) + { + $error++; + } + else { + // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) { include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -771,47 +771,47 @@ function updateProductOrService($authentication, $product) } } } - } + } - if (!$error) - { - if ($newobject->price_base_type == 'HT') - { - $result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser); - if ($result <= 0) - { - $error++; - } - } - elseif ($newobject->price_base_type == 'TTC') - { - $result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type); - if ($result <= 0) - { - $error++; - } - } - } + if (!$error) + { + if ($newobject->price_base_type == 'HT') + { + $result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser); + if ($result <= 0) + { + $error++; + } + } + elseif ($newobject->price_base_type == 'TTC') + { + $result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type); + if ($result <= 0) + { + $error++; + } + } + } - if (!$error) - { - $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $newobject->error; - } - } + if (!$error) + { + $db->commit(); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $newobject->error; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -824,87 +824,87 @@ function updateProductOrService($authentication, $product) */ function deleteProductOrService($authentication, $listofidstring) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: deleteProductOrService login=".$authentication['login']); + dol_syslog("Function: deleteProductOrService login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // User must be defined to user authenticated - global $user; - $user = $fuser; + global $user; + $user = $fuser; - $listofid = explode(',', trim($listofidstring)); - $listofiddeleted = array(); + $listofid = explode(',', trim($listofidstring)); + $listofiddeleted = array(); - // Check parameters - if (count($listofid) == 0 || empty($listofid[0])) - { - $error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required."; - } + // Check parameters + if (count($listofid) == 0 || empty($listofid[0])) + { + $error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required."; + } - if (!$error) - { - $firsterror = ''; + if (!$error) + { + $firsterror = ''; $db->begin(); - foreach ($listofid as $key => $id) + foreach ($listofid as $key => $id) { - $newobject = new Product($db); - $result = $newobject->fetch($id); + $newobject = new Product($db); + $result = $newobject->fetch($id); - if ($result == 0) - { - $error++; - $firsterror = 'Product or service with id '.$id.' not found'; - break; - } - else { - $result = $newobject->delete($user); - if ($result <= 0) - { - $error++; - $firsterror = $newobject->error; - break; - } + if ($result == 0) + { + $error++; + $firsterror = 'Product or service with id '.$id.' not found'; + break; + } + else { + $result = $newobject->delete($user); + if ($result <= 0) + { + $error++; + $firsterror = $newobject->error; + break; + } - $listofiddeleted[] = $id; + $listofiddeleted[] = $id; } } - if (!$error) - { - $db->commit(); - //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted)); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $firsterror; + if (!$error) + { + $db->commit(); + //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted)); } - } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $firsterror; + } + } - if ($error) - { - //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0); - } - elseif (count($listofiddeleted) == 0) - { + if ($error) + { + //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted); + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0); + } + elseif (count($listofiddeleted) == 0) + { //$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted); $objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',', $listofid).' found'), 'nbdeleted'=>0); - } + } - return $objectresp; + return $objectresp; } @@ -917,65 +917,65 @@ function deleteProductOrService($authentication, $listofidstring) */ function getListOfProductsOrServices($authentication, $filterproduct) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']); + dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $arrayproducts = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters + // Init and check authentication + $objectresp = array(); + $arrayproducts = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters - if (!$error) - { - $sql = "SELECT rowid, ref, ref_ext"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity=".$conf->entity; - foreach ($filterproduct as $key => $val) - { - if ($key == 'type' && $val >= 0) $sql .= " AND fk_product_type = ".$db->escape($val); - if ($key == 'status_tosell') $sql .= " AND tosell = ".$db->escape($val); - if ($key == 'status_tobuy') $sql .= " AND tobuy = ".$db->escape($val); - } + if (!$error) + { + $sql = "SELECT rowid, ref, ref_ext"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity=".$conf->entity; + foreach ($filterproduct as $key => $val) + { + if ($key == 'type' && $val >= 0) $sql .= " AND fk_product_type = ".$db->escape($val); + if ($key == 'status_tosell') $sql .= " AND tosell = ".$db->escape($val); + if ($key == 'status_tobuy') $sql .= " AND tobuy = ".$db->escape($val); + } $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + if ($resql) + { + $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext); - $i++; - } - } - else { - $error++; - $errorcode = $db->lasterrno(); - $errorlabel = $db->lasterror(); - } - } + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext); + $i++; + } + } + else { + $error++; + $errorcode = $db->lasterrno(); + $errorlabel = $db->lasterror(); + } + } - if ($error) - { - $objectresp = array( + if ($error) + { + $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), - 'products'=>$arrayproducts - ); - } else { - $objectresp = array( + 'products'=>$arrayproducts + ); + } else { + $objectresp = array( 'result'=>array('result_code' => 'OK', 'result_label' => ''), - 'products'=>$arrayproducts - ); - } + 'products'=>$arrayproducts + ); + } - return $objectresp; + return $objectresp; } @@ -1050,34 +1050,34 @@ function getProductsForCategory($authentication, $id, $lang = '') $dir = $dir.'/'.$pdir; $products[] = array( - 'id' => $tmpproduct->id, + 'id' => $tmpproduct->id, 'ref' => $tmpproduct->ref, 'ref_ext' => $tmpproduct->ref_ext, - 'label' => !empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label, - 'description' => !empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description, - 'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'), - 'date_modification' => dol_print_date($tmpproduct->date_modification, 'dayhourrfc'), - 'note' => !empty($tmpproduct->multilangs[$langs->defaultlang]["note"]) ? $tmpproduct->multilangs[$langs->defaultlang]["note"] : $tmpproduct->note, - 'status_tosell' => $tmpproduct->status, - 'status_tobuy' => $tmpproduct->status_buy, - 'type' => $tmpproduct->type, - 'barcode' => $tmpproduct->barcode, - 'barcode_type' => $tmpproduct->barcode_type, - 'country_id' => $tmpproduct->country_id > 0 ? $tmpproduct->country_id : '', - 'country_code' => $tmpproduct->country_code, - 'custom_code' => $tmpproduct->customcode, + 'label' => !empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label, + 'description' => !empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description, + 'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($tmpproduct->date_modification, 'dayhourrfc'), + 'note' => !empty($tmpproduct->multilangs[$langs->defaultlang]["note"]) ? $tmpproduct->multilangs[$langs->defaultlang]["note"] : $tmpproduct->note, + 'status_tosell' => $tmpproduct->status, + 'status_tobuy' => $tmpproduct->status_buy, + 'type' => $tmpproduct->type, + 'barcode' => $tmpproduct->barcode, + 'barcode_type' => $tmpproduct->barcode_type, + 'country_id' => $tmpproduct->country_id > 0 ? $tmpproduct->country_id : '', + 'country_code' => $tmpproduct->country_code, + 'custom_code' => $tmpproduct->customcode, - 'price_net' => $tmpproduct->price, - 'price' => $tmpproduct->price_ttc, - 'vat_rate' => $tmpproduct->tva_tx, + 'price_net' => $tmpproduct->price, + 'price' => $tmpproduct->price_ttc, + 'vat_rate' => $tmpproduct->tva_tx, 'price_base_type' => $tmpproduct->price_base_type, - 'stock_real' => $tmpproduct->stock_reel, - 'stock_alert' => $tmpproduct->seuil_stock_alerte, - 'pmp' => $tmpproduct->pmp, - 'import_key' => $tmpproduct->import_key, - 'dir' => $pdir, + 'stock_real' => $tmpproduct->stock_reel, + 'stock_alert' => $tmpproduct->seuil_stock_alerte, + 'pmp' => $tmpproduct->pmp, + 'import_key' => $tmpproduct->import_key, + 'dir' => $pdir, 'images' => $tmpproduct->liste_photos($dir, $nbmax) ); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 76c610fa2cd..5ad97434d07 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -34,241 +34,241 @@ require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php'; */ class ZapierApi extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'url', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'url', + ); - /** - * @var Hook $hook {@type Hook} - */ - public $hook; + /** + * @var Hook $hook {@type Hook} + */ + public $hook; - /** - * Constructor - * - * @url GET / - * - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->hook = new Hook($this->db); - } + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->hook = new Hook($this->db); + } - /** - * Get properties of a hook object - * - * Return an array with hook informations - * - * @param int $id ID of hook - * @return array|mixed data without useless information - * - * @url GET /hooks/{id} - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->read) { - throw new RestException(401); - } + /** + * Get properties of a hook object + * + * Return an array with hook informations + * + * @param int $id ID of hook + * @return array|mixed data without useless information + * + * @url GET /hooks/{id} + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } - $result = $this->hook->fetch($id); - if (!$result) { - throw new RestException(404, 'Hook not found'); - } + $result = $this->hook->fetch($id); + if (!$result) { + throw new RestException(404, 'Hook not found'); + } - if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->hook); - } + return $this->_cleanObjectDatas($this->hook); + } - /** - * Get list of possibles choices for module - * - * Return an array with hook informations - * @param integer $id ID - * - * @return array|mixed data - * - * @url GET /getmoduleschoices/ - * @throws RestException - */ - public function getModulesChoices($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->read) { - throw new RestException(401); - } - $arraychoices = array( - 'invoices' => 'Invoices', - 'orders' => 'Orders', - 'thirdparties' => 'Thirparties', - 'contacts' => 'Contacts', - ); - // $result = $this->hook->fetch($id); - // if (! $result ) { - // throw new RestException(404, 'Hook not found'); - // } + /** + * Get list of possibles choices for module + * + * Return an array with hook informations + * @param integer $id ID + * + * @return array|mixed data + * + * @url GET /getmoduleschoices/ + * @throws RestException + */ + public function getModulesChoices($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } + $arraychoices = array( + 'invoices' => 'Invoices', + 'orders' => 'Orders', + 'thirdparties' => 'Thirparties', + 'contacts' => 'Contacts', + ); + // $result = $this->hook->fetch($id); + // if (! $result ) { + // throw new RestException(404, 'Hook not found'); + // } - // if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - // throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - // } + // if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + // throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + // } - return $arraychoices; - } + return $arraychoices; + } - /** - * List hooks - * - * Get a list of hooks - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of order objects - * - * @throws RestException - * - * @url GET /hooks/ - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List hooks + * + * Get a list of hooks + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /hooks/ + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; - // Set to 1 if there is a field socid in table of object - $restrictonsocid = 0; + // Set to 1 if there is a field socid in table of object + $restrictonsocid = 0; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { - $search_sale = DolibarrApiAccess::$user->id; - } + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } - $sql = "SELECT t.rowid"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= ", sc.fk_soc, sc.fk_user"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."hook_mytable as t"; + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= ", sc.fk_soc, sc.fk_user"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."hook_mytable as t"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= " WHERE 1 = 1"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= " WHERE 1 = 1"; - // Example of use $mode - //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; - //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $tmpobject = new Hook($this->db); - if ($tmpobject->ismultientitymanaged) { - $sql .= ' AND t.entity IN ('.getEntity('hook').')'; - } - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= " AND t.fk_soc = sc.fk_soc"; - } - if ($restrictonsocid && $socid) { - $sql .= " AND t.fk_soc = ".$socid; - } - if ($restrictonsocid && $search_sale > 0) { - // Join for the needed table to filter by sale - $sql .= " AND t.rowid = sc.fk_soc"; - } - // Insert sale filter - if ($restrictonsocid && $search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; - } - 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).")"; - } + $tmpobject = new Hook($this->db); + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity('hook').')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".$socid; + } + if ($restrictonsocid && $search_sale > 0) { + // Join for the needed table to filter by sale + $sql .= " AND t.rowid = sc.fk_soc"; + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; + } + 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 .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - $i = 0; - if ($result) { - $num = $this->db->num_rows($result); - while ($i < $num) { - $obj = $this->db->fetch_object($result); - $hook_static = new Hook($this->db); - if ($hook_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($hook_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve hook list'); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No hook found'); - } - return $obj_ret; - } + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $hook_static = new Hook($this->db); + if ($hook_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($hook_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve hook list'); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No hook found'); + } + return $obj_ret; + } - /** - * Create hook object - * - * @param array $request_data Request datas - * @return int ID of hook - * - * @url POST /hook/ - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->zapier->write) { - throw new RestException(401); - } - // Check mandatory fields - $fields = array( - 'url', - ); - $result = $this->validate($request_data, $fields); + /** + * Create hook object + * + * @param array $request_data Request datas + * @return int ID of hook + * + * @url POST /hook/ + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->zapier->write) { + throw new RestException(401); + } + // Check mandatory fields + $fields = array( + 'url', + ); + $result = $this->validate($request_data, $fields); - foreach ($request_data as $field => $value) { - $this->hook->$field = $value; - } - $this->hook->fk_user = DolibarrApiAccess::$user->id; - // on crée le hook dans la base - if (!$this->hook->create(DolibarrApiAccess::$user)) { - throw new RestException(500, "Error creating Hook", array_merge(array($this->hook->error), $this->hook->errors)); - } - return array( - 'id' => $this->hook->id, - ); - } + foreach ($request_data as $field => $value) { + $this->hook->$field = $value; + } + $this->hook->fk_user = DolibarrApiAccess::$user->id; + // on crée le hook dans la base + if (!$this->hook->create(DolibarrApiAccess::$user)) { + throw new RestException(500, "Error creating Hook", array_merge(array($this->hook->error), $this->hook->errors)); + } + return array( + 'id' => $this->hook->id, + ); + } - // /** - // * Update hook - // * - // * @param int $id Id of hook to update - // * @param array $request_data Datas - // * @return int - // * - // * @url PUT /hooks/{id} - // */ - /*public function put($id, $request_data = null) + // /** + // * Update hook + // * + // * @param int $id Id of hook to update + // * @param array $request_data Datas + // * @return int + // * + // * @url PUT /hooks/{id} + // */ + /*public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->zapier->write) { throw new RestException(401); @@ -297,80 +297,80 @@ class ZapierApi extends DolibarrApi } }*/ - /** - * Delete hook - * - * @param int $id Hook ID - * @return array - * - * @url DELETE /hook/{id} - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->delete) { - throw new RestException(401); - } - $result = $this->hook->fetch($id); - if (!$result) { - throw new RestException(404, 'Hook not found'); - } + /** + * Delete hook + * + * @param int $id Hook ID + * @return array + * + * @url DELETE /hook/{id} + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->delete) { + throw new RestException(401); + } + $result = $this->hook->fetch($id); + if (!$result) { + throw new RestException(404, 'Hook not found'); + } - if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->hook->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when deleting Hook : '.$this->hook->error); - } + if (!$this->hook->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting Hook : '.$this->hook->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Hook deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Hook deleted' + ) + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - public function _cleanObjectDatas($object) - { - // phpcs:disable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + public function _cleanObjectDatas($object) + { + // phpcs:disable + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); + /*unset($object->note); unset($object->address); unset($object->barcode_type); unset($object->barcode_type_code); unset($object->barcode_type_label); unset($object->barcode_type_coder);*/ - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array $data Array of data to validate - * @param array $fields Array of fields needed - * @return array - * - * @throws RestException - */ - private function validate($data, $fields) - { - $hook = array(); - foreach ($fields as $field) { - if (!isset($data[$field])) { - throw new RestException(400, $field." field missing"); - } - $hook[$field] = $data[$field]; - } - return $hook; - } + /** + * Validate fields before create or update object + * + * @param array $data Array of data to validate + * @param array $fields Array of fields needed + * @return array + * + * @throws RestException + */ + private function validate($data, $fields) + { + $hook = array(); + foreach ($fields as $field) { + if (!isset($data[$field])) { + throw new RestException(400, $field." field missing"); + } + $hook[$field] = $data[$field]; + } + return $hook; + } } diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index 9e987d88322..8450ec3e0d8 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -53,8 +53,8 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : (int) GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action - $page = 0; + // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -76,19 +76,19 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - // Set here default search field. By default 1st field in definition. - $sortfield = "t.".key($object->fields); + // Set here default search field. By default 1st field in definition. + $sortfield = "t.".key($object->fields); } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "ASC"; } // Security check $socid = 0; if ($user->socid > 0) { - // Protection if external user - //$socid = $user->socid; - accessforbidden(); + // Protection if external user + //$socid = $user->socid; + accessforbidden(); } //$result = restrictedArea($user, 'zapier', $id, ''); @@ -96,27 +96,27 @@ if ($user->socid > 0) { $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list $arrayfields = array(); foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // 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])); - } + 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])); + } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -128,11 +128,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; + $massaction = ''; } $parameters = array(); @@ -140,30 +140,30 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // 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')) { - // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { - $search[$key] = ''; - } - $toselect = ''; - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } + // Purge search criteria + 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 + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } - // Mass actions - $objectclass = 'Hook'; - $objectlabel = 'Hook'; - $permissiontoread = $user->rights->zapier->read; - $permissiontodelete = $user->rights->zapier->delete; - $uploaddir = $conf->zapier->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass = 'Hook'; + $objectlabel = 'Hook'; + $permissiontoread = $user->rights->zapier->read; + $permissiontodelete = $user->rights->zapier->delete; + $uploaddir = $conf->zapier->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -185,13 +185,13 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Hooks")); // -------------------------------------------------------------------- $sql = 'SELECT '; foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } } // Add fields from hooks $parameters = array(); @@ -201,21 +201,21 @@ $sql = preg_replace('/, $/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { - $sql .= " WHERE 1 = 1"; + $sql .= " WHERE 1 = 1"; } foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); - } + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } } if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -245,35 +245,35 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { - // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { + // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $num = $nbtotalofrecords; + $num = $nbtotalofrecords; } else { - $sql .= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } - $num = $db->num_rows($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) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); + exit; } @@ -303,13 +303,13 @@ $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } else { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } } if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -317,8 +317,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -337,9 +337,9 @@ print ''; $newcardbutton = ''; //if ($user->rights->zapier->creer) //{ - $newcardbutton = ''.$langs->trans('New').''; - $newcardbutton .= ''; - $newcardbutton .= ''; + $newcardbutton = ''.$langs->trans('New').''; + $newcardbutton .= ''; + $newcardbutton .= ''; //} //else //{ @@ -358,8 +358,8 @@ $trackid = 'xxxx'.$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).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -373,9 +373,9 @@ if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; + print '
'; + print $moreforfilter; + print '
'; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; @@ -390,22 +390,22 @@ print ''; foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - } + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -426,25 +426,25 @@ print ''."\n"; // -------------------------------------------------------------------- print ''; foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - } + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } } // 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, + 'arrayfields' => $arrayfields, + 'param' => $param, + 'sortfield' => $sortfield, + 'sortorder' => $sortorder, ); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -456,12 +456,12 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) { - // There is at least one compute field that use $object - $needToFetchEachLine++; - } - } + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + // There is at least one compute field that use $object + $needToFetchEachLine++; + } + } } @@ -470,71 +470,71 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co $i = 0; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } - // Store properties in $object - $object->id = $obj->rowid; - foreach ($object->fields as $key => $val) { - if (isset($obj->$key)) $object->$key = $obj->$key; - } + // Store properties in $object + $object->id = $obj->rowid; + foreach ($object->fields as $key => $val) { + if (isset($obj->$key)) $object->$key = $obj->$key; + } - // Show here line of result - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); - else print $object->showOutputField($val, $key, $obj->$key, ''); - print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; - print ''; + print ''; - $i++; + $i++; } // Show total line @@ -543,21 +543,21 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $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 ''; } $db->free($resql); $parameters = array( - 'arrayfields' => $arrayfields, - 'sql' => $sql, + 'arrayfields' => $arrayfields, + 'sql' => $sql, ); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -568,23 +568,23 @@ print ''."\n"; print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir = $diroutputmassaction; - $genallowed = $user->rights->zapier->read; - $delallowed = $user->rights->zapier->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->zapier->read; + $delallowed = $user->rights->zapier->create; - print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page From 33e56a2d7c090276a553efad81e1f536223b2882 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Oct 2020 19:56:36 +0100 Subject: [PATCH 024/247] Fix decimal qty for #14666 --- htdocs/comm/propal/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7190168b513..dd84fbd651a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -806,7 +806,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); if (empty($remise_percent)) $remise_percent = 0; @@ -1229,7 +1229,10 @@ if (empty($reshook)) } } } - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); + + $qty = price2num(GETPOST('qty'), 'MS'); + + $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); if ($result >= 0) { $db->commit(); From 7d30a11a26739aadc8b2778f72af84b530bbc4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:06:49 +0100 Subject: [PATCH 025/247] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6b76148d350..641ec29781e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1086,27 +1086,36 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoreta } } - /** * Convert a string to lower. Never use strtolower because it does not works with UTF8 strings. * - * @param string $utf8_string String to encode + * @param string $string String to encode + * @param string $encoding Character set encoding * @return string String converted */ -function dol_strtolower($utf8_string) +function dol_strtolower($string, $encoding = "UTF-8") { - return mb_strtolower($utf8_string, "UTF-8"); + if (function_exists('mb_strtolower')) { + return mb_strtolower($string, $encoding); + } else { + return strtolower($string); + } } /** * Convert a string to upper. Never use strtolower because it does not works with UTF8 strings. * - * @param string $utf8_string String to encode + * @param string $string String to encode + * @param string $encoding Character set encoding * @return string String converted */ -function dol_strtoupper($utf8_string) +function dol_strtoupper($string, $encoding = "UTF-8") { - return mb_strtoupper($utf8_string, "UTF-8"); + if (function_exists('mb_strtoupper')) { + return mb_strtoupper($string, $encoding); + } else { + return strtoupper($string); + } } From 6d6b143011f2fc0fc70cbea146ebd478b8a3336c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:11:18 +0100 Subject: [PATCH 026/247] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3f128ab9c5a..d0e2c6c382f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -590,6 +590,7 @@ class Adherent extends CommonObject $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(trim($this->lastname)); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($this->firstname)); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); From 0a024f285db01799c7dd963c824ccb696d3278e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:13:01 +0100 Subject: [PATCH 027/247] Update contact.class.php --- htdocs/contact/class/contact.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ab6e3c732c9..9cb5f4a7867 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -354,7 +354,7 @@ class Contact extends CommonObject $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->firstname = trim($this->firstname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; @@ -465,7 +465,7 @@ class Contact extends CommonObject // Clean parameters if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); From 4f3b732ed59cd39e5585fbacee5eb48f61ae3bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:14:42 +0100 Subject: [PATCH 028/247] Update societe.class.php --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9078b2146d4..c1fd09c6c50 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -790,7 +790,7 @@ class Societe extends CommonObject if (empty($this->status)) $this->status = 0; $this->name = $this->name ?trim($this->name) : trim($this->nom); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); $this->nom = $this->name; // For backward compatibility if (empty($this->client)) $this->client = 0; if (empty($this->fournisseur)) $this->fournisseur = 0; @@ -1095,7 +1095,7 @@ class Societe extends CommonObject $now = dol_now(); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); // Clean parameters $this->id = $id; $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); From 584373af55981b2dbc37999890ecc08dbc7a37e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:15:46 +0100 Subject: [PATCH 029/247] Update user.class.php --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b6db00d2d16..488414f24c6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1124,7 +1124,7 @@ class User extends CommonObject // Clean parameters if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->login = trim($this->login); @@ -1469,7 +1469,7 @@ class User extends CommonObject // Clean parameters if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->lastname = trim($this->lastname); From 991273bd100a8aae50f9536372c08f9ce3f70448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:44:17 +0100 Subject: [PATCH 030/247] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 641ec29781e..df2eab61378 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1118,6 +1118,37 @@ function dol_strtoupper($string, $encoding = "UTF-8") } } +/** + * Convert first character of the first word of a string to upper. Never use ucfirst because it does not works with UTF8 strings. + * + * @param string $string String to encode + * @param string $encoding Character set encodign + * @return string String converted + */ +function dol_ucfirst($string, $encoding = "UTF-8") +{ + if (function_exists('mb_substr')) { + return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding) . mb_substr($string, 1, null, $encoding); + } else { + return ucfirst($string); + } +} + +/** + * Convert first character of all the words of a string to upper. Never use ucfirst because it does not works with UTF8 strings. + * + * @param string $string String to encode + * @param string $encoding Character set encodign + * @return string String converted + */ +function dol_ucwords($string, $encoding = "UTF-8") +{ + if (function_exists('mb_convert_case')) { + return mb_convert_case($string, MB_CASE_TITLE, $encoding); + } else { + return ucwords($string); + } +} /** * Write log message into outputs. Possible outputs can be: From b9f593b73ad347c9c33135eee782df352e879993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:46:32 +0100 Subject: [PATCH 031/247] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index d0e2c6c382f..b67ded65c6e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -589,9 +589,9 @@ class Adherent extends CommonObject $this->town = ($this->town ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(trim($this->lastname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($this->firstname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); From 5a01d9149231f62295ce4f87026bcd7476c3260f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:48:13 +0100 Subject: [PATCH 032/247] Update contact.class.php --- htdocs/contact/class/contact.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 9cb5f4a7867..2034803ecb8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -353,9 +353,9 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->firstname = trim($this->firstname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -464,9 +464,9 @@ class Contact extends CommonObject $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->firstname = trim($this->firstname); From 0ff32c7074b25d61f305b85f7215938ce98f8ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:50:11 +0100 Subject: [PATCH 033/247] Update societe.class.php --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c1fd09c6c50..3047e986df8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -789,7 +789,7 @@ class Societe extends CommonObject // Clean parameters if (empty($this->status)) $this->status = 0; $this->name = $this->name ?trim($this->name) : trim($this->nom); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); $this->nom = $this->name; // For backward compatibility if (empty($this->client)) $this->client = 0; @@ -1094,7 +1094,7 @@ class Societe extends CommonObject $now = dol_now(); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); // Clean parameters $this->id = $id; From 039bc3c412bb75deacaadfad7ab96e8de95fdb80 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Oct 2020 20:50:33 +0100 Subject: [PATCH 034/247] Fix phpunit --- test/phpunit/PaypalTest.php | 2 +- test/phpunit/RestAPIDocumentTest.php | 6 +++--- test/phpunit/RestAPIUserTest.php | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index 47d8341f501..19774a11c09 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -146,7 +146,7 @@ class PaypalTest extends PHPUnit\Framework\TestCase $urltotest=getPaypalPaymentUrl(0, 'free'); print "urltotest=".$urltotest."\n"; - $result=getURLContent($urltotest, 'GET'); + $result=getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2); print __METHOD__." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 65b8c206c9d..06094904bd9 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -120,7 +120,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase $password = 'admin'; $url = $this->api_url.'/login?login='.$login.'&password='.$password; // Call the API login method to save api_key for this test class - $result = getURLContent($url, 'GET', '', 1, array()); + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); echo __METHOD__.' result = '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -171,7 +171,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result = getURLContent($url, 'POST', $data, 1); + $result = getURLContent($url, 'POST', $data, 1,array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $object = json_decode($result['content'], true); @@ -192,7 +192,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result2 = getURLContent($url, 'POST', $data, 1); + $result2 = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result2, true)."\n"; echo __METHOD__.' curl_error_no: '.$result2['curl_error_no']."\n"; $object2 = json_decode($result2['content'], true); diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 9d49d10af73..a937bdbd9f8 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -125,7 +125,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $password='admin'; $url=$this->api_url.'/login?login='.$login.'&password='.$password; // Call the API login method to save api_key for this test class - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); print __METHOD__." result = ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -163,7 +163,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase //$addheaders=array('Content-Type: application/json'); print __METHOD__." Request GET url=".$url."\n"; - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -174,7 +174,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $url = $this->api_url.'/users/1?api_key='.$this->api_key; print __METHOD__." Request GET url=".$url."\n"; - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -203,7 +203,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $body = json_encode($bodyobj); print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -221,7 +221,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase ); $body = json_encode($bodyobj); print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); print __METHOD__." Result code for creating user ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -231,7 +231,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase // attempt to create duplicated user print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); //print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); From 19ff2ef19e22472eb426437fa73d069968b07971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 20:52:37 +0100 Subject: [PATCH 035/247] Update user.class.php --- htdocs/user/class/user.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 488414f24c6..87f36cab15a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1123,9 +1123,9 @@ class User extends CommonObject // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value @@ -1468,9 +1468,9 @@ class User extends CommonObject // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); From 7a7a6f801848a186f032e5a837b1c3df8ea041ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 21:28:26 +0100 Subject: [PATCH 036/247] fix phpcs --- dev/setup/codesniffer/ruleset.xml | 1 + htdocs/compta/cashcontrol/report.php | 17 ++++++----------- htdocs/core/lib/geturl.lib.php | 16 ++++++---------- test/phpunit/RestAPIDocumentTest.php | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 03104270dcf..bf283993628 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -17,6 +17,7 @@ */nltechno* */htdocs/includes */htdocs/includes + .git diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 5df55ab7849..c474054b2b4 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -29,7 +29,7 @@ * \brief List of bank transactions */ -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification require '../../main.inc.php'; @@ -125,8 +125,7 @@ elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate( else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -166,12 +165,10 @@ if ($resql) $totalarray = array(); $cachebankaccount = array(); $amountpertype = array(); - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); - if (empty($cachebankaccount[$objp->bankid])) - { + if (empty($cachebankaccount[$objp->bankid])) { $bankaccounttmp = new Account($db); $bankaccounttmp->fetch($objp->bankid); $cachebankaccount[$objp->bankid] = $bankaccounttmp; @@ -235,8 +232,7 @@ if ($resql) // Debit print ''; @@ -758,24 +716,21 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print ''; print ''; - if ($num > 0) - { + if ($num > 0) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projecttmp = new Project($db); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); $projecttmp->fetch($obj->id); // To verify role of users $userAccess = $projecttmp->restrictedProjectArea($user); - if ($user->rights->projet->lire && $userAccess > 0) - { + if ($user->rights->projet->lire && $userAccess > 0) { print ''; // Ref @@ -791,8 +746,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print ''; // Opp amount print ''; @@ -889,8 +843,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "t.lastname"; - if (!empty($conf->clicktodial->enabled)) - { + if (!empty($conf->clicktodial->enabled)) { $user->fetch_clicktodial(); // lecture des infos de clicktodial du user } @@ -917,10 +870,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), ); // Extra fields - if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) - { - foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) - { + if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) { + foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], @@ -933,8 +884,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Initialize array of search criterias $search = array(); - foreach ($arrayfields as $key => $val) - { + foreach ($arrayfields as $key => $val) { $queryName = 'search_'.substr($key, 2); if (GETPOST($queryName, 'alpha')) { $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); @@ -943,8 +893,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); // Purge search criteria - 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 - { + 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_status = ''; $search_name = ''; $search_roles = array(); @@ -953,8 +902,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $search = array(); $search_array_options = array(); - foreach ($contactstatic->fields as $key => $val) - { + foreach ($contactstatic->fields as $key => $val) { $search[$key] = ''; } } @@ -963,8 +911,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $arrayfields = dol_sort_array($arrayfields, 'position'); $newcardbutton = ''; - if ($user->rights->societe->contact->creer) - { + if ($user->rights->societe->contact->creer) { $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } @@ -1030,14 +977,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Fields title search // -------------------------------------------------------------------- print ''; - foreach ($contactstatic->fields as $key => $val) - { + foreach ($contactstatic->fields as $key => $val) { $align = ''; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; - if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) { print ''; - foreach ($contactstatic->fields as $key => $val) - { + foreach ($contactstatic->fields as $key => $val) { $align = ''; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; @@ -1091,12 +1035,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $i = -1; - if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) - { + if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); $contactstatic->id = $obj->rowid; @@ -1129,10 +1071,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') setEventMessages(null, $contactstatic->errors, 'errors'); } - if (is_array($contactstatic->array_options)) - { - foreach ($contactstatic->array_options as $key => $val) - { + if (is_array($contactstatic->array_options)) { + foreach ($contactstatic->array_options as $key => $val) { $obj->$key = $val; } } @@ -1140,16 +1080,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; // ID - if (!empty($arrayfields['t.rowid']['checked'])) - { + if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } // Photo - Name - if (!empty($arrayfields['t.name']['checked'])) - { + if (!empty($arrayfields['t.name']['checked'])) { print ''; } // Address - Phone - Email - if (!empty($arrayfields['t.address']['checked'])) - { + if (!empty($arrayfields['t.address']['checked'])) { print ''; } // Role - if (!empty($arrayfields['sc.role']['checked'])) - { + if (!empty($arrayfields['sc.role']['checked'])) { print ''; } // Status - if (!empty($arrayfields['t.statut']['checked'])) - { + if (!empty($arrayfields['t.statut']['checked'])) { print ''; } @@ -1194,16 +1128,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; print ' '; - print ' '; + print ' '; print ''; 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 ($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 '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'; - if ($objp->amount < 0) - { + if ($objp->amount < 0) { print price($objp->amount * -1); $totalarray['val']['totaldebfield'] += $objp->amount; $amountpertype[$objp->code] += $objp->amount; @@ -247,8 +243,7 @@ if ($resql) // Credit print ''; - if ($objp->amount > 0) - { + if ($objp->amount > 0) { print price($objp->amount); $totalarray['val']['totalcredfield'] += $objp->amount; $amountpertype[$objp->code] -= $objp->amount; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 9a4ac16e2f2..58b19c687e3 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -76,7 +76,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = // Restrict use to some protocols only $protocols = 0; if (is_array($allowedschemes)) { - foreach($allowedschemes as $allowedscheme) { + foreach ($allowedschemes as $allowedscheme) { if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP; if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS; } @@ -129,8 +129,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $info = array(); $response = ''; - do - { + do { if ($maxRedirection < 1) break; curl_setopt($ch, CURLOPT_URL, $newUrl); @@ -187,7 +186,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $http_code = 0; } } - while($http_code); + while ($http_code); $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request @@ -196,8 +195,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it $rep = array(); - if (curl_errno($ch)) - { + if (curl_errno($ch)) { // Ad keys to $rep $rep['content'] = $response; @@ -240,14 +238,12 @@ function getDomainFromURL($url, $mode = 0) { $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain - if ($mode == 2) - { + if ($mode == 2) { $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' } else { $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' } - if (empty($mode)) - { + if (empty($mode)) { $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) } diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 06094904bd9..8dbaafab018 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -171,7 +171,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result = getURLContent($url, 'POST', $data, 1,array(), array('http', 'https'), 2); + $result = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $object = json_decode($result['content'], true); From 9ba22d28135bc1b8a4933301877fbbc5dffb4ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 22:07:31 +0100 Subject: [PATCH 037/247] doxygen --- htdocs/accountancy/class/bookkeeping.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f5f4bf80221..4e49cb1ab17 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1530,14 +1530,14 @@ class BookKeeping extends CommonObject $this->label_compte = 'Customer'; $this->label_operation = 'Sales of pea'; $this->debit = 99.9; - $this->credit = ''; - $this->montant = ''; + $this->credit = 0.0; + $this->amount = 0.0; $this->sens = 'D'; $this->fk_user_author = $user->id; - $this->import_key = ''; + $this->import_key = '20201027'; $this->code_journal = 'VT'; $this->journal_label = 'Journal de vente'; - $this->piece_num = ''; + $this->piece_num = 1234; $this->date_creation = $now; } From e4dfed53c2857ddf8cd260b3fbc0ec40f105ba65 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 27 Oct 2020 22:42:48 +0100 Subject: [PATCH 038/247] new maildev work in docker compose --- build/docker/Dockerfile | 15 ++++++++++++++- build/docker/README.md | 7 +++++-- build/docker/docker-compose.yml | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 2be287c2db9..dca74e9e720 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -20,6 +20,9 @@ RUN apt-get update -y \ unzip \ curl \ apt-utils \ + msmtp \ + msmtp-mta \ + mailutils \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ @@ -44,7 +47,17 @@ RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini -#RUN echo '172.17.0.1 docker.host' >> /etc/hosts +#RUN echo 'localhost docker.host' >> /etc/hosts + +# set up sendmail config, to use maildev +RUN echo "account default" > /etc/msmtprc +RUN echo "auth off" >> /etc/msmtprc +RUN echo "port 25" >> /etc/msmtprc +RUN echo "host mail" >> /etc/msmtprc +RUN echo "from local@localdomain.com" >> /etc/msmtprc +RUN echo "domain localhost.localdomain" >> /etc/msmtprc +RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini +RUN echo "localhost localhost.localdomain" >> /etc/hosts EXPOSE 80 diff --git a/build/docker/README.md b/build/docker/README.md index 2fd278a531f..b7e0045055a 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -25,7 +25,10 @@ The URL to go to the Dolibarr is : The URL to go to PhpMyAdmin is (login/password is root/root) : http://0.0.0.0:8080 + +In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev -Setup the database connection during the installation process, please use mariad -b (name of the database container) as database host. + http://0.0.0.0:8081 + +Setup the database connection during the installation process, please use mariadb (name of the database container) as database host. Setup documents folder, during the installation process, to /var/documents diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 7e4ceda902e..2167f069f25 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -52,3 +52,6 @@ services: ports: - "8081:80" - "25:25" + networks: + - internal-pod + - external-pod From 5d38d01a27457e5317036797650fa3891b5ddb6b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 27 Oct 2020 22:49:20 +0100 Subject: [PATCH 039/247] add new container --- build/docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/docker/README.md b/build/docker/README.md index b7e0045055a..d469c7c7aae 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -16,7 +16,7 @@ And then, you can run : docker-compose up -This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. +This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev. The URL to go to the Dolibarr is : From e8659469b903ff9254e41479000632236a92bd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 22:49:30 +0100 Subject: [PATCH 040/247] Update expedition.class.php --- htdocs/expedition/class/expedition.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 6ac3b4a5290..d86e177034e 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1738,7 +1738,7 @@ class Expedition extends CommonObject $line->total_ttc += $tabprice[2]; $line->total_tva += $tabprice[1]; } - + $line->fetch_optionals(); $i++; $originline = $obj->fk_origin_line; } From bc7c1540cc56cc328d8a3f685f870156eafc5780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 22:57:06 +0100 Subject: [PATCH 041/247] Update fichinter.class.php --- htdocs/fichinter/class/fichinter.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 2e79edd8b9e..e07771179ee 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1356,6 +1356,7 @@ class Fichinter extends CommonObject $line->datei = $this->db->jdate($objp->date); $line->rang = $objp->rang; $line->product_type = 1; + $line->fetch_optionals(); $this->lines[$i] = $line; From a1af0f11c16ff0bac301417e909ecf44a240ae19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Oct 2020 23:01:28 +0100 Subject: [PATCH 042/247] Update delivery.class.php --- htdocs/delivery/class/delivery.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 4d498d70357..c5b62d4233d 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -825,6 +825,7 @@ class Delivery extends CommonObject $line->volume_units = $obj->volume_units; $line->fk_unit = $obj->fk_unit; + $line->fetch_optionals(); $this->lines[$i] = $line; From 6fd996381e162522c5b610e685800be207799c7f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 27 Oct 2020 23:07:05 +0100 Subject: [PATCH 043/247] FIX display variant card --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index d643498162f..e6353aa9057 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -107,7 +107,7 @@ function product_prepare_head($object) $prodcomb = new ProductCombination($db); - if ($prodcomb->fetchByFkProductChild($object->id) == -1) + if ($prodcomb->fetchByFkProductChild($object->id) <= 0) { $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; $head[$h][1] = $langs->trans('ProductCombinations'); From 0d65ab0c96a8e1d389ca612891643fdb93b38dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 00:34:59 +0100 Subject: [PATCH 044/247] add cache --- htdocs/core/lib/company.lib.php | 327 ++++++++++++-------------------- 1 file changed, 125 insertions(+), 202 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 56b23722a74..c078b4d90dc 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -50,10 +50,8 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) - { - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) - { + if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // TODO @@ -61,8 +59,7 @@ function societe_prepare_head(Societe $object) $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $nbContact = $obj->nb; } @@ -82,8 +79,7 @@ function societe_prepare_head(Societe $object) $h++; } - if ($object->client == 1 || $object->client == 2 || $object->client == 3) - { + if ($object->client == 1 || $object->client == 2 || $object->client == 3) { $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; $head[$h][1] = ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); @@ -92,8 +88,7 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'customer'; $h++; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $langs->load("products"); // price $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; @@ -104,16 +99,14 @@ function societe_prepare_head(Societe $object) } $supplier_module_enabled = 0; if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; - if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) - { + if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Supplier"); $head[$h][2] = 'supplier'; $h++; } - if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) - { + if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][1] = $langs->trans("Projects"); $nbNote = 0; @@ -122,12 +115,10 @@ function societe_prepare_head(Societe $object) $sql .= " WHERE fk_soc = ".$object->id; $sql .= " AND entity IN (".getEntity('project').")"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $nbNote = $obj->nb; $i++; @@ -141,19 +132,16 @@ function societe_prepare_head(Societe $object) } // Tab to link resources - if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) - { + if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; } - if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) - { + if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { // Tab to accountancy - if (!empty($conf->accounting->enabled) && $object->client > 0) - { + if (!empty($conf->accounting->enabled) && $object->client > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringCustomer"); $head[$h][2] = 'lettering_customer'; @@ -161,8 +149,7 @@ function societe_prepare_head(Societe $object) } // Tab to accountancy - if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) - { + if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringSupplier"); $head[$h][2] = 'lettering_supplier'; @@ -172,8 +159,7 @@ function societe_prepare_head(Societe $object) // Related items if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) - { + && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][1] = $langs->trans("Referers"); $head[$h][2] = 'consumption'; @@ -181,8 +167,7 @@ function societe_prepare_head(Societe $object) } // Bank accounts - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { + if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { $nbBankAccount = 0; $foundonexternalonlinesystem = 0; $langs->load("banks"); @@ -190,8 +175,7 @@ function societe_prepare_head(Societe $object) //$title = $langs->trans("BankAccounts"); $title = $langs->trans("PaymentInformation"); - if (!empty($conf->stripe->enabled)) - { + if (!empty($conf->stripe->enabled)) { //$langs->load("stripe"); //$title = $langs->trans("BankAccountsAndGateways"); @@ -214,12 +198,10 @@ function societe_prepare_head(Societe $object) } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $nbBankAccount = $obj->nb; $i++; @@ -238,8 +220,7 @@ function societe_prepare_head(Societe $object) $h++; } - if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) - { + if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; @@ -247,12 +228,10 @@ function societe_prepare_head(Societe $object) $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $nbNote = $obj->nb; $i++; @@ -271,22 +250,18 @@ function societe_prepare_head(Societe $object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty'); - if ($user->socid == 0) - { + if ($user->socid == 0) { // Notifications - if (!empty($conf->notification->enabled)) - { + if (!empty($conf->notification->enabled)) { $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; $sql .= " WHERE fk_soc = ".$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $nbNote = $obj->nb; $i++; @@ -328,8 +303,7 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $head[$h][1] .= $langs->trans("Events"); - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $head[$h][1] .= '/'; $head[$h][1] .= $langs->trans("Agenda"); } @@ -437,8 +411,7 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $result = ''; // Check parameters - if (empty($searchkey) && empty($searchlabel)) - { + if (empty($searchkey) && empty($searchlabel)) { if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); else return ''; } @@ -451,14 +424,11 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; $resql = $dbtouse->query($sql); - if ($resql) - { + if ($resql) { $obj = $dbtouse->fetch_object($resql); - if ($obj) - { + if ($obj) { $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); - if (is_object($outputlangs)) - { + if (is_object($outputlangs)) { $outputlangs->load("dict"); if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; @@ -506,14 +476,11 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan dol_syslog("Company.lib::getState", LOG_DEBUG); $resql = $dbtouse->query($sql); - if ($resql) - { + if ($resql) { $obj = $dbtouse->fetch_object($resql); - if ($obj) - { + if ($obj) { $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); - if (is_object($outputlangs)) - { + if (is_object($outputlangs)) { $outputlangs->load("dict"); if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; @@ -567,8 +534,7 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) $outputlangs->load("dict"); // If there is a translation, we can send immediatly the label - if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) - { + if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) { return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); } @@ -577,12 +543,10 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) $sql .= " WHERE code_iso='".$db->escape($code_iso)."'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $obj = $db->fetch_object($resql); $label = ($obj->label != '-' ? $obj->label : ''); if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; @@ -611,12 +575,10 @@ function getFormeJuridiqueLabel($code) dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $obj = $db->fetch_object($resql); $label = ($obj->libelle != '-' ? $obj->libelle : ''); return $label; @@ -675,8 +637,7 @@ function getCountriesInEEC() //'CH', // Switzerland - No. Swizerland in not in EEC ); - if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) - { + if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) { // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); } @@ -719,13 +680,11 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $i = -1; - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) - { + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $langs->load("projects"); $newcardbutton = ''; - if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) - { + if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } @@ -743,8 +702,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $sql .= " ORDER BY p.dateo DESC"; $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); print '
'.$langs->trans("Status").'
'.dol_print_date($db->jdate($obj->de), "day").''; - if ($obj->opp_status_code) - { + if ($obj->opp_status_code) { print price($obj->opp_amount, 1, '', 1, -1, -1, ''); } print '
'; if (in_array($key, array('statut'))) { print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); @@ -1067,8 +1012,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Fields title label // -------------------------------------------------------------------- print '
'; print $contactstatic->id; print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage)); @@ -1157,32 +1095,28 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Job position - if (!empty($arrayfields['t.poste']['checked'])) - { + if (!empty($arrayfields['t.poste']['checked'])) { print ''; if ($obj->poste) print $obj->poste; print ''; print $contactstatic->getBannerAddress('contact', $object); print ''; print $formcompany->showRoles("roles", $contactstatic, 'view'); print ''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - { + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; print img_object($langs->trans("Event"), "action"); print '   '; } // Edit - if ($user->rights->societe->contact->creer) - { + if ($user->rights->societe->contact->creer) { print ''; print img_edit(); print ''; @@ -1288,8 +1220,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; $tms_end = strtotime($search_end); } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_start = ''; $tms_start = ''; $search_end = ''; @@ -1316,8 +1247,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $sql = ''; - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { $sql = "SELECT DISTINCT a.id, a.label as label,"; @@ -1370,32 +1300,25 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') - { + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') - { + } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') - { + } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') - { + } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') - { + } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') - { + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) - { + } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) { // Generic case $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'"; if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; @@ -1445,18 +1368,15 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } //TODO Add limit in nb of results - if ($sql) - { + if ($sql) { $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; $num = $db->num_rows($resql); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj->type == 'action') { @@ -1527,8 +1447,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } } - if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) - { + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) { $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -1540,13 +1459,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $actionstatic = new ActionComm($db); $userstatic = new User($db); + $userlinkcache = array(); $contactstatic = new Contact($db); + $elementlinkcache = array(); $out .= '
'; $out .= ''; if ($objcon && get_class($objcon) == 'Contact' && - (is_null($filterobj) || get_class($filterobj) == 'Societe')) - { + (is_null($filterobj) || get_class($filterobj) == 'Societe')) { $out .= ''; } else { $out .= ''; @@ -1559,8 +1479,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; $out .= ''; - if ($donetodo) - { + if ($donetodo) { $out .= ''; } $out .= ''; @@ -1581,8 +1500,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; $out .= ''; - if ($donetodo) - { + if ($donetodo) { $tmp = ''; if (get_class($filterobj) == 'Societe') $tmp .= ''; $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); @@ -1607,8 +1525,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); - foreach ($histo as $key => $value) - { + foreach ($histo as $key => $value) { $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo $actionstatic->type_picto = $histo[$key]['apicto']; @@ -1617,8 +1534,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; // Done or todo - if ($donetodo) - { + if ($donetodo) { $out .= ''; } @@ -1639,19 +1555,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin //$userstatic->id=$histo[$key]['userid']; //$userstatic->login=$histo[$key]['login']; //$out.=$userstatic->getLoginUrl(1); - if ($histo[$key]['userid'] > 0) - { - $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched - $out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); - } + if ($histo[$key]['userid'] > 0) { + if (isset($userlinkcache[$histo[$key]['userid']])) { + $link = $userlinkcache[$histo[$key]['userid']]; + } else { + $userstatic->fetch($histo[$key]['userid']); + $link = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + $userlinkcache[$histo[$key]['userid']] = $link; + } + $out .= $link; + } $out .= ''; // Type $out .= ''; // Contact(s) for action - if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) - { + if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { $contactstatic->lastname = $histo[$key]['lastname']; $contactstatic->firstname = $histo[$key]['firstname']; $contactstatic->id = $histo[$key]['contact_id']; @@ -1799,8 +1725,7 @@ function show_subsidiaries($conf, $langs, $db, $object) $result = $db->query($sql); $num = $db->num_rows($result); - if ($num) - { + if ($num) { $socstatic = new Societe($db); print load_fiche_titre($langs->trans("Subsidiaries"), '', ''); @@ -1814,8 +1739,7 @@ function show_subsidiaries($conf, $langs, $db, $object) $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); $socstatic->id = $obj->rowid; @@ -1873,8 +1797,7 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO global $conf, $db; // Condition on actioncode - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; else { @@ -1896,12 +1819,12 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO } /** - * Add Mailing Event Type SQL + * Add Mailing Event Type SQL * - * @param string $actioncode Action code - * @param string $objcon objcon - * @param Object $filterobj filterobj - * @return string + * @param string $actioncode Action code + * @param Object $objcon objcon + * @param Object $filterobj filterobj + * @return string */ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { From 63c5c41a7b3c754f0a9f85c1fa38db52512bbef9 Mon Sep 17 00:00:00 2001 From: Pierre Penelon Date: Wed, 28 Oct 2020 01:47:25 +0100 Subject: [PATCH 045/247] ADD Handle proposals upload in documents API --- htdocs/api/class/api_documents.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9605f46f219..70cdeb14ade 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -616,6 +616,12 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $object = new Adherent($this->db); } + elseif ($modulepart == 'proposal' || $modulepart == 'propal' || $modulepart == 'propale') + { + $modulepart = 'propale'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $object = new Propal($this->db); + } // TODO Implement additional moduleparts else { From 86ee75363a0df5f0cfb74f28909237e9d2bb3746 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 28 Oct 2020 09:49:38 +0100 Subject: [PATCH 046/247] NEW: Accountancy - Add a ledger for subaccount --- .../accountancy/bookkeeping/listbyaccount.php | 12 +- .../bookkeeping/listbysubaccount.php | 766 ++++++++++++++++++ .../accountancy/class/bookkeeping.class.php | 11 +- htdocs/langs/en_US/main.lang | 4 +- 4 files changed, 782 insertions(+), 11 deletions(-) create mode 100644 htdocs/accountancy/bookkeeping/listbysubaccount.php diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4ed055be0b1..5a197b2cc7d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); @@ -377,17 +377,13 @@ print ''; print ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); -$newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); - -$newcardbutton .= '   '; - -$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); +$newcardbutton = dolGetButtonTitle($langs->trans('ViewSubAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php new file mode 100644 index 00000000000..9f3749690e2 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -0,0 +1,766 @@ + + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France + * + * 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/accountancy/bookkeeping/listbysubaccount.php + * \ingroup Accountancy (Double entries) + * \brief List operation of ledger ordered by subaccount number + */ + +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("accountancy", "compta")); + +$action = GETPOST('action', 'aZ09'); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + +$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); +$search_label_operation = GETPOST('search_label_operation', 'alpha'); +$search_mvt_num = GETPOST('search_mvt_num', 'int'); +$search_direction = GETPOST('search_direction', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_debit = GETPOST('search_debit', 'alpha'); +$search_credit = GETPOST('search_credit', 'alpha'); +$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); +$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha'); + +if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { + $action = 'delbookkeepingyear'; +} + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if ($sortorder == "") $sortorder = "ASC"; +if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new BookKeeping($db); +$formfile = new FormFile($db); +$hookmanager->initHooks(array('bookkeepingbysubaccountlist')); + +$formaccounting = new FormAccounting($db); +$form = new Form($db); + +if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { + $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql .= $db->plimit(1); + $res = $db->query($sql); + + if ($res->num_rows > 0) { + $fiscalYear = $db->fetch_object($res); + $search_date_start = strtotime($fiscalYear->date_start); + $search_date_end = strtotime($fiscalYear->date_end); + } else { + $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + $year_end = $year_start + 1; + $month_end = $month_start - 1; + if ($month_end < 1) + { + $month_end = 12; + $year_end--; + } + $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); + $search_date_end = dol_get_last_day($year_end, $month_end); + } +} + +$arrayfields = array( + // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), + 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), + 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), + 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), + 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), + 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), + 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), + 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), +); + +if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); + +/* + * Action + */ +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$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 (empty($reshook)) +{ + include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + + 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_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_label_account = ''; + $search_doc_ref = ''; + $search_label_operation = ''; + $search_mvt_num = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; + $search_not_reconciled = ''; + } + + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + } + if (!empty($search_label_account)) { + $filter['t.label_compte'] = $search_label_account; + $param .= '&search_label_compte=' . urlencode($search_label_account); + } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + } + if (!empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $param .= '&search_label_operation=' . urlencode($search_label_operation); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction=' . urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit=' . urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit=' . urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } +} + +if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { + $import_key = GETPOST('importkey', 'alpha'); + + if (!empty($import_key)) { + $result = $object->deleteByImportkey($import_key); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } +} +if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + $delmonth = GETPOST('delmonth', 'int'); + $delyear = GETPOST('delyear', 'int'); + if ($delyear == -1) { + $delyear = 0; + } + $deljournal = GETPOST('deljournal', 'alpha'); + if ($deljournal == -1) { + $deljournal = 0; + } + + if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) + { + $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages("RecordDeleted", null, 'mesgs'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbysubaccount.php".($param ? '?'.$param : '')); + exit; + } else { + setEventMessages("NoRecordDeleted", null, 'warnings'); + } +} +if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { + $mvt_num = GETPOST('mvt_num', 'int'); + + if (!empty($mvt_num)) { + $result = $object->deleteMvtNum($mvt_num); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } + + header("Location: listbysubaccount.php?noreset=1".($param ? '&'.$param : '')); + exit; + } +} + + +/* + * View + */ + +$formaccounting = new FormAccounting($db); +$formfile = new FormFile($db); +$formother = new FormOther($db); +$form = new Form($db); + +$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')'; + +llxHeader('', $title_page); + + +// List +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} + +$num = count($object->lines); + + +if ($action == 'delmouv') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); + print $formconfirm; +} +if ($action == 'delbookkeepingyear') { + $form_question = array(); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); + + if (empty($delyear)) { + $delyear = dol_print_date(dol_now(), '%Y'); + } + $month_array = array(); + for ($i = 1; $i <= 12; $i++) { + $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); + } + $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); + + $form_question['delmonth'] = array( + 'name' => 'delmonth', + 'type' => 'select', + 'label' => $langs->trans('DelMonth'), + 'values' => $month_array, + 'default' => '' + ); + $form_question['delyear'] = array( + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + $form_question['deljournal'] = array( + 'name' => 'deljournal', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component + 'label' => $langs->trans('DelJournal'), + 'value' => $journal_array, + 'default' => $deljournal + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); + print $formconfirm; +} + + +print ''; +print ''; +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; + + +$newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); + +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); + +$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); + +// Reverse sort order +if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; +else $sortorder = "desc"; + +$moreforfilter = ''; + +// Accountancy account +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountAccounting').': '; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('From').' '; +$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= ' '.$langs->trans('to').' '; +$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + +$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; + +print '
'; +print $moreforfilter; +print '
'; + +print '
'; +print '
'; $out .= ''; // TODO Code common with code into showactions $imgpicto = ''; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actionstatic->type_picto) { $imgpicto .= img_picto('', $actionstatic->type_picto); } @@ -1679,8 +1599,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Title $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') - { + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { $transcode = $langs->trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); //$actionstatic->libelle=$libelle; @@ -1688,8 +1607,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $actionstatic->id = $histo[$key]['id']; $out .= dol_trunc($libelle, 120); } - if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') - { + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; $transcode = $langs->trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); @@ -1700,8 +1618,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Date $out .= ''; $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); - if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) - { + if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { $tmpa = dol_getdate($histo[$key]['datestart'], true); $tmpb = dol_getdate($histo[$key]['dateend'], true); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); @@ -1720,15 +1637,24 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Linked object $out .= ''; - if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) - { - $out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); - } else $out .= ' '; + if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { + if (isset($elementlinkcache[$histo[$key]['elementtype']]) && isset($elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']])) { + $link = $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']]; + } else { + if (!isset($elementlinkcache[$histo[$key]['elementtype']])) { + $elementlinkcache[$histo[$key]['elementtype']] = array(); + } + $link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); + $elementlinkcache[$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link; + } + $out .= $link; + } else { + $out .= ' '; + } $out .= '
'; + +// Filters lines +print ''; + +// Code journal +if (!empty($arrayfields['t.code_journal']['checked'])) { + print ''; +} +// Date document +if (!empty($arrayfields['t.doc_date']['checked'])) { + print ''; +} +// Movement number +if (!empty($arrayfields['t.piece_num']['checked'])) +{ + print ''; +} +// Ref document +if (!empty($arrayfields['t.doc_ref']['checked'])) { + print ''; +} +// Label operation +if (!empty($arrayfields['t.label_operation']['checked'])) { + print ''; +} +// Debit +if (!empty($arrayfields['t.debit']['checked'])) { + print ''; +} +// Credit +if (!empty($arrayfields['t.credit']['checked'])) { + print ''; +} +// Lettering code +if (!empty($arrayfields['t.lettering_code']['checked'])) +{ + print ''; +} + +// 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; + +// Action column +print ''; +print "\n"; + +print ''; +if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +// 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; +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; + + +$total_debit = 0; +$total_credit = 0; +$sous_total_debit = 0; +$sous_total_credit = 0; +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + $accountg = length_accounta($line->subledger_account); + //if (empty($accountg)) $accountg = '-'; + + // Is it a break ? + if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { + $colspan = $totalarray['nbfield'] - 3; + $colspanend = $totalarray['nbfield'] - 7; + // Show a subtotal by accounting account + if (isset($displayed_account_number)) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Show balance of last shown account + $balance = $sous_total_debit - $sous_total_credit; + print ''; + print ''; + if ($balance > 0 ) + { + print ''; + print ''; + } else { + print ''; + print ''; + } + print ''; + print ''; + } + + // Show the break account + print ""; + print ''; + print ''; + + $displayed_account_number = $accountg; + //if (empty($displayed_account_number)) $displayed_account_number='-'; + $sous_total_debit = 0; + $sous_total_credit = 0; + + $colspan = 0; + } + + print ''; + + // Journal code + if (!empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document date + if (!empty($arrayfields['t.doc_date']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Piece number + if (!empty($arrayfields['t.piece_num']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document ref + if (!empty($arrayfields['t.doc_ref']['checked'])) + { + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); + + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } + + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Label operation + if (!empty($arrayfields['t.label_operation']['checked'])) { + // Affiche un lien vers la facture client/fournisseur + $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount debit + if (!empty($arrayfields['t.debit']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; + $totalarray['val']['totaldebit'] += $line->debit; + } + + // Amount credit + if (!empty($arrayfields['t.credit']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; + $totalarray['val']['totalcredit'] += $line->credit; + } + + // Lettering code + if (!empty($arrayfields['t.lettering_code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // 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; + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + + print "\n"; + + $i++; +} + +// Show sub-total of last shown account +$colspan = $totalarray['nbfield'] - 3; +$colspanend = $totalarray['nbfield'] - 8; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Show balance of last shown account +$balance = $sous_total_debit - $sous_total_credit; +print ''; +print ''; +if ($balance > 0 ) +{ + print ''; + print ''; +} else { + print ''; + print ''; +} +print ''; +print ''; + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + +print "
'; + print '
'; + print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print '
'; + print ''; + print '
'.$langs->trans("NotReconciled").''; + print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
'; + if ($line->subledger_account != "" && $line->subledger_account != '-1') print length_accounta($line->subledger_account).' : '.$object->get_compte_desc($line->numero_compte); + else print ''.$langs->trans("Unknown").''; + print '
'.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1, '', 0, '', 1); + print ''; + + print ''; + // Picto + Ref + print '
'; + + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; + + print "
' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
'.($line->debit ? price($line->debit) : '').'' . ($line->credit ? price($line->credit) : '') . ''.$line->lettering_code.''; + if (empty($line->date_export)) { + if ($user->rights->accounting->mouvements->creer) { + print ''.img_edit().''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print '   '.img_delete().''; + } + } + print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
"; +print ''; + +// TODO Replace this with mass delete action +if ($user->rights->accounting->mouvements->supprimer_tous) { + print ''; +} + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f5f4bf80221..3dcf2784676 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -768,10 +768,11 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) * * @return int <0 if KO, >=0 if OK */ - public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) { global $conf; @@ -836,7 +837,13 @@ class BookKeeping extends CommonObject $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } // Affichage par compte comptable - $sql .= ' ORDER BY t.numero_compte ASC'; + if (!empty($option)) { + $sql .= ' AND t.subledger_account IS NOT NULL'; + $sql .= ' ORDER BY t.subledger_account ASC'; + } else { + $sql .= ' ORDER BY t.numero_compte ASC'; + } + if (!empty($sortfield)) { $sql .= ', '.$sortfield.' '.$sortorder; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1096b9857f1..2068a37af2b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -884,6 +884,8 @@ Miscellaneous=Miscellaneous Calendar=Calendar GroupBy=Group by... ViewFlatList=View flat list +ViewAccountList=View ledger +ViewSubAccountList=View subaccount ledger RemoveString=Remove string '%s' SomeTranslationAreUncomplete=Some of the languages offered may be only partially translated or may contain errors. Please help to correct your language by registering at https://transifex.com/projects/p/dolibarr/ to add your improvements. DirectDownloadLink=Direct download link (public/external) @@ -1099,4 +1101,4 @@ DateOfBirth=Date of birth SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry=Security token has expired, so action has been canceled. Please try again. UpToDate=Up-to-date OutOfDate=Out-of-date -EventReminder=Event Reminder \ No newline at end of file +EventReminder=Event Reminder From f0baa0f788505266c4befea63955ea4671b370c8 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 28 Oct 2020 12:12:29 +0100 Subject: [PATCH 047/247] fix : input type number , getpost type , hook --- htdocs/multicurrency/multicurrency_rate.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 4a76c721128..2340df84ce5 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -73,6 +73,8 @@ $object=new CurrencyRate($db); $extrafields = new ExtraFields($db); $form=new Form($db); +$hookmanager->initHooks(array('EditorRatelist', 'globallist')); + if (empty($action)) $action='list'; // List of fields to search into when doing a "search in all" @@ -127,9 +129,9 @@ if ($action == 'update'){ if ( $result > 0){ $currency_static = new MultiCurrency($db); $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code); - $currencyRate->date_sync = $db->escape(GETPOST('dateinput')); + $currencyRate->date_sync = $db->escape(GETPOST('dateinput', 'alpha')); $currencyRate->fk_multicurrency = $fk_currency; - $currencyRate->rate = $db->escape(GETPOST('rateinput')); + $currencyRate->rate = $db->escape(GETPOST('rateinput', 'int')); $res = $currencyRate->update(); if ($res){ setEventMessage($langs->trans('successUpdateRate')); @@ -174,7 +176,7 @@ if ($action == "confirm_delete"){ if ($result){ setEventMessage($langs->trans('successRateDelete')); }else { - setEventMessage($langs->trans('errorRateDelete')); + setEventMessage($langs->trans('errorRateDelete'), 'errors'); } }else { setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings"); @@ -249,7 +251,7 @@ if ($action!= "updateRate" && $action!= "deleteRate" ) { print '
' . $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true) . '' . $langs->trans('rate') . ''; print ''; From 47dfe633f9823a0d7954a4a7b29a25e547af83e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2020 13:19:35 +0100 Subject: [PATCH 048/247] Fix filter on date on statistics of products --- htdocs/product/class/product.class.php | 5 ++--- htdocs/product/stats/card.php | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 99590e27a36..ba63afdab44 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3188,7 +3188,7 @@ class Product extends CommonObject return -1; } - if (empty($year)) { + if (empty($year) || $year == -1) { $year = strftime('%Y', time()); $month = strftime('%m', time()); } @@ -3339,8 +3339,7 @@ class Product extends CommonObject public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { // phpcs:enable - global $conf; - global $user; + global $conf, $user; $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; if ($mode == 'bynumber') { diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 4600baa1597..6c6d2b80cf8 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -208,14 +208,14 @@ if ($result || empty($id)) // Year print '
'.$langs->trans("Year").''; $arrayyears = array(); - for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) + for ($year = $currentyear - 25; $year < $currentyear; $year++) { $arrayyears[$year] = $year; } if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; - if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; + if (!in_array($currentyear, $arrayyears)) $arrayyears[$currentyear] = $currentyear; arsort($arrayyears); - print $form->selectarray('search_year', $arrayyears, $search_year, 0); + print $form->selectarray('search_year', $arrayyears, $search_year, 1); print '
'; print '
'; @@ -262,49 +262,49 @@ if ($result || empty($id)) if ($conf->propal->enabled) { $graphfiles['propal'] = array('modulepart'=>'productstats_proposals', - 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals"))); } if ($conf->supplier_proposal->enabled) { $graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers', - 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); } if ($conf->order->enabled) { $graphfiles['orders'] = array('modulepart'=>'productstats_orders', - 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); } if ($conf->supplier_order->enabled) { $graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers', - 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); } if ($conf->facture->enabled) { $graphfiles['invoices'] = array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); } if ($conf->supplier_invoice->enabled) { $graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); } if ($conf->contrat->enabled) { $graphfiles['contracts'] = array('modulepart'=>'productstats_contracts', - 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); } if ($conf->mrp->enabled) { $graphfiles['mrp'] = array('modulepart'=>'productstats_mrp', - 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos"))); } From 6363a6cd606453284642e4df946f88553724ec0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2020 14:11:46 +0100 Subject: [PATCH 049/247] Fix sanitize --- htdocs/product/stats/commande.php | 2 +- htdocs/product/stats/commande_fournisseur.php | 2 +- htdocs/product/stats/facture.php | 2 +- htdocs/product/stats/facture_fournisseur.php | 2 +- htdocs/product/stats/propal.php | 2 +- htdocs/product/stats/supplier_proposal.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 9898c13f21b..b55b43d218d 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -59,7 +59,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "c.date_commande"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index c111e075972..b4a837679a9 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -61,7 +61,7 @@ if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "c.date_commande"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index d4bbe68386c..f858dbc91e4 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -61,7 +61,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "f.datef"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index f39d4ab73b3..58d52452654 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -60,7 +60,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "f.datef"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index f5b097d0655..2dffd4d78d6 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.datep"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 5a59cbb9c83..8d5b8ad14c4 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.date_valid"; -$search_month = GETPOST('search_month', 'alpha'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { From f02a35d398208ad45bdac8b5e9c7e761879e6eb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2020 16:47:00 +0100 Subject: [PATCH 050/247] Fix bad array when year is not defined into graph stat of products --- htdocs/product/class/product.class.php | 36 ++++++++++++++++---------- htdocs/product/stats/card.php | 1 + 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba63afdab44..98c4084587c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3158,14 +3158,16 @@ class Product extends CommonObject /** * Return an array formated for showing graphs * - * @param string $sql Request to execute - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $year Year (0=current year) - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param string $sql Request to execute + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $year Year (0=current year, -1=all years) + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ private function _get_stats($sql, $mode, $year = 0) { // phpcs:enable + $tab = array(); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -3173,11 +3175,14 @@ class Product extends CommonObject while ($i < $num) { $arr = $this->db->fetch_array($resql); - if ($mode == 'byunit') { - $tab[$arr[1]] = $arr[0]; // 1st field + $keyfortab = (string) $arr[1]; + if ($year == -1) { + $keyfortab = substr($keyfortab, -2); } - if ($mode == 'bynumber') { - $tab[$arr[1]] = $arr[2]; // 3rd field + if ($mode == 'byunit') { + $tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[0]; // 1st field + } elseif ($mode == 'bynumber') { + $tab[$keyfortab] = (empty($tab[$keyfortab]) ? 0 : $tab[$keyfortab]) + $arr[2]; // 3rd field } $i++; } @@ -3188,21 +3193,24 @@ class Product extends CommonObject return -1; } - if (empty($year) || $year == -1) { + if (empty($year)) { $year = strftime('%Y', time()); $month = strftime('%m', time()); - } - else - { + } elseif ($year == -1) { + $year = ''; + $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. + } else { $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. } + $result = array(); for ($j = 0; $j < 12; $j++) { - //$idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1)); - $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 1, 'right', 'UTF-8', 1)); + // $ids is 'D', 'N', 'O', 'S', ... (First letter of month in user language) + $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, 1970), "%b"), 1, 'right', 'UTF-8', 1)); + //print $idx.'-'.$year.'-'.$month.'
'; $result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0); // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 6c6d2b80cf8..fb161ea40cf 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -180,6 +180,7 @@ if (empty($id) & empty($ref)) if ($result || empty($id)) { print '
'; + print ''; print ''; print ''; From 9a85441c6147e0f371b09438cb00e2d71ff8b909 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2020 17:06:30 +0100 Subject: [PATCH 051/247] Fix phpcs --- htdocs/compta/cashcontrol/report.php | 2 +- htdocs/core/lib/geturl.lib.php | 7 +++---- test/phpunit/RestAPIDocumentTest.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 5df55ab7849..f51e068352f 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -29,7 +29,7 @@ * \brief List of bank transactions */ -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification require '../../main.inc.php'; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 9a4ac16e2f2..b1c0048081e 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -76,7 +76,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = // Restrict use to some protocols only $protocols = 0; if (is_array($allowedschemes)) { - foreach($allowedschemes as $allowedscheme) { + foreach ($allowedschemes as $allowedscheme) { if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP; if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS; } @@ -129,8 +129,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $info = array(); $response = ''; - do - { + do { if ($maxRedirection < 1) break; curl_setopt($ch, CURLOPT_URL, $newUrl); @@ -187,7 +186,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $http_code = 0; } } - while($http_code); + while ($http_code); $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 06094904bd9..8dbaafab018 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -171,7 +171,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result = getURLContent($url, 'POST', $data, 1,array(), array('http', 'https'), 2); + $result = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $object = json_decode($result['content'], true); From a4af2e94a9f550110997e86f37c582d5220d9e0f Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 28 Oct 2020 17:08:09 +0100 Subject: [PATCH 052/247] FIX 10.0 - make formConfirm an addreplace-type hook --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index f1abc148291..8c29ebad1bb 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -160,6 +160,7 @@ class HookManager 'doActions', 'doMassActions', 'formatEvent', + 'formConfirm', 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', From f760b20bdeaf1d7670c693b6b385a2589da79e6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2020 17:48:20 +0100 Subject: [PATCH 053/247] Fix double semi colon --- htdocs/core/actions_sendmails.inc.php | 2 +- htdocs/core/class/CMailFile.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f3c72257670..0be919de0dd 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -477,7 +477,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto)); $mesg .= '
'.$mailfile->error; } else { - $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));; + $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto)); if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { $mesg .= '
Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; } else { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index bb8086f9b90..7f51b47d0b6 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -862,7 +862,7 @@ class CMailFile if (!empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); - if (! empty($conf->global->$keyforsslseflsigned)) $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));; + if (!empty($conf->global->$keyforsslseflsigned)) $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false))); //$smtps->_msgReplyTo = 'reply@web.com'; // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable From 208740c9c4f71b8bdb2b6a60a2ebb36864f7b246 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 28 Oct 2020 16:49:52 +0000 Subject: [PATCH 054/247] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/delivery.php | 402 +- htdocs/comm/propal/class/propal.class.php | 338 +- htdocs/commande/card.php | 154 +- ...box_supplier_orders_awaiting_reception.php | 266 +- htdocs/core/class/commonobject.class.php | 82 +- htdocs/core/lib/propal.lib.php | 44 +- htdocs/core/lib/sendings.lib.php | 62 +- .../modules/delivery/mod_delivery_saphir.php | 94 +- htdocs/delivery/card.php | 100 +- htdocs/delivery/class/delivery.class.php | 224 +- htdocs/expedition/class/expedition.class.php | 252 +- htdocs/expedition/shipment.php | 452 +- .../fourn/class/fournisseur.facture.class.php | 48 +- htdocs/install/upgrade2.php | 5426 ++++++++--------- htdocs/reception/card.php | 1014 +-- htdocs/reception/class/reception.class.php | 708 +-- 16 files changed, 4833 insertions(+), 4833 deletions(-) diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index c05bd985705..d9c1b2ebe17 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -54,113 +54,113 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); - $maskdelivery = GETPOST('maskdelivery', 'alpha'); - if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); + $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); + $maskdelivery = GETPOST('maskdelivery', 'alpha'); + if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'set_DELIVERY_FREE_TEXT') { - $free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); + $free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $sending = new Delivery($db); - $sending->initAsSpecimen(); + $sending = new Delivery($db); + $sending->initAsSpecimen(); - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($sending, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { + if ($module->write_file($sending, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } if ($action == 'set') { - $ret = addDocumentModel($value, $type, $label, $scandir); + $ret = addDocumentModel($value, $type, $label, $scandir); } if ($action == 'del') { - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->DELIVERY_ADDON_PDF == "$value") dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); - } + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->DELIVERY_ADDON_PDF == "$value") dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); + } } if ($action == 'setdoc') { - if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->DELIVERY_ADDON_PDF = $value; - } + if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->DELIVERY_ADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } if ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "DELIVERY_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "DELIVERY_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } @@ -199,79 +199,79 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/delivery/"); + $dir = dol_buildpath($reldir."core/modules/delivery/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.$file.'.php'; + require_once $dir.$file.'.php'; - $module = new $file; + $module = new $file; if ($module->isEnabled()) - { + { // Show modules according to features level if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - print '
'; + print ''; - // Show example of numbering module - print ''."\n"; + else print $tmp; + print ''."\n"; - print ''; + print ''; - $delivery = new Delivery($db); - $delivery->initAsSpecimen(); + $delivery = new Delivery($db); + $delivery->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $delivery); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $delivery); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'.$module->name."\n"; - print $module->info(); - print '
'.$module->name."\n"; + print $module->info(); + print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; - if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '
'; @@ -321,14 +321,14 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/delivery/doc/"); + $dir = dol_buildpath($reldir."core/modules/delivery/doc/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } @@ -337,79 +337,79 @@ foreach ($dirmodels as $reldir) foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ""; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ""; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ""; - if ($conf->global->DELIVERY_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ""; + if ($conf->global->DELIVERY_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + // Info + $htmltooltip = ''.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'sending').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'sending').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print ''; - } - } - } - } - } - } + print ''; + } + } + } + } + } + } } print ''; @@ -440,11 +440,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $la $variablename = 'DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7496f98a394..2e02323c090 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -124,9 +124,9 @@ class Propal extends CommonObject */ public $datec; - /** - * @var integer|string $date_creation; - */ + /** + * @var integer|string $date_creation; + */ public $date_creation; /** @@ -136,13 +136,13 @@ class Propal extends CommonObject public $datev; /** - * @var integer|string $date_validation; - */ + * @var integer|string $date_validation; + */ public $date_validation; /** - * @var integer|string date of the quote; - */ + * @var integer|string date of the quote; + */ public $date; /** @@ -186,9 +186,9 @@ class Propal extends CommonObject public $remise_absolue = 0; /** - * @var int ID - * @deprecated - */ + * @var int ID + * @deprecated + */ public $fk_address; public $address_type; @@ -218,8 +218,8 @@ class Propal extends CommonObject // Multicurrency /** - * @var int ID - */ + * @var int ID + */ public $fk_multicurrency; public $multicurrency_code; @@ -342,7 +342,7 @@ class Propal extends CommonObject * @param int $socid Id third party * @param int $propalid Id proposal */ - public function __construct($db, $socid = 0, $propalid = 0) + public function __construct($db, $socid = 0, $propalid = 0) { global $conf, $langs; @@ -357,7 +357,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->thirdparty should be loaded @@ -370,9 +370,9 @@ class Propal extends CommonObject * TODO Replace calls to this function by generation objet Ligne * inserted into table $this->products */ - public function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { - // phpcs:enable + // phpcs:enable global $conf, $mysoc; if (!$qty) $qty = 1; @@ -417,16 +417,16 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - public function insert_discount($idremise) + public function insert_discount($idremise) { - // phpcs:enable + // phpcs:enable global $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -493,43 +493,43 @@ class Propal extends CommonObject } } - /** - * Add a proposal line into database (linked to product/service or not) - * The parameters are already supposed to be appropriate and with final values to the call - * of this method. Also, for the VAT rate, it must have already been defined - * by whose calling the method get_default_tva (societe_vendeuse, societe_acheteuse, '' product) - * and desc must already have the right value (it's up to the caller to manage multilanguage) - * - * @param string $desc Description of line - * @param float $pu_ht Unit price - * @param float $qty Quantity - * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) - * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) - * @param int $fk_product Product/Service ID predefined - * @param float $remise_percent Pourcentage de remise de la ligne - * @param string $price_base_type HT or TTC - * @param float $pu_ttc Prix unitaire TTC - * @param int $info_bits Bits for type of lines - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line - * @param int $special_code Special code (also used by externals modules!) - * @param int $fk_parent_line Id of parent line - * @param int $fk_fournprice Id supplier price - * @param int $pa_ht Buying price without tax - * @param string $label ??? - * @param int $date_start Start date of the line - * @param int $date_end End date of the line - * @param array $array_options extrafields array - * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... - * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id - * @param double $pu_ht_devise Unit price in currency - * @param int $fk_remise_except Id discount if line is from a discount - * @return int >0 if OK, <0 if KO - * @see add_product() - */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) + /** + * Add a proposal line into database (linked to product/service or not) + * The parameters are already supposed to be appropriate and with final values to the call + * of this method. Also, for the VAT rate, it must have already been defined + * by whose calling the method get_default_tva (societe_vendeuse, societe_acheteuse, '' product) + * and desc must already have the right value (it's up to the caller to manage multilanguage) + * + * @param string $desc Description of line + * @param float $pu_ht Unit price + * @param float $qty Quantity + * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) + * @param int $fk_product Product/Service ID predefined + * @param float $remise_percent Pourcentage de remise de la ligne + * @param string $price_base_type HT or TTC + * @param float $pu_ttc Prix unitaire TTC + * @param int $info_bits Bits for type of lines + * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int $rang Position of line + * @param int $special_code Special code (also used by externals modules!) + * @param int $fk_parent_line Id of parent line + * @param int $fk_fournprice Id supplier price + * @param int $pa_ht Buying price without tax + * @param string $label ??? + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @param array $array_options extrafields array + * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id + * @param double $pu_ht_devise Unit price in currency + * @param int $fk_remise_except Id discount if line is from a discount + * @return int >0 if OK, <0 if KO + * @see add_product() + */ + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) { global $mysoc, $conf, $langs; @@ -706,27 +706,27 @@ class Propal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); - // Mise a jour informations denormalisees au niveau de la propale meme - $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. - if ($result > 0) - { - $this->db->commit(); - return $this->line->id; - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->line->error; - $this->db->rollback(); - return -2; - } - } else { + // Mise a jour informations denormalisees au niveau de la propale meme + $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + if ($result > 0) + { + $this->db->commit(); + return $this->line->id; + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->line->error; + $this->db->rollback(); + return -2; + } + } else { dol_syslog(get_class($this)."::addline status of proposal must be Draft to allow use of ->addline()", LOG_ERR); return -3; } - } + } /** @@ -757,11 +757,11 @@ class Propal extends CommonObject * @param int $notrigger disable line update trigger * @return int 0 if OK, <0 if KO */ - public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $mysoc, $langs; - dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -778,11 +778,11 @@ class Propal extends CommonObject if (!empty($qty) && $special_code == 3) $special_code = 0; // Remove option tag if (empty($type)) $type = 0; - if ($date_start && $date_end && $date_start > $date_end) { - $langs->load("errors"); - $this->error = $langs->trans('ErrorStartDateGreaterEnd'); - return -1; - } + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } if ($this->statut == self::STATUS_DRAFT) { @@ -926,7 +926,7 @@ class Propal extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid) + public function deleteline($lineid) { global $user; @@ -964,7 +964,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - public function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $hookmanager; $error = 0; @@ -1102,62 +1102,62 @@ class Propal extends CommonObject $resql = $this->db->query($sql); if (!$resql) $error++; - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds - } + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + { + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + } - // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - } + // Add object linked + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } + } - /* + /* * Insertion du detail des produits dans la base * Insert products detail in database */ - if (!$error) - { - $fk_parent_line = 0; - $num = count($this->lines); + if (!$error) + { + $fk_parent_line = 0; + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { - if (!is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API - { // Convert into object this->lines[$i]. - $line = (object) $this->lines[$i]; - } else { - $line = $this->lines[$i]; - } + if (!is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API + { // Convert into object this->lines[$i]. + $line = (object) $this->lines[$i]; + } else { + $line = $this->lines[$i]; + } // Reset fk_parent_line for line that are not child lines or special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; } - // Complete vat rate with code + // Complete vat rate with code $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; @@ -1273,7 +1273,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a proposal object completely defined by its data members (ex, results from copy). * @@ -1281,9 +1281,9 @@ class Propal extends CommonObject * @return int Id of the new object if ok, <0 if ko * @see create() */ - public function create_from($user) + public function create_from($user) { - // phpcs:enable + // phpcs:enable // i love this function because $this->products is not used in create function... $this->products = $this->lines; @@ -1324,10 +1324,10 @@ class Propal extends CommonObject { if ($objsoc->fetch($socid) > 0) { - $object->socid = $objsoc->id; - $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $object->fk_delivery_address = ''; + $object->socid = $objsoc->id; + $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $object->fk_delivery_address = ''; /*if (!empty($conf->projet->enabled)) { @@ -1339,7 +1339,7 @@ class Propal extends CommonObject $clonedObj->fk_project = ''; } }*/ - $object->fk_project = ''; // A cloned proposal is set by default to no project. + $object->fk_project = ''; // A cloned proposal is set by default to no project. } // reset ref_client @@ -1347,7 +1347,7 @@ class Propal extends CommonObject // TODO Change product price if multi-prices } else { - $objsoc->fetch($object->socid); + $objsoc->fetch($object->socid); } $object->id = 0; @@ -1372,18 +1372,18 @@ class Propal extends CommonObject $result = $object->create($user); if ($result < 0) { - $this->error = $object->error; - $this->errors = array_merge($this->errors, $object->errors); - $error++; + $this->error = $object->error; + $this->errors = array_merge($this->errors, $object->errors); + $error++; } if (!$error) { // copy internal contacts - if ($object->copy_linked_contact($this, 'internal') < 0) - { + if ($object->copy_linked_contact($this, 'internal') < 0) + { $error++; - } + } } if (!$error) @@ -1391,7 +1391,7 @@ class Propal extends CommonObject // copy external contacts if same company if ($this->socid == $object->socid) { - if ($object->copy_linked_contact($this, 'external') < 0) + if ($object->copy_linked_contact($this, 'external') < 0) $error++; } } @@ -1429,7 +1429,7 @@ class Propal extends CommonObject * @param string $ref_ext Ref ext of proposal * @return int >0 if OK, <0 if KO */ - public function fetch($rowid, $ref = '', $ref_ext = '') + public function fetch($rowid, $ref = '', $ref_ext = '') { $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; @@ -1595,7 +1595,7 @@ class Propal extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1684,7 +1684,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * @@ -1696,7 +1696,7 @@ class Propal extends CommonObject public function fetch_lines($only_product = 0, $loadalsotranslation = 0) { global $langs, $conf; - // phpcs:enable + // phpcs:enable $this->lines = array(); $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,'; @@ -1790,11 +1790,11 @@ class Propal extends CommonObject $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } $this->lines[$i] = $line; //dol_syslog("1 ".$line->fk_product); @@ -1818,7 +1818,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, 0=Nothing done, >=0 if OK */ - public function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf; @@ -1933,7 +1933,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define proposal date * @@ -1942,9 +1942,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (empty($date)) { $this->error = 'ErrorBadParameter'; @@ -2000,7 +2000,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define end validity date * @@ -2009,9 +2009,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_echeance($user, $date_fin_validite, $notrigger = 0) + public function set_echeance($user, $date_fin_validite, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer)) { $error = 0; @@ -2134,7 +2134,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery * @@ -2201,7 +2201,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set source of demand * @@ -2270,7 +2270,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer reference number * @@ -2331,7 +2331,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -2396,7 +2396,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -2676,7 +2676,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -2825,7 +2825,7 @@ class Propal extends CommonObject return $this->InvoiceArrayList($this->id); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array with id and ref of related invoices * @@ -3091,7 +3091,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change source demand * @@ -3446,7 +3446,7 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @@ -4260,7 +4260,7 @@ class PropaleLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eb93a125fb5..901a0f6f385 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -242,7 +242,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $selectedLines = GETPOST('toselect', 'array'); + $selectedLines = GETPOST('toselect', 'array'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); @@ -349,7 +349,7 @@ if (empty($reshook)) for ($i = 0; $i < $num; $i++) { - if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : ''); @@ -738,8 +738,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer @@ -1284,82 +1284,82 @@ if (empty($reshook)) // add lines from objectlinked if ($action == 'import_lines_from_object' - && $usercancreate - && $object->statut == Commande::STATUS_DRAFT + && $usercancreate + && $object->statut == Commande::STATUS_DRAFT ) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - $situation_percent = 100; - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } // Actions when printing a doc from card @@ -1849,7 +1849,7 @@ if ($action == 'create' && $usercancreate) print ''; } - print '
'; + print ''; } else { // Mode view $now = dol_now(); @@ -2635,9 +2635,9 @@ if ($action == 'create' && $usercancreate) $compatibleImportElementsList = false; if ($usercancreate - && $object->statut == Commande::STATUS_DRAFT) + && $object->statut == Commande::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index bc86591fc22..1d367774432 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -31,166 +31,166 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders_awaiting_reception extends ModeleBoxes { - public $boxcode = "supplierordersawaitingreception"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; - public $depends = array("fournisseur"); + public $boxcode = "supplierordersawaitingreception"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->lire); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->loadLangs(array("boxes", "sendings", "orders")); + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->loadLangs(array("boxes", "sendings", "orders")); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_client, s.code_fournisseur, s.email,"; - $sql .= " s.logo,"; - $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; - $sql .= " c.total_ht,"; - $sql .= " c.tva as total_tva,"; - $sql .= " c.total_ttc,"; - $sql .= " c.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $delivery_date = $this->db->jdate($objp->date_livraison); + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $delivery_date = $this->db->jdate($objp->date_livraison); $datem = $this->db->jdate($objp->tms); - $supplierorderstatic->date_livraison = $delivery_date; - $supplierorderstatic->statut = $objp->fk_statut; + $supplierorderstatic->date_livraison = $delivery_date; + $supplierorderstatic->statut = $objp->fk_statut; $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; $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; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $delayIcon = ''; - if ($supplierorderstatic->hasDelay()) { - $delayIcon = img_warning($langs->trans("Late")); - } + $delayIcon = ''; + if ($supplierorderstatic->hasDelay()) { + $delayIcon = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day').'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day').'', + 'asis' => 1 + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 58b36ac3643..04b7d4985cd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -296,11 +296,11 @@ abstract class CommonObject */ public $cond_reglement_id; - /** - * @var int Transport mode ID (For module intracomm report) - * @see setTransportMode() - */ - public $transport_mode_id; + /** + * @var int Transport mode ID (For module intracomm report) + * @see setTransportMode() + */ + public $transport_mode_id; /** * @var int Payment terms ID @@ -2196,42 +2196,42 @@ abstract class CommonObject } } - /** - * Change the transport mode methods - * - * @param int $id Id of new payment method - * @return int >0 if OK, <0 if KO - */ - public function setTransportMode($id) - { - dol_syslog(get_class($this).'::setTransportMode('.$id.')'); - if ($this->statut >= 0 || $this->element == 'societe') - { - $fieldname = 'fk_transport_mode'; - if ($this->element == 'societe') $fieldname = 'transport_mode'; - if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; + /** + * Change the transport mode methods + * + * @param int $id Id of new payment method + * @return int >0 if OK, <0 if KO + */ + public function setTransportMode($id) + { + dol_syslog(get_class($this).'::setTransportMode('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'fk_transport_mode'; + if ($this->element == 'societe') $fieldname = 'transport_mode'; + if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); - $sql .= ' WHERE rowid='.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->transport_mode_id = $id; - // for supplier - if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; - return 1; - } else { - dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; - return -2; - } - } + if ($this->db->query($sql)) + { + $this->transport_mode_id = $id; + // for supplier + if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; + return 1; + } else { + dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } /** * Change the retained warranty payments terms @@ -2785,8 +2785,8 @@ abstract class CommonObject */ public function line_max($fk_parent_line = 0) { - // phpcs:enable - $positionfield = 'rang'; + // phpcs:enable + $positionfield = 'rang'; if ($this->table_element == 'bom_bom') $positionfield = 'position'; // Search the last rang with fk_parent_line diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index ef41614116f..bd3a30151da 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -43,7 +43,7 @@ function propal_prepare_head($object) $h++; if ((empty($conf->commande->enabled) && ((!empty($conf->expedition->enabled) && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) - || (!empty($conf->expedition->enabled) && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) + || (!empty($conf->expedition->enabled) && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) { $langs->load("sendings"); $text = ''; @@ -57,7 +57,7 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; @@ -65,29 +65,29 @@ function propal_prepare_head($object) $h++; } - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - } + } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -129,13 +129,13 @@ function propal_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'attributes'; - $h++; + $head[$h][2] = 'attributes'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $head[$h][2] = 'attributeslines'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines'; + $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_admin', 'remove'); diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 81775bf8dbd..cf1d1793a88 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -37,7 +37,7 @@ function shipping_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings", "deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -53,8 +53,8 @@ function shipping_prepare_head($object) $object->fetchObjectLinked($object->id, $object->element); if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery { - // Take first one element of array - $tmp = reset($object->linkedObjectsIds['delivery']); + // Take first one element of array + $tmp = reset($object->linkedObjectsIds['delivery']); $head[$h][0] = DOL_URL_ROOT."/delivery/card.php?id=".$tmp; $head[$h][1] = $langs->trans("DeliveryCard"); @@ -65,34 +65,34 @@ function shipping_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $objectsrc = $object; - if ($object->origin == 'commande' && $object->origin_id > 0) - { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->origin_id); - } - $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; - $head[$h][1] = $langs->trans("ContactsAddresses"); + $objectsrc = $object; + if ($object->origin == 'commande' && $object->origin_id > 0) + { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->origin_id); + } + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; + $head[$h][2] = 'contact'; + $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; - $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; - if (!empty($object->note_public)) $nbNote++; + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; @@ -101,8 +101,8 @@ function shipping_prepare_head($object) // Show more tabs from modules // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); @@ -122,7 +122,7 @@ function delivery_prepare_head($object) global $langs, $db, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings", "deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -195,7 +195,7 @@ function delivery_prepare_head($object) $object->id = $tmpobject->id; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); @@ -262,7 +262,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$langs->trans("QtyPreparedOrShipped").''; if (!empty($conf->stock->enabled)) { - print ''.$langs->trans("Warehouse").''; + print ''.$langs->trans("Warehouse").''; } /*TODO Add link to expeditiondet_batch if (! empty($conf->productbatch->enabled)) @@ -371,13 +371,13 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') // Warehouse if (!empty($conf->stock->enabled)) { - print ''; - if ($objp->warehouse_id > 0) - { - $warehousestatic->fetch($objp->warehouse_id); - print $warehousestatic->getNomUrl(1); - } - print ''; + print ''; + if ($objp->warehouse_id > 0) + { + $warehousestatic->fetch($objp->warehouse_id); + print $warehousestatic->getNomUrl(1); + } + print ''; } // Batch number managment diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 10a979d4ee2..df1a15598b1 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/delivery/modules_delivery.php'; class mod_delivery_saphir extends ModeleNumRefDeliveryOrder { /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** @@ -55,14 +55,14 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder public $name = 'Saphir'; - /** - * Returns the description of the numbering model - * - * @return string Texte descripif - */ - public function info() - { - global $conf, $langs, $db; + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; $langs->load("bills"); @@ -93,28 +93,28 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder $texte .= ''; return $texte; - } + } - /** - * Return an example of number - * - * @return string Example - */ - public function getExample() - { - global $conf, $langs, $mysoc; + /** + * Return an example of number + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client = $old_code_client; + $mysoc->code_client = $old_code_client; if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } return $numExample; - } + } /** @@ -124,8 +124,8 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * @param Object $object Object delivery * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc, $object) - { + public function getNextValue($objsoc, $object) + { global $db, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -142,33 +142,33 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder $numFinal = get_next_value($db, $mask, 'delivery', 'ref', '', $objsoc, $object->date_livraison); return $numFinal; - } + } /** * Return next free value * - * @param Societe $objsoc Object third party + * @param Societe $objsoc Object third party * @param string $objforref Object for number to search - * @return string Next free value - */ - public function getNumRef($objsoc, $objforref) - { - return $this->getNextValue($objsoc, $objforref); - } + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref) + { + return $this->getNextValue($objsoc, $objforref); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next free ref - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Objet livraison - * @return string Texte descripif - */ - public function delivery_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next free ref + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Objet livraison + * @return string Texte descripif + */ + public function delivery_get_num($objsoc = 0, $object = '') + { + // phpcs:enable + return $this->getNextValue($objsoc, $object); + } } diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 65172c88372..d9cde97c303 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -41,8 +41,8 @@ if (!empty($conf->expedition_bon->enabled)) if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -126,8 +126,8 @@ if ($action == 'add') $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) ) { $result = $object->valid($user); @@ -310,13 +310,13 @@ if ($action == 'create') // Create. Seems to no be used if ($typeobject == 'commande' && $expedition->origin_id > 0 && !empty($conf->commande->enabled)) { - $objectsrc = new Commande($db); - $objectsrc->fetch($expedition->origin_id); + $objectsrc = new Commande($db); + $objectsrc->fetch($expedition->origin_id); } if ($typeobject == 'propal' && $expedition->origin_id > 0 && !empty($conf->propal->enabled)) { - $objectsrc = new Propal($db); - $objectsrc->fetch($expedition->origin_id); + $objectsrc = new Propal($db); + $objectsrc->fetch($expedition->origin_id); } // Shipment card @@ -331,35 +331,35 @@ if ($action == 'create') // Create. Seems to no be used $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$expedition->thirdparty->getNomUrl(1); // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if (0) { // Do not change on shipment - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($expedition->socid, $expedition->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$expedition->id, $expedition->socid, $expedition->fk_project, 'none', 0, 0, 0, 1); - } - } else { - $morehtmlref .= ' : '; - if (!empty($objectsrc->fk_project)) { - $proj = new Project($db); - $proj->fetch($objectsrc->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if (0) { // Do not change on shipment + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($expedition->socid, $expedition->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$expedition->id, $expedition->socid, $expedition->fk_project, 'none', 0, 0, 0, 1); + } + } else { + $morehtmlref .= ' : '; + if (!empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; @@ -371,7 +371,7 @@ if ($action == 'create') // Create. Seems to no be used print '
'; print '
'; - print ''; + print '
'; // Shipment /* @@ -454,21 +454,21 @@ if ($action == 'create') // Create. Seems to no be used if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; + print ''; } /* A delivery note should be just more properties of a shipment, so notes are on shipment @@ -690,9 +690,9 @@ if ($action == 'create') // Create. Seems to no be used $shipment = new Expedition($db); $shipment->fetch($object->origin_id); - // Show links to link elements - //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); - $somethingshown = $form->showLinkedObjectBlock($object, ''); + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); + $somethingshown = $form->showLinkedObjectBlock($object, ''); } diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index c5b62d4233d..74ba0f86de0 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -88,8 +88,8 @@ class Delivery extends CommonObject public $date_delivery; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -108,7 +108,7 @@ class Delivery extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; $this->lines = array(); @@ -126,7 +126,7 @@ class Delivery extends CommonObject * @param User $user Objet du user qui cree * @return int <0 si erreur, id delivery cree si ok */ - public function create($user) + public function create($user) { global $conf; @@ -136,7 +136,7 @@ class Delivery extends CommonObject $error = 0; - $now = dol_now(); + $now = dol_now(); /* Delivery note as draft On positionne en mode draft le bon de livraison */ $this->draft = 1; @@ -170,8 +170,8 @@ class Delivery extends CommonObject $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); - $sql .= ", ".(int) $this->fk_incoterms; - $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ")"; dol_syslog("Delivery::create", LOG_DEBUG); @@ -256,7 +256,7 @@ class Delivery extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a line * @@ -266,9 +266,9 @@ class Delivery extends CommonObject * @param string $description Description * @return int <0 if KO, >0 if OK */ - public function create_line($origin_id, $qty, $fk_product, $description) - { - // phpcs:enable + public function create_line($origin_id, $qty, $fk_product, $description) + { + // phpcs:enable $error = 0; $idprod = $fk_product; $j = 0; @@ -298,7 +298,7 @@ class Delivery extends CommonObject * @param int $id Id of object to load * @return integer */ - public function fetch($id) + public function fetch($id) { global $conf; @@ -306,8 +306,8 @@ class Delivery extends CommonObject $sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public"; $sql .= ", l.date_delivery, l.fk_address, l.model_pdf"; $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql .= ', l.fk_incoterms, l.location_incoterms'; - $sql .= ", i.libelle as label_incoterms"; + $sql .= ', l.fk_incoterms, l.location_incoterms'; + $sql .= ", i.libelle as label_incoterms"; $sql .= " FROM ".MAIN_DB_PREFIX."delivery as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid'; @@ -374,14 +374,14 @@ class Delivery extends CommonObject /** * Validate object and update stock if option enabled * - * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int + * @param User $user Object user that validate + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int */ - public function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_syslog(get_class($this)."::valid begin"); @@ -389,8 +389,8 @@ class Delivery extends CommonObject $error = 0; - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->delivery_advance->validate))) { if (!empty($conf->global->DELIVERY_ADDON_NUMBER)) { @@ -409,12 +409,12 @@ class Delivery extends CommonObject $soc->fetch($this->socid); if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life - { - $numref = $objMod->delivery_get_num($soc, $this); - } else { - $numref = $this->ref; - } - $this->newref = dol_sanitizeFileName($numref); + { + $numref = $objMod->delivery_get_num($soc, $this); + } else { + $numref = $this->ref; + } + $this->newref = dol_sanitizeFileName($numref); // Test if is not already in valid status. If so, we stop to avoid decrementing the stock twice. $sql = "SELECT ref"; @@ -442,24 +442,24 @@ class Delivery extends CommonObject $sql .= " AND fk_statut = 0"; $resql = $this->db->query($sql); - if (!$resql) - { - dol_print_error($this->db); - $this->error = $this->db->lasterror(); - $error++; - } + if (!$resql) + { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('DELIVERY_VALIDATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('DELIVERY_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers + } if (!$error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) @@ -481,17 +481,17 @@ class Delivery extends CommonObject if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -506,14 +506,14 @@ class Delivery extends CommonObject dol_syslog(get_class($this)."::valid ok"); } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } } } else { @@ -523,7 +523,7 @@ class Delivery extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Creating the delivery slip from an existing shipment * @@ -531,9 +531,9 @@ class Delivery extends CommonObject * @param int $sending_id Id of the expedition that serves as a model * @return integer */ - public function create_from_sending($user, $sending_id) + public function create_from_sending($user, $sending_id) { - // phpcs:enable + // phpcs:enable $expedition = new Expedition($this->db); $result = $expedition->fetch($sending_id); @@ -569,7 +569,7 @@ class Delivery extends CommonObject return $this->create($user); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a livraison line (only extrafields) * @@ -577,9 +577,9 @@ class Delivery extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - public function update_line($id, $array_options = 0) + public function update_line($id, $array_options = 0) { - // phpcs:enable + // phpcs:enable global $conf; $error = 0; @@ -609,7 +609,7 @@ class Delivery extends CommonObject * @param int $qty Qty * @return void */ - public function addline($origin_id, $qty) + public function addline($origin_id, $qty) { $num = count($this->lines); $line = new DeliveryLine($this->db); @@ -626,7 +626,7 @@ class Delivery extends CommonObject * @param int $lineid Line id * @return integer|null */ - public function deleteline($lineid) + public function deleteline($lineid) { if ($this->statut == 0) { @@ -649,11 +649,11 @@ class Delivery extends CommonObject * * @return integer */ - public function delete() + public function delete() { global $conf, $langs, $user; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $this->db->begin(); $error = 0; @@ -697,14 +697,14 @@ class Delivery extends CommonObject } } - // Call trigger - $result = $this->call_trigger('DELIVERY_DELETE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -4; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('DELIVERY_DELETE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -4; + } + // End call triggers return 1; } else { @@ -728,10 +728,10 @@ class Delivery extends CommonObject * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -742,16 +742,16 @@ class Delivery extends CommonObject $url = DOL_URL_ROOT.'/delivery/card.php?id='.$this->id; - //if ($option !== 'nolink') - //{ - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - //} + //if ($option !== 'nolink') + //{ + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + //} - $linkstart = ''; + $linkstart = ''; $linkend = ''; if ($withpicto) $result .= ($linkstart.img_object($label, $this->picto, 'class="classfortooltip"').$linkend); @@ -760,15 +760,15 @@ class Delivery extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return void */ - public function fetch_lines() + public function fetch_lines() { - // phpcs:enable + // phpcs:enable $this->lines = array(); $sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped, ld.fk_origin_line, "; @@ -844,12 +844,12 @@ class Delivery extends CommonObject * @param int $mode Mode * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -857,9 +857,9 @@ class Delivery extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($status, $mode) + public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -883,19 +883,19 @@ class Delivery extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { global $user, $langs, $conf; $now = dol_now(); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -946,7 +946,7 @@ class Delivery extends CommonObject * @return array Product remaining to be delivered * TODO use new function */ - public function getRemainingDelivered() + public function getRemainingDelivered() { global $langs; @@ -1148,13 +1148,13 @@ class DeliveryLine extends CommonObjectLine public $product_ref; public $product_label; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d86e177034e..229031ff56a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -159,8 +159,8 @@ class Expedition extends CommonObject public $date_shipping; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -171,7 +171,7 @@ class Expedition extends CommonObject public $meths; public $listmeths; // List of carriers - /** + /** * Draft status */ const STATUS_DRAFT = 0; @@ -441,7 +441,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a expedition line * @@ -473,7 +473,7 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create the detail (eat-by date) of the expedition line * @@ -483,7 +483,7 @@ class Expedition extends CommonObject */ public function create_line_batch($line_ext, $array_options = 0) { - // phpcs:enable + // phpcs:enable $error = 0; $stockLocationQty = array(); // associated array with batch qty in stock location @@ -537,7 +537,7 @@ class Expedition extends CommonObject if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; - $sql .= ", e.date_valid"; + $sql .= ", e.date_valid"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql .= ", e.fk_shipping_method, e.tracking_number"; @@ -574,7 +574,7 @@ class Expedition extends CommonObject $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date_valid = $this->db->jdate($obj->date_valid); $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real @@ -868,7 +868,7 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a delivery receipt from a shipment * @@ -877,7 +877,7 @@ class Expedition extends CommonObject */ public function create_delivery($user) { - // phpcs:enable + // phpcs:enable global $conf; if ($conf->delivery_note->enabled) @@ -974,7 +974,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a shipment line with batch record * @@ -984,7 +984,7 @@ class Expedition extends CommonObject */ public function addline_batch($dbatch, $array_options = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $num = count($this->lines); @@ -1154,7 +1154,7 @@ class Expedition extends CommonObject * Cancel shipment. * * @param int $notrigger Disable triggers - * @param bool $also_update_stock true if the stock should be increased back (false by default) + * @param bool $also_update_stock true if the stock should be increased back (false by default) * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ public function cancel($notrigger = 0, $also_update_stock = false) @@ -1360,7 +1360,7 @@ class Expedition extends CommonObject * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) * * @param int $notrigger Disable triggers - * @param bool $also_update_stock true if the stock should be increased back (false by default) + * @param bool $also_update_stock true if the stock should be increased back (false by default) * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ public function delete($notrigger = 0, $also_update_stock = false) @@ -1474,9 +1474,9 @@ class Expedition extends CommonObject if (!$error) { - $main = MAIN_DB_PREFIX.'expeditiondet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".$this->id.")"; + $main = MAIN_DB_PREFIX.'expeditiondet'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; $sql .= " WHERE fk_expedition = ".$this->id; @@ -1487,9 +1487,9 @@ class Expedition extends CommonObject $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - // delete extrafields - $res = $this->deleteExtraFields(); - if ($res < 0) $error++; + // delete extrafields + $res = $this->deleteExtraFields(); + if ($res < 0) $error++; if (!$error) { @@ -1570,7 +1570,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * @@ -1578,7 +1578,7 @@ class Expedition extends CommonObject */ public function fetch_lines() { - // phpcs:enable + // phpcs:enable global $conf, $mysoc; // TODO: recuperer les champs du document associe a part $this->lines = array(); @@ -1854,7 +1854,7 @@ class Expedition extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1864,8 +1864,8 @@ class Expedition extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable - global $langs; + // phpcs:enable + global $langs; $labelStatus = $langs->trans($this->statuts[$status]); $labelStatusShort = $langs->trans($this->statutshorts[$status]); @@ -2002,7 +2002,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * @@ -2030,7 +2030,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch all deliveries method and return an array. Load array this->listmeths. * @@ -2039,7 +2039,7 @@ class Expedition extends CommonObject */ public function list_delivery_methods($id = '') { - // phpcs:enable + // phpcs:enable global $langs; $this->listmeths = array(); @@ -2066,7 +2066,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update/create delivery method. * @@ -2110,7 +2110,7 @@ class Expedition extends CommonObject $resql = $this->db->query($sql); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * DesActivate delivery method. * @@ -2308,7 +2308,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * @@ -2316,7 +2316,7 @@ class Expedition extends CommonObject */ public function set_billed() { - // phpcs:enable + // phpcs:enable global $user; $error = 0; @@ -2450,13 +2450,13 @@ class Expedition extends CommonObject } } - if (!$error) { + if (!$error) { // Call trigger $result = $this->call_trigger('SHIPPING_REOPEN', $user); if ($result < 0) { $error++; } - } + } } else { $error++; $this->errors[] = $this->db->lasterror(); @@ -2482,7 +2482,7 @@ class Expedition extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2550,8 +2550,8 @@ class ExpeditionLigne extends CommonObjectLine public $origin_line_id; /** - * @var int ID - */ + * @var int ID + */ public $fk_origin_line; /** @@ -2560,42 +2560,42 @@ class ExpeditionLigne extends CommonObjectLine public $fk_expedition; /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - /** - * @var float qty asked From llx_expeditiondet - */ - public $qty; + /** + * @var float qty asked From llx_expeditiondet + */ + public $qty; - /** - * @var float qty shipped - */ - public $qty_shipped; + /** + * @var float qty shipped + */ + public $qty_shipped; - /** - * @var int Id of product - */ - public $fk_product; - public $detail_batch; + /** + * @var int Id of product + */ + public $fk_product; + public $detail_batch; - /** - * @var int Id of warehouse - */ + /** + * @var int Id of warehouse + */ public $entrepot_id; - /** - * @var float qty asked From llx_commandedet or llx_propaldet - */ + /** + * @var float qty asked From llx_commandedet or llx_propaldet + */ public $qty_asked; - /** - * @deprecated - * @see $product_ref - */ - public $ref; + /** + * @deprecated + * @see $product_ref + */ + public $ref; /** * @var string product ref @@ -2608,87 +2608,87 @@ class ExpeditionLigne extends CommonObjectLine */ public $libelle; - /** - * @var string product label - */ + /** + * @var string product label + */ public $product_label; - /** - * @var string product description - * @deprecated - * @see $product_desc - */ - public $desc; + /** + * @var string product description + * @deprecated + * @see $product_desc + */ + public $desc; - /** - * @var string product description - */ + /** + * @var string product description + */ public $product_desc; - /** - * @var int rang of line - */ - public $rang; + /** + * @var int rang of line + */ + public $rang; - /** - * @var float weight - */ - public $weight; - public $weight_units; + /** + * @var float weight + */ + public $weight; + public $weight_units; - /** - * @var float weight - */ - public $length; - public $length_units; + /** + * @var float weight + */ + public $length; + public $length_units; - /** - * @var float weight - */ - public $surface; - public $surface_units; + /** + * @var float weight + */ + public $surface; + public $surface_units; - /** - * @var float weight - */ - public $volume; - public $volume_units; + /** + * @var float weight + */ + public $volume; + public $volume_units; // Invoicing public $remise_percent; - public $tva_tx; + public $tva_tx; - /** - * @var float total without tax - */ - public $total_ht; + /** + * @var float total without tax + */ + public $total_ht; - /** - * @var float total with tax - */ - public $total_ttc; + /** + * @var float total with tax + */ + public $total_ttc; - /** - * @var float total vat - */ - public $total_tva; + /** + * @var float total vat + */ + public $total_tva; - /** - * @var float total localtax 1 - */ - public $total_localtax1; + /** + * @var float total localtax 1 + */ + public $total_localtax1; - /** - * @var float total localtax 2 - */ - public $total_localtax2; + /** + * @var float total localtax 2 + */ + public $total_localtax2; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + */ public function __construct($db) { $this->db = $db; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 4d4dd365c5f..b487202e26a 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -124,100 +124,100 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } */ - if ($action == 'setmode' && $user->rights->commande->creer) - { - $object = new Commande($db); - $object->fetch($id); - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setmode' && $user->rights->commande->creer) + { + $object = new Commande($db); + $object->fetch($id); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - if ($action == 'setavailability' && $user->rights->commande->creer) { - $object = new Commande($db); - $object->fetch($id); - $result = $object->availability(GETPOST('availability_id')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setavailability' && $user->rights->commande->creer) { + $object = new Commande($db); + $object->fetch($id); + $result = $object->availability(GETPOST('availability_id')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $object = new Commande($db); - $object->fetch($id); - $result = $object->demand_reason(GETPOST('demand_reason_id')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setdemandreason' && $user->rights->commande->creer) { + $object = new Commande($db); + $object->fetch($id); + $result = $object->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - if ($action == 'setconditions' && $user->rights->commande->creer) - { - $object = new Commande($db); - $object->fetch($id); - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setconditions' && $user->rights->commande->creer) + { + $object = new Commande($db); + $object->fetch($id); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) - { - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + // Set incoterm + elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) + { + $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } - // shipping method - if ($action == 'setshippingmethod' && $user->rights->commande->creer) { - $object = new Commande($db); - $object->fetch($id); - $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + // shipping method + if ($action == 'setshippingmethod' && $user->rights->commande->creer) { + $object = new Commande($db); + $object->fetch($id); + $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - // warehouse - if ($action == 'setwarehouse' && $user->rights->commande->creer) { - $object = new Commande($db); - $object->fetch($id); - $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + // warehouse + if ($action == 'setwarehouse' && $user->rights->commande->creer) { + $object = new Commande($db); + $object->fetch($id); + $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } - if ($action == 'update_extras') - { - $object->oldcopy = dol_clone($object); + if ($action == 'update_extras') + { + $object->oldcopy = dol_clone($object); - // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + if ($ret < 0) $error++; - if (!$error) - { - // Actions on extra fields - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + if (!$error) + { + // Actions on extra fields + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } + } - if ($error) - $action = 'edit_extras'; - } + if ($error) + $action = 'edit_extras'; + } - if ($action == 'set_thirdparty' && $user->rights->commande->creer) - { - $object->fetch($id); - $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); + if ($action == 'set_thirdparty' && $user->rights->commande->creer) + { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit(); - } + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit(); + } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; } /* @@ -280,61 +280,61 @@ if ($id > 0 || !empty($ref)) // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { + // Thirdparty + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= ''; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print '
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->expedition->delivery->creer) print ''.img_edit().''; - else print ' '; - print '
'; - print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->expedition->delivery->creer) print ''.img_edit().''; + else print ' '; + print '
'; + print '
'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } - print '
'; + print '
'; // Discounts for third party - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; - } + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; + } print ''; print ''; @@ -380,7 +380,7 @@ if ($id > 0 || !empty($ref)) } else { print dol_print_date($object->date_livraison, 'dayhour'); if ($object->hasDelay() && !empty($object->date_livraison)) { - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } print ''; @@ -390,43 +390,43 @@ if ($id > 0 || !empty($ref)) //print ''; print ''; - // Shipping Method - print ''; - print ''; + // Shipping Method + print ''; + print ''; - // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - print ''; - print ''; - } + // Warehouse + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + print ''; + print ''; + } // Terms of payment /* @@ -502,14 +502,14 @@ if ($id > 0 || !empty($ref)) $totalVolume = $tmparray['volume']; if ($totalWeight || $totalVolume) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } // TODO How record was recorded OrderMode (llx_c_input_method) @@ -517,22 +517,22 @@ if ($id > 0 || !empty($ref)) // Incoterms if (!empty($conf->incoterm->enabled)) { - print ''; - print ''; + print ''; + print ''; } $expe = new Expedition($db); @@ -553,20 +553,20 @@ if ($id > 0 || !empty($ref)) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - print ''; - print ''; + // Multicurrency Amount HT + print ''; + print ''; + print ''; - // Multicurrency Amount VAT - print ''; - print ''; - print ''; + // Multicurrency Amount VAT + print ''; + print ''; + print ''; - // Multicurrency Amount TTC - print ''; - print ''; - print ''; + // Multicurrency Amount TTC + print ''; + print ''; + print ''; } // Total HT @@ -581,13 +581,13 @@ if ($id > 0 || !empty($ref)) // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print ''; - print ''; + print ''; + print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF { - print ''; - print ''; + print ''; + print ''; } // Total TTC @@ -676,8 +676,8 @@ if ($id > 0 || !empty($ref)) $object->fetch_thirdparty(); $prod = new Product($db); - $prod->id = $objp->fk_product; - $prod->entity = $objp->entity; + $prod->id = $objp->fk_product; + $prod->entity = $objp->entity; $prod->getMultiLangs(); $outputlangs = $langs; @@ -700,25 +700,25 @@ if ($id > 0 || !empty($ref)) $product_static->type = $type; $product_static->id = $objp->fk_product; $product_static->ref = $objp->ref; - $product_static->entity = $objp->entity; + $product_static->entity = $objp->entity; - $product_static->weight = $objp->weight; - $product_static->weight_units = $objp->weight_units; - $product_static->length = $objp->length; - $product_static->length_units = $objp->length_units; - $product_static->width = $objp->width; - $product_static->width_units = $objp->width_units; - $product_static->height = $objp->height; - $product_static->height_units = $objp->height_units; - $product_static->surface = $objp->surface; - $product_static->surface_units = $objp->surface_units; - $product_static->volume = $objp->volume; - $product_static->volume_units = $objp->volume_units; + $product_static->weight = $objp->weight; + $product_static->weight_units = $objp->weight_units; + $product_static->length = $objp->length; + $product_static->length_units = $objp->length_units; + $product_static->width = $objp->width; + $product_static->width_units = $objp->width_units; + $product_static->height = $objp->height; + $product_static->height_units = $objp->height_units; + $product_static->surface = $objp->surface; + $product_static->surface_units = $objp->surface_units; + $product_static->volume = $objp->volume; + $product_static->volume_units = $objp->volume_units; $text = $product_static->getNomUrl(1); $text .= ' - '.$label; $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($objp->description)).'
'; - $description .= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); + $description .= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range @@ -845,8 +845,8 @@ if ($id > 0 || !empty($ref)) { print '
'; - // Bouton expedier sans gestion des stocks - if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) + // Bouton expedier sans gestion des stocks + if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { @@ -863,24 +863,24 @@ if ($id > 0 || !empty($ref)) } - // Bouton expedier avec gestion des stocks + // Bouton expedier avec gestion des stocks - if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) - { - print $langs->trans("ValidateOrderFirstBeforeShipment"); - } + if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) + { + print $langs->trans("ValidateOrderFirstBeforeShipment"); + } if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { //print load_fiche_titre($langs->trans("CreateShipment")); - print '
'; + print '
'; print '
'; print ''; //print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d3780d412ea..8d5809dff73 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2219,37 +2219,37 @@ class FactureFournisseur extends CommonInvoice if ($user->socid) $sql .= ' AND ff.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql = $this->db->query($sql); - if ($resql) - { - $langs->load("bills"); - $now = dol_now(); + $resql = $this->db->query($sql); + if ($resql) + { + $langs->load("bills"); + $now = dol_now(); - $response = new WorkboardResponse(); - $response->warning_delay = $conf->facture->fournisseur->warning_delay / 60 / 60 / 24; - $response->label = $langs->trans("SupplierBillsToPay"); - $response->labelShort = $langs->trans("StatusToPay"); + $response = new WorkboardResponse(); + $response->warning_delay = $conf->facture->fournisseur->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("SupplierBillsToPay"); + $response->labelShort = $langs->trans("StatusToPay"); - $response->url = DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills'; - $response->img = img_object($langs->trans("Bills"), "bill"); + $response->url = DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills'; + $response->img = img_object($langs->trans("Bills"), "bill"); - $facturestatic = new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); - while ($obj = $this->db->fetch_object($resql)) - { - $response->nbtodo++; + while ($obj = $this->db->fetch_object($resql)) + { + $response->nbtodo++; - $facturestatic->date_echeance = $this->db->jdate($obj->datefin); - $facturestatic->statut = $obj->fk_statut; + $facturestatic->date_echeance = $this->db->jdate($obj->datefin); + $facturestatic->statut = $obj->fk_statut; - if ($facturestatic->hasDelay()) { - $response->nbtodolate++; + if ($facturestatic->hasDelay()) { + $response->nbtodolate++; $response->url_late = DOL_URL_ROOT.'/fourn/facture/list.php?option=late&mainmenu=billing&leftmenu=suppliers_bills'; - } - } - $this->db->free($resql); - return $response; - } else { + } + } + $this->db->free($resql); + return $response; + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index c6208f1dd1b..7b41e7030b1 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -41,7 +41,7 @@ include_once 'inc.php'; if (!file_exists($conffile)) { - print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; + print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } require_once $conffile; require_once $dolibarr_main_document_root.'/compta/facture/class/facture.class.php'; @@ -111,353 +111,353 @@ pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upg if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { - print '

Database '.$langs->trans('DataMigration').'

'; + print '

Database '.$langs->trans('DataMigration').'

'; - print '
'.$langs->trans('Discounts').''; @@ -355,7 +355,7 @@ if ($id > 0 || !empty($ref)) print ''; print dol_print_date($object->date, 'day'); if ($object->hasDelay() && empty($object->date_livraison)) { - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } print '
'; - print ''; - if ($action != 'editshippingmethod' && $user->rights->expedition->creer) - print ''; - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'
'; - print '
'; - if ($action == 'editshippingmethod') { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); - } else { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); - } - print '
'; + print ''; + if ($action != 'editshippingmethod' && $user->rights->expedition->creer) + print ''; + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'
'; + print '
'; + if ($action == 'editshippingmethod') { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); + } else { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); + } + print '
'; - print ''; - if ($action != 'editwarehouse' && $user->rights->commande->creer) - print ''; - print '
'; - print $langs->trans('Warehouse'); - print 'id.'">'.img_edit($langs->trans('SetWarehouse'), 1).'
'; - print '
'; - if ($action == 'editwarehouse') { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); - } else { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); - } - print '
'; + print ''; + if ($action != 'editwarehouse' && $user->rights->commande->creer) + print ''; + print '
'; + print $langs->trans('Warehouse'); + print 'id.'">'.img_edit($langs->trans('SetWarehouse'), 1).'
'; + print '
'; + if ($action == 'editwarehouse') { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); + } else { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); + } + print '
'.$langs->trans("CalculatedWeight").''; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedVolume").''; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedWeight").''; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print '
'.$langs->trans("CalculatedVolume").''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + print '
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->commande->creer) print ''.img_edit().''; - else print ' '; - print '
'; - print '
'; - if ($action != 'editincoterm') - { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->commande->creer) print ''.img_edit().''; + else print ' '; + print '
'; + print '
'; + if ($action != 'editincoterm') + { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } else { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'; + print '
'; - // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) - { - require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { - $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); - $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); - } + // If password is encoded, we decode it + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) + { + require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) + { + $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } - // $conf is already instancied inside inc.php - $conf->db->type = $dolibarr_main_db_type; - $conf->db->host = $dolibarr_main_db_host; - $conf->db->port = $dolibarr_main_db_port; - $conf->db->name = $dolibarr_main_db_name; - $conf->db->user = $dolibarr_main_db_user; - $conf->db->pass = $dolibarr_main_db_pass; + // $conf is already instancied inside inc.php + $conf->db->type = $dolibarr_main_db_type; + $conf->db->host = $dolibarr_main_db_host; + $conf->db->port = $dolibarr_main_db_port; + $conf->db->name = $dolibarr_main_db_name; + $conf->db->user = $dolibarr_main_db_user; + $conf->db->pass = $dolibarr_main_db_pass; - $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); - // Create the global $hookmanager object - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - $hookmanager->initHooks(array('upgrade')); + // Create the global $hookmanager object + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + $hookmanager->initHooks(array('upgrade')); - if (!$db->connected) - { - print ''; - dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); - $error++; - } + if (!$db->connected) + { + print ''; + dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); + $error++; + } - if (!$error) - { - if ($db->database_selected) - { - dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); - } else { - $error++; - } - } + if (!$error) + { + if ($db->database_selected) + { + dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); + } else { + $error++; + } + } - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; - $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; - $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; + $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; + $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; - // Chargement config - if (!$error) - { - $conf->setValues($db); - // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); - $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; - } + // Chargement config + if (!$error) + { + $conf->setValues($db); + // Reset forced setup after the setValues + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); + $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; + } - /*************************************************************************************** + /*************************************************************************************** * * Migration of data * ***************************************************************************************/ - $db->begin(); + $db->begin(); - if (!$error) - { - // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE - // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); + if (!$error) + { + // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE + // Version to install is DOL_VERSION + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); - // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec - // dans la 1ere colonne, la description de l'action a faire - // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' + // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec + // dans la 1ere colonne, la description de l'action a faire + // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - $versiontoarray = explode('.', $versionto); - $versionranarray = explode('.', DOL_VERSION); + $versiontoarray = explode('.', $versionto); + $versionranarray = explode('.', DOL_VERSION); - // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; - $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; - $db->query($sql, 1); + // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; + $db->query($sql, 1); - $afterversionarray = explode('.', '2.0.0'); - $beforeversionarray = explode('.', '2.7.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - // Script pour V2 -> V2.1 - migrate_paiements($db, $langs, $conf); + $afterversionarray = explode('.', '2.0.0'); + $beforeversionarray = explode('.', '2.7.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + // Script pour V2 -> V2.1 + migrate_paiements($db, $langs, $conf); - migrate_contracts_det($db, $langs, $conf); + migrate_contracts_det($db, $langs, $conf); - migrate_contracts_date1($db, $langs, $conf); + migrate_contracts_date1($db, $langs, $conf); - migrate_contracts_date2($db, $langs, $conf); + migrate_contracts_date2($db, $langs, $conf); - migrate_contracts_date3($db, $langs, $conf); + migrate_contracts_date3($db, $langs, $conf); - migrate_contracts_open($db, $langs, $conf); + migrate_contracts_open($db, $langs, $conf); - migrate_modeles($db, $langs, $conf); + migrate_modeles($db, $langs, $conf); - migrate_price_propal($db, $langs, $conf); + migrate_price_propal($db, $langs, $conf); - migrate_price_commande($db, $langs, $conf); + migrate_price_commande($db, $langs, $conf); - migrate_price_commande_fournisseur($db, $langs, $conf); + migrate_price_commande_fournisseur($db, $langs, $conf); - migrate_price_contrat($db, $langs, $conf); + migrate_price_contrat($db, $langs, $conf); - migrate_paiementfourn_facturefourn($db, $langs, $conf); + migrate_paiementfourn_facturefourn($db, $langs, $conf); - // Script pour V2.1 -> V2.2 - migrate_paiements_orphelins_1($db, $langs, $conf); + // Script pour V2.1 -> V2.2 + migrate_paiements_orphelins_1($db, $langs, $conf); - migrate_paiements_orphelins_2($db, $langs, $conf); + migrate_paiements_orphelins_2($db, $langs, $conf); - migrate_links_transfert($db, $langs, $conf); + migrate_links_transfert($db, $langs, $conf); - // Script pour V2.2 -> V2.4 - migrate_commande_expedition($db, $langs, $conf); + // Script pour V2.2 -> V2.4 + migrate_commande_expedition($db, $langs, $conf); - migrate_commande_livraison($db, $langs, $conf); + migrate_commande_livraison($db, $langs, $conf); - migrate_detail_livraison($db, $langs, $conf); + migrate_detail_livraison($db, $langs, $conf); - // Script pour V2.5 -> V2.6 - migrate_stocks($db, $langs, $conf); + // Script pour V2.5 -> V2.6 + migrate_stocks($db, $langs, $conf); - // Script pour V2.6 -> V2.7 - migrate_menus($db, $langs, $conf); + // Script pour V2.6 -> V2.7 + migrate_menus($db, $langs, $conf); - migrate_commande_deliveryaddress($db, $langs, $conf); + migrate_commande_deliveryaddress($db, $langs, $conf); - migrate_restore_missing_links($db, $langs, $conf); + migrate_restore_missing_links($db, $langs, $conf); - migrate_rename_directories($db, $langs, $conf, '/compta', '/banque'); + migrate_rename_directories($db, $langs, $conf, '/compta', '/banque'); - migrate_rename_directories($db, $langs, $conf, '/societe', '/mycompany'); - } + migrate_rename_directories($db, $langs, $conf, '/societe', '/mycompany'); + } - // Script for 2.8 - $afterversionarray = explode('.', '2.7.9'); - $beforeversionarray = explode('.', '2.8.9'); - //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + // Script for 2.8 + $afterversionarray = explode('.', '2.7.9'); + $beforeversionarray = explode('.', '2.8.9'); + //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx - migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); + migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); - migrate_relationship_tables($db, $langs, $conf, 'pr_exp', 'fk_propal', 'propal', 'fk_expedition', 'shipping'); + migrate_relationship_tables($db, $langs, $conf, 'pr_exp', 'fk_propal', 'propal', 'fk_expedition', 'shipping'); - migrate_relationship_tables($db, $langs, $conf, 'pr_liv', 'fk_propal', 'propal', 'fk_livraison', 'delivery'); + migrate_relationship_tables($db, $langs, $conf, 'pr_liv', 'fk_propal', 'propal', 'fk_livraison', 'delivery'); - migrate_relationship_tables($db, $langs, $conf, 'co_liv', 'fk_commande', 'commande', 'fk_livraison', 'delivery'); + migrate_relationship_tables($db, $langs, $conf, 'co_liv', 'fk_commande', 'commande', 'fk_livraison', 'delivery'); - migrate_relationship_tables($db, $langs, $conf, 'co_pr', 'fk_propale', 'propal', 'fk_commande', 'commande'); + migrate_relationship_tables($db, $langs, $conf, 'co_pr', 'fk_propale', 'propal', 'fk_commande', 'commande'); - migrate_relationship_tables($db, $langs, $conf, 'fa_pr', 'fk_propal', 'propal', 'fk_facture', 'facture'); + migrate_relationship_tables($db, $langs, $conf, 'fa_pr', 'fk_propal', 'propal', 'fk_facture', 'facture'); - migrate_relationship_tables($db, $langs, $conf, 'co_fa', 'fk_commande', 'commande', 'fk_facture', 'facture'); + migrate_relationship_tables($db, $langs, $conf, 'co_fa', 'fk_commande', 'commande', 'fk_facture', 'facture'); - migrate_project_user_resp($db, $langs, $conf); + migrate_project_user_resp($db, $langs, $conf); - migrate_project_task_actors($db, $langs, $conf); - } + migrate_project_task_actors($db, $langs, $conf); + } - // Script for 2.9 - $afterversionarray = explode('.', '2.8.9'); - $beforeversionarray = explode('.', '2.9.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_project_task_time($db, $langs, $conf); + // Script for 2.9 + $afterversionarray = explode('.', '2.8.9'); + $beforeversionarray = explode('.', '2.9.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_project_task_time($db, $langs, $conf); - migrate_customerorder_shipping($db, $langs, $conf); + migrate_customerorder_shipping($db, $langs, $conf); - migrate_shipping_delivery($db, $langs, $conf); + migrate_shipping_delivery($db, $langs, $conf); - migrate_shipping_delivery2($db, $langs, $conf); - } + migrate_shipping_delivery2($db, $langs, $conf); + } - // Script for 3.0 - $afterversionarray = explode('.', '2.9.9'); - $beforeversionarray = explode('.', '3.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - // No particular code - } + // Script for 3.0 + $afterversionarray = explode('.', '2.9.9'); + $beforeversionarray = explode('.', '3.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + // No particular code + } - // Script for 3.1 - $afterversionarray = explode('.', '3.0.9'); - $beforeversionarray = explode('.', '3.1.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); + // Script for 3.1 + $afterversionarray = explode('.', '3.0.9'); + $beforeversionarray = explode('.', '3.1.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); - migrate_actioncomm_element($db, $langs, $conf); - } + migrate_actioncomm_element($db, $langs, $conf); + } - // Script for 3.2 - $afterversionarray = explode('.', '3.1.9'); - $beforeversionarray = explode('.', '3.2.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_price_contrat($db, $langs, $conf); + // Script for 3.2 + $afterversionarray = explode('.', '3.1.9'); + $beforeversionarray = explode('.', '3.2.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_price_contrat($db, $langs, $conf); - migrate_mode_reglement($db, $langs, $conf); + migrate_mode_reglement($db, $langs, $conf); - migrate_clean_association($db, $langs, $conf); - } + migrate_clean_association($db, $langs, $conf); + } - // Script for 3.3 - $afterversionarray = explode('.', '3.2.9'); - $beforeversionarray = explode('.', '3.3.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_categorie_association($db, $langs, $conf); - } + // Script for 3.3 + $afterversionarray = explode('.', '3.2.9'); + $beforeversionarray = explode('.', '3.3.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_categorie_association($db, $langs, $conf); + } // Script for 3.4 // No specific scripts - // Tasks to do always and only into last targeted version - $afterversionarray = explode('.', '3.6.9'); // target is after this - $beforeversionarray = explode('.', '3.7.9'); // target is before this - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_event_assignement($db, $langs, $conf); - } + // Tasks to do always and only into last targeted version + $afterversionarray = explode('.', '3.6.9'); // target is after this + $beforeversionarray = explode('.', '3.7.9'); // target is before this + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_event_assignement($db, $langs, $conf); + } - // Scripts for 3.9 - $afterversionarray = explode('.', '3.7.9'); - $beforeversionarray = explode('.', '3.8.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - // No particular code - } + // Scripts for 3.9 + $afterversionarray = explode('.', '3.7.9'); + $beforeversionarray = explode('.', '3.8.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + // No particular code + } - // Scripts for 4.0 - $afterversionarray = explode('.', '3.9.9'); - $beforeversionarray = explode('.', '4.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); - } + // Scripts for 4.0 + $afterversionarray = explode('.', '3.9.9'); + $beforeversionarray = explode('.', '4.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); + } - // Scripts for 5.0 - $afterversionarray = explode('.', '4.0.9'); - $beforeversionarray = explode('.', '5.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - // Migrate to add entity value into llx_societe_remise - migrate_remise_entity($db, $langs, $conf); + // Scripts for 5.0 + $afterversionarray = explode('.', '4.0.9'); + $beforeversionarray = explode('.', '5.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + // Migrate to add entity value into llx_societe_remise + migrate_remise_entity($db, $langs, $conf); - // Migrate to add entity value into llx_societe_remise_except - migrate_remise_except_entity($db, $langs, $conf); - } + // Migrate to add entity value into llx_societe_remise_except + migrate_remise_except_entity($db, $langs, $conf); + } - // Scripts for 6.0 - $afterversionarray = explode('.', '5.0.9'); - $beforeversionarray = explode('.', '6.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - if (!empty($conf->multicompany->enabled)) - { - global $multicompany_transverse_mode; + // Scripts for 6.0 + $afterversionarray = explode('.', '5.0.9'); + $beforeversionarray = explode('.', '6.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + if (!empty($conf->multicompany->enabled)) + { + global $multicompany_transverse_mode; - // Only if the transverse mode is not used - if (empty($multicompany_transverse_mode)) - { - // Migrate to add entity value into llx_user_rights - migrate_user_rights_entity($db, $langs, $conf); + // Only if the transverse mode is not used + if (empty($multicompany_transverse_mode)) + { + // Migrate to add entity value into llx_user_rights + migrate_user_rights_entity($db, $langs, $conf); - // Migrate to add entity value into llx_usergroup_rights - migrate_usergroup_rights_entity($db, $langs, $conf); - } - } - } + // Migrate to add entity value into llx_usergroup_rights + migrate_usergroup_rights_entity($db, $langs, $conf); + } + } + } - // Scripts for 7.0 - $afterversionarray = explode('.', '6.0.9'); - $beforeversionarray = explode('.', '7.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - // Migrate contact association - migrate_event_assignement_contact($db, $langs, $conf); + // Scripts for 7.0 + $afterversionarray = explode('.', '6.0.9'); + $beforeversionarray = explode('.', '7.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + // Migrate contact association + migrate_event_assignement_contact($db, $langs, $conf); - migrate_reset_blocked_log($db, $langs, $conf); - } + migrate_reset_blocked_log($db, $langs, $conf); + } - // Scripts for 8.0 - $afterversionarray = explode('.', '7.0.9'); - $beforeversionarray = explode('.', '8.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); - } + // Scripts for 8.0 + $afterversionarray = explode('.', '7.0.9'); + $beforeversionarray = explode('.', '8.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); + } - // Scripts for 9.0 - $afterversionarray = explode('.', '8.0.9'); - $beforeversionarray = explode('.', '9.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) - { - migrate_user_photospath(); - } + // Scripts for 9.0 + $afterversionarray = explode('.', '8.0.9'); + $beforeversionarray = explode('.', '9.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) + { + migrate_user_photospath(); + } - // Scripts for 11.0 - $afterversionarray = explode('.', '10.0.9'); - $beforeversionarray = explode('.', '11.0.9'); - if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_users_socialnetworks(); - migrate_members_socialnetworks(); - migrate_contacts_socialnetworks(); - migrate_thirdparties_socialnetworks(); - } - } + // Scripts for 11.0 + $afterversionarray = explode('.', '10.0.9'); + $beforeversionarray = explode('.', '11.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_users_socialnetworks(); + migrate_members_socialnetworks(); + migrate_contacts_socialnetworks(); + migrate_thirdparties_socialnetworks(); + } + } // Code executed only if migration is LAST ONE. Must always be done. if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) @@ -497,86 +497,86 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ migrate_reload_menu($db, $langs, $conf); } - // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' - // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (!$error && $enablemodules) - { - // Reload modules (this must be always done and only into last targeted version) - $listofmodules = array(); - $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); - $tmplistofmodules = explode(',', $enablemodules); - foreach ($tmplistofmodules as $value) - { - $listofmodules[$value] = 'forceactivate'; - } - migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); - } + // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' + // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. + if (!$error && $enablemodules) + { + // Reload modules (this must be always done and only into last targeted version) + $listofmodules = array(); + $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); + $tmplistofmodules = explode(',', $enablemodules); + foreach ($tmplistofmodules as $value) + { + $listofmodules[$value] = 'forceactivate'; + } + migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); + } - // Can call a dedicated external upgrade process - if (!$error) - { - $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); - $object = new stdClass(); - $action = "upgrade"; - $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($hookmanager->resNbOfHooks > 0) - { - if ($reshook < 0) - { - print ''; - } else { - print ''; - } - } else { - //if (! empty($conf->modules)) - if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done - { - print ''; - } - } - } + // Can call a dedicated external upgrade process + if (!$error) + { + $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($hookmanager->resNbOfHooks > 0) + { + if ($reshook < 0) + { + print ''; + } else { + print ''; + } + } else { + //if (! empty($conf->modules)) + if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done + { + print ''; + } + } + } - print '
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'; - print ''.$langs->trans('UpgradeExternalModule').': '; - print $hookmanager->error; - print ""; - print '
'; - print ''.$langs->trans('UpgradeExternalModule').': OK'; - print ""; - print '
'; - print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); - print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '; + print $hookmanager->error; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').': OK'; + print ""; + print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); + print '
'; + print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; - $db->query($sql, 1); + $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; + $db->query($sql, 1); - // We always commit. - // Process is designed so we can run it several times whatever is situation. - $db->commit(); - $db->close(); + // We always commit. + // Process is designed so we can run it several times whatever is situation. + $db->commit(); + $db->close(); - // Copy directory medias - $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; - $destroot = DOL_DATA_ROOT.'/medias'; - dolCopyDir($srcroot, $destroot, 0, 0); + // Copy directory medias + $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; + $destroot = DOL_DATA_ROOT.'/medias'; + dolCopyDir($srcroot, $destroot, 0, 0); - // Actions for all versions (no database change but delete some files and directories) - migrate_delete_old_files($db, $langs, $conf); - migrate_delete_old_dir($db, $langs, $conf); - // Actions for all versions (no database change but create some directories) - dol_mkdir(DOL_DATA_ROOT.'/bank'); - // Actions for all versions (no database change but rename some directories) - migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); + // Actions for all versions (no database change but delete some files and directories) + migrate_delete_old_files($db, $langs, $conf); + migrate_delete_old_dir($db, $langs, $conf); + // Actions for all versions (no database change but create some directories) + dol_mkdir(DOL_DATA_ROOT.'/bank'); + // Actions for all versions (no database change but rename some directories) + migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); - print '

'.$langs->trans("MigrationFinished").'
'; + print '

'.$langs->trans("MigrationFinished").'
'; } else { - print '
'.$langs->trans('ErrorWrongParameters').'
'; - $error++; + print '
'.$langs->trans('ErrorWrongParameters').'
'; + $error++; } $ret = 0; @@ -603,78 +603,78 @@ if ($ret) exit($ret); */ function migrate_paiements($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); - $obj = $db->fetch_object($result); - if ($obj) - { - $sql = "SELECT p.rowid, p.fk_facture, p.amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " WHERE p.fk_facture > 0"; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); + $obj = $db->fetch_object($result); + if ($obj) + { + $sql = "SELECT p.rowid, p.fk_facture, p.amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " WHERE p.fk_facture > 0"; - $resql = $db->query($sql); + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_paiements"); - if ($resql) - { - $i = 0; - $row = array(); - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_paiements"); + if ($resql) + { + $i = 0; + $row = array(); + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $row[$i][0] = $obj->rowid; - $row[$i][1] = $obj->fk_facture; - $row[$i][2] = $obj->amount; - $i++; - } - } else { - dol_print_error($db); - } + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $row[$i][0] = $obj->rowid; + $row[$i][1] = $obj->fk_facture; + $row[$i][2] = $obj->amount; + $i++; + } + } else { + dol_print_error($db); + } - if ($num) - { - print $langs->trans('MigrationPaymentsNumberToUpdate', $num)."
\n"; - if ($db->begin()) - { - $res = 0; - $num = count($row); - for ($i = 0; $i < $num; $i++) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; + if ($num) + { + print $langs->trans('MigrationPaymentsNumberToUpdate', $num)."
\n"; + if ($db->begin()) + { + $res = 0; + $num = count($row); + for ($i = 0; $i < $num; $i++) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; + $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; - $res += $db->query($sql); + $res += $db->query($sql); - $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0]; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0]; - $res += $db->query($sql); + $res += $db->query($sql); - print $langs->trans('MigrationProcessPaymentUpdate', $row[$i][0])."
\n"; - } - } + print $langs->trans('MigrationProcessPaymentUpdate', $row[$i][0])."
\n"; + } + } - if ($res == (2 * count($row))) - { - $db->commit(); - print $langs->trans('MigrationSuccessfullUpdate')."
"; - } else { - $db->rollback(); - print $langs->trans('MigrationUpdateFailed').'
'; - } - } else { - print $langs->trans('MigrationPaymentsNothingToUpdate')."
\n"; - } - } else { - print $langs->trans('MigrationPaymentsNothingToUpdate')."
\n"; - } + if ($res == (2 * count($row))) + { + $db->commit(); + print $langs->trans('MigrationSuccessfullUpdate')."
"; + } else { + $db->rollback(); + print $langs->trans('MigrationUpdateFailed').'
'; + } + } else { + print $langs->trans('MigrationPaymentsNothingToUpdate')."
\n"; + } + } else { + print $langs->trans('MigrationPaymentsNothingToUpdate')."
\n"; + } - print ''; + print ''; } /** @@ -689,109 +689,109 @@ function migrate_paiements($db, $langs, $conf) */ function migrate_paiements_orphelins_1($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); - $obj = $db->fetch_object($result); - if ($obj) - { - // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture - $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql .= " bu2.url_id as socid"; - $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; - $sql .= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; - $sql .= " AND b.rappro = 1"; - $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); + $obj = $db->fetch_object($result); + if ($obj) + { + // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture + $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND b.rappro = 1"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; - $resql = $db->query($sql); + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1"); - $row = array(); - if ($resql) - { - $i = $j = 0; - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_1"); + $row = array(); + if ($resql) + { + $i = $j = 0; + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { - $row[$j]['paymentid'] = $obj->rowid; // paymentid - $row[$j]['pamount'] = $obj->pamount; - $row[$j]['fk_bank'] = $obj->fk_bank; - $row[$j]['bamount'] = $obj->bamount; - $row[$j]['socid'] = $obj->socid; - $row[$j]['datec'] = $obj->datec; - $j++; - } - $i++; - } - } else { - dol_print_error($db); - } + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas + { + $row[$j]['paymentid'] = $obj->rowid; // paymentid + $row[$j]['pamount'] = $obj->pamount; + $row[$j]['fk_bank'] = $obj->fk_bank; + $row[$j]['bamount'] = $obj->bamount; + $row[$j]['socid'] = $obj->socid; + $row[$j]['datec'] = $obj->datec; + $j++; + } + $i++; + } + } else { + dol_print_error($db); + } - if (count($row)) - { - print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)."
\n"; - $db->begin(); + if (count($row)) + { + print $langs->trans('OrphelinsPaymentsDetectedByMethod', 1).': '.count($row)."
\n"; + $db->begin(); - $res = 0; - $num = count($row); - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + $res = 0; + $num = count($row); + for ($i = 0; $i < $num; $i++) + { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; - // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql .= " AND pf.fk_facture IS NULL"; - $sql .= " ORDER BY f.fk_statut"; - //print $sql.'
'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { - $obj = $db->fetch_object($resql); - $facid = $obj->rowid; + // On cherche facture sans lien paiement et du meme montant et pour meme societe. + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; + //print $sql.'
'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + //print 'Nb of invoice found for this amount and company :'.$num.'
'; + if ($num >= 1) + { + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; - $res += $db->query($sql); + $res += $db->query($sql); - print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; - } - } else { - print 'ERROR'; - } - } + print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; + } + } else { + print 'ERROR'; + } + } - if ($res > 0) - { - print $langs->trans('MigrationSuccessfullUpdate')."
"; - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } + if ($res > 0) + { + print $langs->trans('MigrationSuccessfullUpdate')."
"; + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } - $db->commit(); - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } + $db->commit(); + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } - print ''; + print ''; } /** @@ -806,124 +806,124 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) */ function migrate_paiements_orphelins_2($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationPaymentsUpdate')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); - $obj = $db->fetch_object($result); - if ($obj) - { - // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture - $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql .= " bu2.url_id as socid"; - $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; - $sql .= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; - $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiement", "fk_facture"); + $obj = $db->fetch_object($result); + if ($obj) + { + // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture + $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; - $resql = $db->query($sql); + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2"); - $row = array(); - if ($resql) - { - $i = $j = 0; - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_paiements_orphelins_2"); + $row = array(); + if ($resql) + { + $i = $j = 0; + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas - { - $row[$j]['paymentid'] = $obj->rowid; // paymentid - $row[$j]['pamount'] = $obj->pamount; - $row[$j]['fk_bank'] = $obj->fk_bank; - $row[$j]['bamount'] = $obj->bamount; - $row[$j]['socid'] = $obj->socid; - $row[$j]['datec'] = $obj->datec; - $j++; - } - $i++; - } - } else { - dol_print_error($db); - } + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas + { + $row[$j]['paymentid'] = $obj->rowid; // paymentid + $row[$j]['pamount'] = $obj->pamount; + $row[$j]['fk_bank'] = $obj->fk_bank; + $row[$j]['bamount'] = $obj->bamount; + $row[$j]['socid'] = $obj->socid; + $row[$j]['datec'] = $obj->datec; + $j++; + } + $i++; + } + } else { + dol_print_error($db); + } - $nberr = 0; + $nberr = 0; - $num = count($row); - if ($num) - { - print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; - $db->begin(); + $num = count($row); + if ($num) + { + print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; + $db->begin(); - $res = 0; - for ($i = 0; $i < $num; $i++) - { - if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; + $res = 0; + for ($i = 0; $i < $num; $i++) + { + if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; - // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql .= " AND pf.fk_facture IS NULL"; - $sql .= " ORDER BY f.fk_statut"; - //print $sql.'
'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - //print 'Nb of invoice found for this amount and company :'.$num.'
'; - if ($num >= 1) - { - $obj = $db->fetch_object($resql); - $facid = $obj->rowid; + // On cherche facture sans lien paiement et du meme montant et pour meme societe. + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; + //print $sql.'
'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + //print 'Nb of invoice found for this amount and company :'.$num.'
'; + if ($num >= 1) + { + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; - $res += $db->query($sql); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $res += $db->query($sql); - print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; - } - } else { - print 'ERROR'; - $nberr++; - } - } + print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; + } + } else { + print 'ERROR'; + $nberr++; + } + } - if ($res > 0) - { - print $langs->trans('MigrationSuccessfullUpdate')."
"; - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } + if ($res > 0) + { + print $langs->trans('MigrationSuccessfullUpdate')."
"; + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } - $db->commit(); - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } + $db->commit(); + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } - // Delete obsolete fields fk_facture - $db->begin(); + // Delete obsolete fields fk_facture + $db->begin(); - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture"; - $db->query($sql); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiement DROP COLUMN fk_facture"; + $db->query($sql); - if (!$nberr) - { - $db->commit(); - } else { - print 'ERROR'; - $db->rollback(); - } - } else { - print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; - } + if (!$nberr) + { + $db->commit(); + } else { + print 'ERROR'; + $db->rollback(); + } + } else { + print $langs->trans('MigrationPaymentsNothingUpdatable')."
\n"; + } - print ''; + print ''; } @@ -937,84 +937,84 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) */ function migrate_contracts_det($db, $langs, $conf) { - print ''; + print ''; - $nberr = 0; + $nberr = 0; - print '
'; - print ''.$langs->trans('MigrationContractsUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationContractsUpdate')."
\n"; - $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.fk_product, c.fk_facture, c.fk_user_author,"; - $sql .= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; - $sql .= " ON c.fk_product = p.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; - $sql .= " ON c.rowid=cd.fk_contrat"; - $sql .= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; - $resql = $db->query($sql); + $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.fk_product, c.fk_facture, c.fk_user_author,"; + $sql .= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; + $sql .= " ON c.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " ON c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_contracts_det"); - if ($resql) - { - $i = 0; - $row = array(); - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_contracts_det"); + if ($resql) + { + $i = 0; + $row = array(); + $num = $db->num_rows($resql); - if ($num) - { - print $langs->trans('MigrationContractsNumberToUpdate', $num)."
\n"; - $db->begin(); + if ($num) + { + print $langs->trans('MigrationContractsNumberToUpdate', $num)."
\n"; + $db->begin(); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; - $sql .= "fk_contrat, fk_product, statut, label, description,"; - $sql .= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; - $sql .= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; - $sql .= " VALUES ("; - $sql .= $obj->cref.", ".($obj->fk_product ? $obj->fk_product : 0).", "; - $sql .= "0, "; - $sql .= "'".$db->escape($obj->label)."', null, "; - $sql .= ($obj->date_contrat ? "'".$db->escape($obj->date_contrat)."'" : "null").", "; - $sql .= "null, "; - $sql .= "null, "; - $sql .= "'".$db->escape($obj->tva_tx)."' , 1, "; - $sql .= "'".$db->escape($obj->price)."', '".$db->escape($obj->price)."', ".$obj->fk_user_author.","; - $sql .= "null"; - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; + $sql .= "fk_contrat, fk_product, statut, label, description,"; + $sql .= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; + $sql .= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; + $sql .= " VALUES ("; + $sql .= $obj->cref.", ".($obj->fk_product ? $obj->fk_product : 0).", "; + $sql .= "0, "; + $sql .= "'".$db->escape($obj->label)."', null, "; + $sql .= ($obj->date_contrat ? "'".$db->escape($obj->date_contrat)."'" : "null").", "; + $sql .= "null, "; + $sql .= "null, "; + $sql .= "'".$db->escape($obj->tva_tx)."' , 1, "; + $sql .= "'".$db->escape($obj->price)."', '".$db->escape($obj->price)."', ".$obj->fk_user_author.","; + $sql .= "null"; + $sql .= ")"; - if ($db->query($sql)) - { - print $langs->trans('MigrationContractsLineCreation', $obj->cref)."
\n"; - } else { - dol_print_error($db); - $nberr++; - } + if ($db->query($sql)) + { + print $langs->trans('MigrationContractsLineCreation', $obj->cref)."
\n"; + } else { + dol_print_error($db); + $nberr++; + } - $i++; - } + $i++; + } - if (!$nberr) - { - // $db->rollback(); - $db->commit(); - print $langs->trans('MigrationSuccessfullUpdate')."
"; - } else { - $db->rollback(); - print $langs->trans('MigrationUpdateFailed').'
'; - } - } else { - print $langs->trans('MigrationContractsNothingToUpdate')."
\n"; - } - } else { - print $langs->trans('MigrationContractsFieldDontExist')."
\n"; - // dol_print_error($db); - } + if (!$nberr) + { + // $db->rollback(); + $db->commit(); + print $langs->trans('MigrationSuccessfullUpdate')."
"; + } else { + $db->rollback(); + print $langs->trans('MigrationUpdateFailed').'
'; + } + } else { + print $langs->trans('MigrationContractsNothingToUpdate')."
\n"; + } + } else { + print $langs->trans('MigrationContractsFieldDontExist')."
\n"; + // dol_print_error($db); + } - print ''; + print ''; } /** @@ -1027,73 +1027,73 @@ function migrate_contracts_det($db, $langs, $conf) */ function migrate_links_transfert($db, $langs, $conf) { - print ''; + print ''; - $nberr = 0; + $nberr = 0; - print '
'; - print ''.$langs->trans('MigrationBankTransfertsUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationBankTransfertsUpdate')."
\n"; - $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; - $sql .= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; - $sql .= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; - $sql .= " AND bu.fk_bank IS NULL"; - $resql = $db->query($sql); + $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; + $sql .= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; + $sql .= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; + $sql .= " AND bu.fk_bank IS NULL"; + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_links_transfert"); - if ($resql) - { - $i = 0; - $row = array(); - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_links_transfert"); + if ($resql) + { + $i = 0; + $row = array(); + $num = $db->num_rows($resql); - if ($num) - { - print $langs->trans('MigrationBankTransfertsToUpdate', $num)."
\n"; - $db->begin(); + if ($num) + { + print $langs->trans('MigrationBankTransfertsToUpdate', $num)."
\n"; + $db->begin(); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql .= "fk_bank, url_id, url, label, type"; - $sql .= ")"; - $sql .= " VALUES ("; - $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; + $sql .= "fk_bank, url_id, url, label, type"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; + $sql .= ")"; - print $sql.'
'; - dolibarr_install_syslog("migrate_links_transfert"); + print $sql.'
'; + dolibarr_install_syslog("migrate_links_transfert"); - if (!$db->query($sql)) - { - dol_print_error($db); - $nberr++; - } + if (!$db->query($sql)) + { + dol_print_error($db); + $nberr++; + } - $i++; - } + $i++; + } - if (!$nberr) - { - // $db->rollback(); - $db->commit(); - print $langs->trans('MigrationSuccessfullUpdate')."
"; - } else { - $db->rollback(); - print $langs->trans('MigrationUpdateFailed').'
'; - } - } else { - print $langs->trans('MigrationBankTransfertsNothingToUpdate')."
\n"; - } - } else { - dol_print_error($db); - } + if (!$nberr) + { + // $db->rollback(); + $db->commit(); + print $langs->trans('MigrationSuccessfullUpdate')."
"; + } else { + $db->rollback(); + print $langs->trans('MigrationUpdateFailed').'
'; + } + } else { + print $langs->trans('MigrationBankTransfertsNothingToUpdate')."
\n"; + } + } else { + dol_print_error($db); + } - print ''; + print ''; } /** @@ -1106,28 +1106,28 @@ function migrate_links_transfert($db, $langs, $conf) */ function migrate_contracts_date1($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; - $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; - dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; + $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; + dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + if ($db->affected_rows($resql) > 0) + print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; + else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; - $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; - dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; + dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + if ($db->affected_rows($resql) > 0) + print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; + else print $langs->trans('MigrationContractsEmptyCreationDatesNothingToUpdate')."
\n"; - print ''; + print ''; } /** @@ -1140,62 +1140,62 @@ function migrate_contracts_date1($db, $langs, $conf) */ function migrate_contracts_date2($db, $langs, $conf) { - print ''; + print ''; - $nberr = 0; + $nberr = 0; - print '
'; - print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')."
\n"; - $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin"; - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; - $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; - $sql .= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; - $sql .= " GROUP BY c.rowid, c.date_contrat"; - $resql = $db->query($sql); + $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; + $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; + $sql .= " GROUP BY c.rowid, c.date_contrat"; + $resql = $db->query($sql); - dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); - if ($resql) - { - $i = 0; - $row = array(); - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); + if ($resql) + { + $i = 0; + $row = array(); + $num = $db->num_rows($resql); - if ($num) - { - $nbcontratsmodifie = 0; - $db->begin(); + if ($num) + { + $nbcontratsmodifie = 0; + $db->begin(); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj->date_contrat > $obj->datemin) - { - $datemin = $db->jdate($obj->datemin); + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj->date_contrat > $obj->datemin) + { + $datemin = $db->jdate($obj->datemin); - print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql .= " SET date_contrat='".$db->idate($datemin)."'"; - $sql .= " WHERE rowid=".$obj->cref; - $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET date_contrat='".$db->idate($datemin)."'"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); - $nbcontratsmodifie++; - } - $i++; - } + $nbcontratsmodifie++; + } + $i++; + } - $db->commit(); + $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; - } - } else { - dol_print_error($db); - } + if ($nbcontratsmodifie) + print $langs->trans('MigrationContractsInvalidDatesNumber', $nbcontratsmodifie)."
\n"; + else print $langs->trans('MigrationContractsInvalidDatesNothingToUpdate')."
\n"; + } + } else { + dol_print_error($db); + } - print ''; + print ''; } /** @@ -1208,20 +1208,20 @@ function migrate_contracts_date2($db, $langs, $conf) */ function migrate_contracts_date3($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; + print '
'; + print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; - $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; - dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) - print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; - else print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; + dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + if ($db->affected_rows($resql) > 0) + print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; + else print $langs->trans('MigrationContractsIncoherentCreationDateNothingToUpdate')."
\n"; - print ''; + print ''; } /** @@ -1234,51 +1234,51 @@ function migrate_contracts_date3($db, $langs, $conf) */ function migrate_contracts_open($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationReopeningContracts')."
\n"; + print '
'; + print ''.$langs->trans('MigrationReopeningContracts')."
\n"; - $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; - dolibarr_install_syslog("upgrade2::migrate_contracts_open"); - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - if ($db->affected_rows($resql) > 0) { - $i = 0; - $row = array(); - $num = $db->num_rows($resql); + $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; + dolibarr_install_syslog("upgrade2::migrate_contracts_open"); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + if ($db->affected_rows($resql) > 0) { + $i = 0; + $row = array(); + $num = $db->num_rows($resql); - if ($num) - { - $nbcontratsmodifie = 0; - $db->begin(); + if ($num) + { + $nbcontratsmodifie = 0; + $db->begin(); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql .= " SET statut=1"; - $sql .= " WHERE rowid=".$obj->cref; - $resql2 = $db->query($sql); - if (!$resql2) dol_print_error($db); + print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET statut=1"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); - $nbcontratsmodifie++; + $nbcontratsmodifie++; - $i++; - } + $i++; + } - $db->commit(); + $db->commit(); - if ($nbcontratsmodifie) - print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; - else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; - } - } else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + if ($nbcontratsmodifie) + print $langs->trans('MigrationReopenedContractsNumber', $nbcontratsmodifie)."
\n"; + else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; + } + } else print $langs->trans('MigrationReopeningContractsNothingToUpdate')."
\n"; - print ''; + print ''; } /** @@ -1291,101 +1291,101 @@ function migrate_contracts_open($db, $langs, $conf) */ function migrate_paiementfourn_facturefourn($db, $langs, $conf) { - global $bc; + global $bc; - print ''; - print '
'; - print ''.$langs->trans('SuppliersInvoices')."
\n"; - print ''; + print ''; + print '
'; + print ''.$langs->trans('SuppliersInvoices')."
\n"; + print ''; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn", "fk_facture_fourn"); - $obj = $db->fetch_object($result); - if ($obj) - { - $error = 0; - $nb = 0; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."paiementfourn", "fk_facture_fourn"); + $obj = $db->fetch_object($result); + if ($obj) + { + $error = 0; + $nb = 0; - $select_sql = 'SELECT rowid, fk_facture_fourn, amount'; - $select_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; - $select_sql .= ' WHERE fk_facture_fourn IS NOT NULL'; + $select_sql = 'SELECT rowid, fk_facture_fourn, amount'; + $select_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; + $select_sql .= ' WHERE fk_facture_fourn IS NOT NULL'; - dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); - $select_resql = $db->query($select_sql); - if ($select_resql) - { - $select_num = $db->num_rows($select_resql); - $i = 0; - $var = true; + dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); + $select_resql = $db->query($select_sql); + if ($select_resql) + { + $select_num = $db->num_rows($select_resql); + $i = 0; + $var = true; - // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (!$error)) - { - $var = !$var; - $select_obj = $db->fetch_object($select_resql); + // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn + while (($i < $select_num) && (!$error)) + { + $var = !$var; + $select_obj = $db->fetch_object($select_resql); - // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. - $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; - $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; - $check_resql = $db->query($check_sql); - if ($check_resql) - { - $check_num = $db->num_rows($check_resql); - if ($check_num == 0) - { - $db->begin(); + // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. + $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; + $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; + $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_resql = $db->query($check_sql); + if ($check_resql) + { + $check_num = $db->num_rows($check_resql); + if ($check_num == 0) + { + $db->begin(); - if ($nb == 0) - { - print ''.$langs->trans('SuppliersInvoices').''; - print 'fk_paiementfournfk_facturefourn'.$langs->trans('Amount').' '; - } + if ($nb == 0) + { + print ''.$langs->trans('SuppliersInvoices').''; + print 'fk_paiementfournfk_facturefourn'.$langs->trans('Amount').' '; + } - print ''; - print ''.$select_obj->rowid.''.$select_obj->fk_facture_fourn.''.$select_obj->amount.''; + print ''; + print ''.$select_obj->rowid.''.$select_obj->fk_facture_fourn.''.$select_obj->amount.''; - $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET '; - $insert_sql .= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; - $insert_sql .= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; - $insert_sql .= ' amount = \''.$select_obj->amount.'\''; - $insert_resql = $db->query($insert_sql); + $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET '; + $insert_sql .= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; + $insert_sql .= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; + $insert_sql .= ' amount = \''.$select_obj->amount.'\''; + $insert_resql = $db->query($insert_sql); - if ($insert_resql) - { - $nb++; - print ''.$langs->trans("OK").''; - } else { - print 'Error on insert'; - $error++; - } - print ''; - } - } else { - $error++; - } - $i++; - } - } else { - $error++; - } + if ($insert_resql) + { + $nb++; + print ''.$langs->trans("OK").''; + } else { + print 'Error on insert'; + $error++; + } + print ''; + } + } else { + $error++; + } + $i++; + } + } else { + $error++; + } - if (!$error) - { - if (!$nb) - { - print ''.$langs->trans("AlreadyDone").''; - } - $db->commit(); + if (!$error) + { + if (!$nb) + { + print ''.$langs->trans("AlreadyDone").''; + } + $db->commit(); - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiementfourn DROP COLUMN fk_facture_fourn"; - $db->query($sql); - } else { - print ''.$langs->trans("Error").''; - $db->rollback(); - } - } else { - print ''.$langs->trans("AlreadyDone").''; - } + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."paiementfourn DROP COLUMN fk_facture_fourn"; + $db->query($sql); + } else { + print ''.$langs->trans("Error").''; + $db->rollback(); + } + } else { + print ''.$langs->trans("AlreadyDone").''; + } } /** @@ -1398,105 +1398,105 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) */ function migrate_price_facture($db, $langs, $conf) { - $err = 0; + $err = 0; - $tmpmysoc = new Societe($db); - $tmpmysoc->setMysoc($conf); + $tmpmysoc = new Societe($db); + $tmpmysoc->setMysoc($conf); - $db->begin(); + $db->begin(); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationInvoice')."
\n"; + print '
'; + print ''.$langs->trans('MigrationInvoice')."
\n"; - // List of invoice lines not up to date - $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,"; - $sql .= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; - $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE fd.fk_facture = f.rowid"; - $sql .= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; - //print $sql; + // List of invoice lines not up to date + $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,"; + $sql .= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE fd.fk_facture = f.rowid"; + $sql .= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; + //print $sql; - dolibarr_install_syslog("upgrade2::migrate_price_facture"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + dolibarr_install_syslog("upgrade2::migrate_price_facture"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $rowid = $obj->rowid; - $qty = $obj->qty; - $pu = $obj->subprice; - $vatrate = $obj->vatrate; - $remise_percent = $obj->remise_percent; - $remise_percent_global = $obj->remise_percent_global; - $total_ttc_f = $obj->total_ttc_f; - $info_bits = $obj->info_bits; + $rowid = $obj->rowid; + $qty = $obj->qty; + $pu = $obj->subprice; + $vatrate = $obj->vatrate; + $remise_percent = $obj->remise_percent; + $remise_percent_global = $obj->remise_percent_global; + $total_ttc_f = $obj->total_ttc_f; + $info_bits = $obj->info_bits; - // On met a jour les 3 nouveaux champs - $facligne = new FactureLigne($db); - $facligne->fetch($rowid); + // On met a jour les 3 nouveaux champs + $facligne = new FactureLigne($db); + $facligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); - $total_ht = $result[0]; - $total_tva = $result[1]; - $total_ttc = $result[2]; + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); + $total_ht = $result[0]; + $total_tva = $result[1]; + $total_ttc = $result[2]; - $facligne->total_ht = $total_ht; - $facligne->total_tva = $total_tva; - $facligne->total_ttc = $total_ttc; + $facligne->total_ht = $total_ht; + $facligne->total_tva = $total_tva; + $facligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); - print ". "; - $facligne->update_total(); + dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); + print ". "; + $facligne->update_total(); - /* On touche a facture mere uniquement si total_ttc = 0 */ - if (!$total_ttc_f) - { - $facture = new Facture($db); - $facture->id = $obj->facid; + /* On touche a facture mere uniquement si total_ttc = 0 */ + if (!$total_ttc_f) + { + $facture = new Facture($db); + $facture->id = $obj->facid; - if ($facture->fetch($facture->id) >= 0) - { - if ($facture->update_price() > 0) - { - //print $facture->id; - } else { - print "Error id=".$facture->id; - $err++; - } - } else { - print "Error #3"; - $err++; - } - } - print " "; + if ($facture->fetch($facture->id) >= 0) + { + if ($facture->update_price() > 0) + { + //print $facture->id; + } else { + print "Error id=".$facture->id; + $err++; + } + } else { + print "Error #3"; + $err++; + } + } + print " "; - $i++; - } - } else { - print $langs->trans("AlreadyDone"); - } - $db->free($resql); + $i++; + } + } else { + print $langs->trans("AlreadyDone"); + } + $db->free($resql); - $db->commit(); - } else { - print "Error #1 ".$db->error(); - $err++; + $db->commit(); + } else { + print "Error #1 ".$db->error(); + $err++; - $db->rollback(); - } + $db->rollback(); + } - print '
'; + print '
'; - print ''; + print ''; } /** @@ -1512,59 +1512,59 @@ function migrate_price_propal($db, $langs, $conf) $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - $db->begin(); + $db->begin(); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationProposal')."
\n"; + print '
'; + print ''.$langs->trans('MigrationProposal')."
\n"; - // List of proposal lines not up to date - $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,"; - $sql .= " p.rowid as propalid, p.remise_percent as remise_percent_global"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; - $sql .= " WHERE pd.fk_propal = p.rowid"; - $sql .= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; + // List of proposal lines not up to date + $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,"; + $sql .= " p.rowid as propalid, p.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; + $sql .= " WHERE pd.fk_propal = p.rowid"; + $sql .= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; - dolibarr_install_syslog("upgrade2::migrate_price_propal"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + dolibarr_install_syslog("upgrade2::migrate_price_propal"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $rowid = $obj->rowid; - $qty = $obj->qty; - $pu = $obj->subprice; - $vatrate = $obj->vatrate; - $remise_percent = $obj->remise_percent; - $remise_percent_global = $obj->remise_percent_global; - $info_bits = $obj->info_bits; + $rowid = $obj->rowid; + $qty = $obj->qty; + $pu = $obj->subprice; + $vatrate = $obj->vatrate; + $remise_percent = $obj->remise_percent; + $remise_percent_global = $obj->remise_percent_global; + $info_bits = $obj->info_bits; - // On met a jour les 3 nouveaux champs - $propalligne = new PropaleLigne($db); - $propalligne->fetch($rowid); + // On met a jour les 3 nouveaux champs + $propalligne = new PropaleLigne($db); + $propalligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); - $total_ht = $result[0]; - $total_tva = $result[1]; - $total_ttc = $result[2]; + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); + $total_ht = $result[0]; + $total_tva = $result[1]; + $total_ttc = $result[2]; - $propalligne->total_ht = $total_ht; - $propalligne->total_tva = $total_tva; - $propalligne->total_ttc = $total_ttc; + $propalligne->total_ht = $total_ht; + $propalligne->total_tva = $total_tva; + $propalligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); - print ". "; - $propalligne->update_total(); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); + print ". "; + $propalligne->update_total(); - /* On touche pas a propal mere + /* On touche pas a propal mere $propal = new Propal($db); $propal->id=$obj->rowid; if ( $propal->fetch($propal->id) >= 0 ) @@ -1583,24 +1583,24 @@ function migrate_price_propal($db, $langs, $conf) print "Error #3"; } */ - $i++; - } - } else { - print $langs->trans("AlreadyDone"); - } + $i++; + } + } else { + print $langs->trans("AlreadyDone"); + } - $db->free($resql); + $db->free($resql); - $db->commit(); - } else { - print "Error #1 ".$db->error(); + $db->commit(); + } else { + print "Error #1 ".$db->error(); - $db->rollback(); - } + $db->rollback(); + } - print '
'; + print '
'; - print ''; + print ''; } /** @@ -1613,79 +1613,79 @@ function migrate_price_propal($db, $langs, $conf) */ function migrate_price_contrat($db, $langs, $conf) { - $db->begin(); + $db->begin(); $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationContract')."
\n"; + print '
'; + print ''.$langs->trans('MigrationContract')."
\n"; - // List of contract lines not up to date - $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql .= " c.rowid as contratid"; - $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; - $sql .= " WHERE cd.fk_contrat = c.rowid"; - $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; + // List of contract lines not up to date + $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; + $sql .= " c.rowid as contratid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE cd.fk_contrat = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; - dolibarr_install_syslog("upgrade2::migrate_price_contrat"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + dolibarr_install_syslog("upgrade2::migrate_price_contrat"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $rowid = $obj->rowid; - $qty = $obj->qty; - $pu = $obj->subprice; - $vatrate = $obj->vatrate; - $remise_percent = $obj->remise_percent; - $info_bits = $obj->info_bits; + $rowid = $obj->rowid; + $qty = $obj->qty; + $pu = $obj->subprice; + $vatrate = $obj->vatrate; + $remise_percent = $obj->remise_percent; + $info_bits = $obj->info_bits; - // On met a jour les 3 nouveaux champs - $contratligne = new ContratLigne($db); - //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis - $contratligne->fetch($rowid); + // On met a jour les 3 nouveaux champs + $contratligne = new ContratLigne($db); + //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis + $contratligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); - $total_ht = $result[0]; - $total_tva = $result[1]; - $total_ttc = $result[2]; + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); + $total_ht = $result[0]; + $total_tva = $result[1]; + $total_ttc = $result[2]; - $contratligne->total_ht = $total_ht; - $contratligne->total_tva = $total_tva; - $contratligne->total_ttc = $total_ttc; + $contratligne->total_ht = $total_ht; + $contratligne->total_tva = $total_tva; + $contratligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); - print ". "; - $contratligne->update_total(); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); + print ". "; + $contratligne->update_total(); - $i++; - } - } else { - print $langs->trans("AlreadyDone"); - } + $i++; + } + } else { + print $langs->trans("AlreadyDone"); + } - $db->free($resql); + $db->free($resql); - $db->commit(); - } else { - print "Error #1 ".$db->error(); + $db->commit(); + } else { + print "Error #1 ".$db->error(); - $db->rollback(); - } + $db->rollback(); + } - print '
'; + print '
'; - print ''; + print ''; } /** @@ -1698,61 +1698,61 @@ function migrate_price_contrat($db, $langs, $conf) */ function migrate_price_commande($db, $langs, $conf) { - $db->begin(); + $db->begin(); - $tmpmysoc = new Societe($db); - $tmpmysoc->setMysoc($conf); + $tmpmysoc = new Societe($db); + $tmpmysoc->setMysoc($conf); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationOrder')."
\n"; + print '
'; + print ''.$langs->trans('MigrationOrder')."
\n"; - // List of sales orders lines not up to date - $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; - $sql .= " WHERE cd.fk_commande = c.rowid"; - $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + // List of sales orders lines not up to date + $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; - dolibarr_install_syslog("upgrade2::migrate_price_commande"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + dolibarr_install_syslog("upgrade2::migrate_price_commande"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $rowid = $obj->rowid; - $qty = $obj->qty; - $pu = $obj->subprice; - $vatrate = $obj->vatrate; - $remise_percent = $obj->remise_percent; - $remise_percent_global = $obj->remise_percent_global; - $info_bits = $obj->info_bits; + $rowid = $obj->rowid; + $qty = $obj->qty; + $pu = $obj->subprice; + $vatrate = $obj->vatrate; + $remise_percent = $obj->remise_percent; + $remise_percent_global = $obj->remise_percent_global; + $info_bits = $obj->info_bits; - // On met a jour les 3 nouveaux champs - $commandeligne = new OrderLine($db); - $commandeligne->fetch($rowid); + // On met a jour les 3 nouveaux champs + $commandeligne = new OrderLine($db); + $commandeligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); - $total_ht = $result[0]; - $total_tva = $result[1]; - $total_ttc = $result[2]; + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); + $total_ht = $result[0]; + $total_tva = $result[1]; + $total_ttc = $result[2]; - $commandeligne->total_ht = $total_ht; - $commandeligne->total_tva = $total_tva; - $commandeligne->total_ttc = $total_ttc; + $commandeligne->total_ht = $total_ht; + $commandeligne->total_tva = $total_tva; + $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); - print ". "; - $commandeligne->update_total(); + dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); + print ". "; + $commandeligne->update_total(); - /* On touche pas a facture mere + /* On touche pas a facture mere $commande = new Commande($db); $commande->id = $obj->rowid; if ( $commande->fetch($commande->id) >= 0 ) @@ -1771,15 +1771,15 @@ function migrate_price_commande($db, $langs, $conf) print "Error #3"; } */ - $i++; - } - } else { - print $langs->trans("AlreadyDone"); - } + $i++; + } + } else { + print $langs->trans("AlreadyDone"); + } - $db->free($resql); + $db->free($resql); - /* + /* $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0 AND remise_percent = 0"; $resql=$db->query($sql); @@ -1789,16 +1789,16 @@ function migrate_price_commande($db, $langs, $conf) } */ - $db->commit(); - } else { - print "Error #1 ".$db->error(); + $db->commit(); + } else { + print "Error #1 ".$db->error(); - $db->rollback(); - } + $db->rollback(); + } - print '
'; + print '
'; - print ''; + print ''; } /** @@ -1811,61 +1811,61 @@ function migrate_price_commande($db, $langs, $conf) */ function migrate_price_commande_fournisseur($db, $langs, $conf) { - $db->begin(); + $db->begin(); - $tmpmysoc = new Societe($db); - $tmpmysoc->setMysoc($conf); + $tmpmysoc = new Societe($db); + $tmpmysoc->setMysoc($conf); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationSupplierOrder')."
\n"; + print '
'; + print ''.$langs->trans('MigrationSupplierOrder')."
\n"; - // List of purchase order lines not up to date - $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql .= " WHERE cd.fk_commande = c.rowid"; - $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + // List of purchase order lines not up to date + $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; - dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $rowid = $obj->rowid; - $qty = $obj->qty; - $pu = $obj->subprice; - $vatrate = $obj->vatrate; - $remise_percent = $obj->remise_percent; - $remise_percent_global = $obj->remise_percent_global; - $info_bits = $obj->info_bits; + $rowid = $obj->rowid; + $qty = $obj->qty; + $pu = $obj->subprice; + $vatrate = $obj->vatrate; + $remise_percent = $obj->remise_percent; + $remise_percent_global = $obj->remise_percent_global; + $info_bits = $obj->info_bits; - // On met a jour les 3 nouveaux champs - $commandeligne = new CommandeFournisseurLigne($db); - $commandeligne->fetch($rowid); + // On met a jour les 3 nouveaux champs + $commandeligne = new CommandeFournisseurLigne($db); + $commandeligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); - $total_ht = $result[0]; - $total_tva = $result[1]; - $total_ttc = $result[2]; + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); + $total_ht = $result[0]; + $total_tva = $result[1]; + $total_ttc = $result[2]; - $commandeligne->total_ht = $total_ht; - $commandeligne->total_tva = $total_tva; - $commandeligne->total_ttc = $total_ttc; + $commandeligne->total_ht = $total_ht; + $commandeligne->total_tva = $total_tva; + $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); - print ". "; - $commandeligne->update_total(); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); + print ". "; + $commandeligne->update_total(); - /* On touche pas a facture mere + /* On touche pas a facture mere $commande = new Commande($db); $commande->id = $obj->rowid; if ( $commande->fetch($commande->id) >= 0 ) @@ -1884,15 +1884,15 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) print "Error #3"; } */ - $i++; - } - } else { - print $langs->trans("AlreadyDone"); - } + $i++; + } + } else { + print $langs->trans("AlreadyDone"); + } - $db->free($resql); + $db->free($resql); - /* + /* $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0"; $resql=$db->query($sql); @@ -1902,16 +1902,16 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) } */ - $db->commit(); - } else { - print "Error #1 ".$db->error(); + $db->commit(); + } else { + print "Error #1 ".$db->error(); - $db->rollback(); - } + $db->rollback(); + } - print '
'; + print '
'; - print ''; + print ''; } /** @@ -1924,51 +1924,51 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) */ function migrate_modeles($db, $langs, $conf) { - //print '
'; - //print ''.$langs->trans('UpdateModelsTable')."
\n"; + //print '
'; + //print ''.$langs->trans('UpdateModelsTable')."
\n"; - dolibarr_install_syslog("upgrade2::migrate_modeles"); + dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (!empty($conf->facture->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist = ModelePDFFactures::liste_modeles($db); - if (count($modellist) == 0) - { - // Aucun model par defaut. - $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - } - } + if (!empty($conf->facture->enabled)) + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $modellist = ModelePDFFactures::liste_modeles($db); + if (count($modellist) == 0) + { + // Aucun model par defaut. + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + } + } - if (!empty($conf->commande->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist = ModelePDFCommandes::liste_modeles($db); - if (count($modellist) == 0) - { - // Aucun model par defaut. - $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - } - } + if (!empty($conf->commande->enabled)) + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; + $modellist = ModelePDFCommandes::liste_modeles($db); + if (count($modellist) == 0) + { + // Aucun model par defaut. + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + } + } - if (!empty($conf->expedition->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist = ModelePDFExpedition::liste_modeles($db); - if (count($modellist) == 0) - { - // Aucun model par defaut. - $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; - $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - } - } + if (!empty($conf->expedition->enabled)) + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; + $modellist = ModelePDFExpedition::liste_modeles($db); + if (count($modellist) == 0) + { + // Aucun model par defaut. + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + } + } - //print $langs->trans("AlreadyDone"); + //print $langs->trans("AlreadyDone"); } @@ -1982,65 +1982,65 @@ function migrate_modeles($db, $langs, $conf) */ function migrate_commande_expedition($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_commande_expedition"); + dolibarr_install_syslog("upgrade2::migrate_commande_expedition"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationShipmentOrderMatching')."
\n"; + print '
'; + print ''.$langs->trans('MigrationShipmentOrderMatching')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande"); - $obj = $db->fetch_object($result); - if ($obj) - { - $error = 0; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "fk_commande"); + $obj = $db->fetch_object($result); + if ($obj) + { + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; - $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2 = $db->query($sql); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + if (!$resql2) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $db->commit(); - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande"; - print $langs->trans('FieldRenamed')."
\n"; - $db->query($sql); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - print ''; + if ($error == 0) + { + $db->commit(); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande"; + print $langs->trans('FieldRenamed')."
\n"; + $db->query($sql); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; } /** @@ -2053,81 +2053,81 @@ function migrate_commande_expedition($db, $langs, $conf) */ function migrate_commande_livraison($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_commande_livraison"); + dolibarr_install_syslog("upgrade2::migrate_commande_livraison"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationDeliveryOrderMatching')."
\n"; + print '
'; + print ''.$langs->trans('MigrationDeliveryOrderMatching')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande"); - $obj = $db->fetch_object($result); - if ($obj) - { - $error = 0; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_commande"); + $obj = $db->fetch_object($result); + if ($obj) + { + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT l.rowid, l.fk_commande"; - $sql .= ", c.ref_client, c.date_livraison"; - $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; - $sql .= " WHERE c.rowid = l.fk_commande"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT l.rowid, l.fk_commande"; + $sql .= ", c.ref_client, c.date_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.rowid = l.fk_commande"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; - $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2 = $db->query($sql); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); - if ($resql2) - { - $delivery_date = $db->jdate($obj->date_livraison); + if ($resql2) + { + $delivery_date = $db->jdate($obj->date_livraison); - $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu .= " ref_client='".$db->escape($obj->ref_client)."'"; - $sqlu .= ", date_livraison='".$db->idate($delivery_date)."'"; - $sqlu .= " WHERE rowid = ".$obj->rowid; - $resql3 = $db->query($sqlu); - if (!$resql3) - { - $error++; - dol_print_error($db); - } - } else { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; + $sqlu .= " ref_client='".$db->escape($obj->ref_client)."'"; + $sqlu .= ", date_livraison='".$db->idate($delivery_date)."'"; + $sqlu .= " WHERE rowid = ".$obj->rowid; + $resql3 = $db->query($sqlu); + if (!$resql3) + { + $error++; + dol_print_error($db); + } + } else { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $db->commit(); - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande"; - print $langs->trans('FieldRenamed')."
\n"; - $db->query($sql); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - print ''; + if ($error == 0) + { + $db->commit(); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_commande"; + print $langs->trans('FieldRenamed')."
\n"; + $db->query($sql); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; } /** @@ -2140,105 +2140,105 @@ function migrate_commande_livraison($db, $langs, $conf) */ function migrate_detail_livraison($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_detail_livraison"); + dolibarr_install_syslog("upgrade2::migrate_detail_livraison"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationDeliveryDetail')."
\n"; + print '
'; + print ''.$langs->trans('MigrationDeliveryDetail')."
\n"; - // This is done if field fk_commande_ligne exists. - // If not this means migration was already done. - $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne"); - $obj = $db->fetch_object($result); - if ($obj) - { - $error = 0; + // This is done if field fk_commande_ligne exists. + // If not this means migration was already done. + $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_commande_ligne"); + $obj = $db->fetch_object($result); + if ($obj) + { + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht"; - $sql .= ", ld.fk_livraison"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; - $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht"; + $sql .= ", ld.fk_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; - $sql .= " fk_product=".$obj->fk_product; - $sql .= ",description='".$db->escape($obj->description)."'"; - $sql .= ",subprice='".$db->escape($obj->subprice)."'"; - $sql .= ",total_ht='".$db->escape($obj->total_ht)."'"; - $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; - $resql2 = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; + $sql .= " fk_product=".$obj->fk_product; + $sql .= ",description='".$db->escape($obj->description)."'"; + $sql .= ",subprice='".$db->escape($obj->subprice)."'"; + $sql .= ",total_ht='".$db->escape($obj->total_ht)."'"; + $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; + $resql2 = $db->query($sql); - if ($resql2) - { - $sql = "SELECT total_ht"; - $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql .= " WHERE rowid = ".$obj->fk_livraison; - $resql3 = $db->query($sql); + if ($resql2) + { + $sql = "SELECT total_ht"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE rowid = ".$obj->fk_livraison; + $resql3 = $db->query($sql); - if ($resql3) - { - $obju = $db->fetch_object($resql3); - $total_ht = $obju->total_ht + $obj->total_ht; + if ($resql3) + { + $obju = $db->fetch_object($resql3); + $total_ht = $obju->total_ht + $obj->total_ht; - $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu .= " total_ht='".$db->escape($total_ht)."'"; - $sqlu .= " WHERE rowid=".$obj->fk_livraison; - $resql4 = $db->query($sqlu); - if (!$resql4) - { - $error++; - dol_print_error($db); - } - } else { - $error++; - dol_print_error($db); - } - } else { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; + $sqlu .= " total_ht='".$db->escape($total_ht)."'"; + $sqlu .= " WHERE rowid=".$obj->fk_livraison; + $resql4 = $db->query($sqlu); + if (!$resql4) + { + $error++; + dol_print_error($db); + } + } else { + $error++; + dol_print_error($db); + } + } else { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $db->commit(); - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer"; - print $langs->trans('FieldRenamed')."
\n"; - $db->query($sql); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line"); - $obj = $db->fetch_object($result); - if (!$obj) - { - $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison"; - $db->query($sql); - } - print $langs->trans('AlreadyDone')."
\n"; - } - print ''; + if ($error == 0) + { + $db->commit(); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet CHANGE fk_commande_ligne fk_origin_line integer"; + print $langs->trans('FieldRenamed')."
\n"; + $db->query($sql); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraisondet", "fk_origin_line"); + $obj = $db->fetch_object($result); + if (!$obj) + { + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."livraisondet ADD COLUMN fk_origin_line integer after fk_livraison"; + $db->query($sql); + } + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; } /** @@ -2251,60 +2251,60 @@ function migrate_detail_livraison($db, $langs, $conf) */ function migrate_stocks($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_stocks"); + dolibarr_install_syslog("upgrade2::migrate_stocks"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationStockDetail')."
\n"; + print '
'; + print ''.$langs->trans('MigrationStockDetail')."
\n"; - $error = 0; + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT SUM(reel) as total, fk_product"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " GROUP BY fk_product"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT SUM(reel) as total, fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " GROUP BY fk_product"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; - $sql .= " stock = '".$db->escape($obj->total)."'"; - $sql .= " WHERE rowid=".$obj->fk_product; + $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; + $sql .= " stock = '".$db->escape($obj->total)."'"; + $sql .= " WHERE rowid=".$obj->fk_product; - $resql2 = $db->query($sql); - if ($resql2) - { - } else { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + $resql2 = $db->query($sql); + if ($resql2) + { + } else { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } - print ''; + print ''; } /** @@ -2318,66 +2318,66 @@ function migrate_stocks($db, $langs, $conf) */ function migrate_menus($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_menus"); + dolibarr_install_syslog("upgrade2::migrate_menus"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationMenusDetail')."
\n"; + print '
'; + print ''.$langs->trans('MigrationMenusDetail')."
\n"; - $error = 0; + $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) - { - $db->begin(); + if ($db->DDLInfoTable(MAIN_DB_PREFIX."menu_constraint")) + { + $db->begin(); - $sql = "SELECT m.rowid, mc.action"; - $sql .= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; - $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; - $sql .= " AND m.enabled = '1'"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $sql = "SELECT m.rowid, mc.action"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; + $sql .= " AND m.enabled = '1'"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; - $sql .= " enabled = '".$db->escape($obj->action)."'"; - $sql .= " WHERE rowid=".$obj->rowid; - $sql .= " AND enabled = '1'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; + $sql .= " enabled = '".$db->escape($obj->action)."'"; + $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " AND enabled = '1'"; - $resql2 = $db->query($sql); - if ($resql2) - { - } else { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + $resql2 = $db->query($sql); + if ($resql2) + { + } else { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - print ''; + print ''; } /** @@ -2391,69 +2391,69 @@ function migrate_menus($db, $langs, $conf) */ function migrate_commande_deliveryaddress($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_commande_deliveryaddress"); + dolibarr_install_syslog("upgrade2::migrate_commande_deliveryaddress"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationDeliveryAddress')."
\n"; + print '
'; + print ''.$langs->trans('MigrationDeliveryAddress')."
\n"; - $error = 0; + $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) - { - $db->begin(); + if ($db->DDLInfoTable(MAIN_DB_PREFIX."co_exp")) + { + $db->begin(); - $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql .= ", ".MAIN_DB_PREFIX."co_exp as ce"; - $sql .= " WHERE c.rowid = ce.fk_commande"; - $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; + $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."co_exp as ce"; + $sql .= " WHERE c.rowid = ce.fk_commande"; + $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql .= " fk_adresse_livraison = '".$db->escape($obj->fk_adresse_livraison)."'"; - $sql .= " WHERE rowid=".$obj->fk_expedition; + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; + $sql .= " fk_adresse_livraison = '".$db->escape($obj->fk_adresse_livraison)."'"; + $sql .= " WHERE rowid=".$obj->fk_expedition; - $resql2 = $db->query($sql); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $resql2 = $db->query($sql); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - print ''; + print ''; } /** @@ -2467,139 +2467,139 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) */ function migrate_restore_missing_links($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_restore_missing_links"); + dolibarr_install_syslog("upgrade2::migrate_restore_missing_links"); - if (($db->type == 'mysql' || $db->type == 'mysqli')) - { - if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) - { - dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); - return 0; - } - } - print ''; + if (($db->type == 'mysql' || $db->type == 'mysqli')) + { + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) + { + dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); + return 0; + } + } + print ''; - print '
'; - print ''.$langs->trans('MigrationFixData')." (1)
\n"; + print '
'; + print ''.$langs->trans('MigrationFixData')." (1)
\n"; - $error = 0; + $error = 0; - // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1. - $table1 = 'facturedet'; $field1 = 'fk_remise_except'; - $table2 = 'societe_remise_except'; $field2 = 'fk_facture_line'; + // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1. + $table1 = 'facturedet'; $field1 = 'fk_remise_except'; + $table2 = 'societe_remise_except'; $field2 = 'fk_facture_line'; - $db->begin(); + $db->begin(); - $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql .= " WHERE t1.rowid = t2.".$field2.")"; + $sql = "SELECT t1.rowid, t1.".$field1." as field"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; - dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; - $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql .= " ".$field2." = '".$db->escape($obj->rowid)."'"; - $sql .= " WHERE rowid=".$obj->field; + print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; + $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; + $sql .= " ".$field2." = '".$db->escape($obj->rowid)."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2 = $db->query($sql); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - //print ". "; - $i++; - } - } else print $langs->trans('AlreadyDone')."
\n"; + $resql2 = $db->query($sql); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + //print ". "; + $i++; + } + } else print $langs->trans('AlreadyDone')."
\n"; - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } - print ''; + print ''; - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationFixData')." (2)
\n"; + print '
'; + print ''.$langs->trans('MigrationFixData')." (2)
\n"; - // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2. - $table2 = 'facturedet'; $field2 = 'fk_remise_except'; - $table1 = 'societe_remise_except'; $field1 = 'fk_facture_line'; + // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2. + $table2 = 'facturedet'; $field2 = 'fk_remise_except'; + $table1 = 'societe_remise_except'; $field1 = 'fk_facture_line'; - $db->begin(); + $db->begin(); - $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql .= " WHERE t1.rowid = t2.".$field2.")"; + $sql = "SELECT t1.rowid, t1.".$field1." as field"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; - dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; - $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql .= " ".$field2." = '".$db->escape($obj->rowid)."'"; - $sql .= " WHERE rowid=".$obj->field; + print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; + $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; + $sql .= " ".$field2." = '".$db->escape($obj->rowid)."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2 = $db->query($sql); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - //print ". "; - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $resql2 = $db->query($sql); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + //print ". "; + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } - print ''; + print ''; } /** @@ -2612,83 +2612,83 @@ function migrate_restore_missing_links($db, $langs, $conf) */ function migrate_project_user_resp($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_project_user_resp"); + dolibarr_install_syslog("upgrade2::migrate_project_user_resp"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationProjectUserResp')."
\n"; + print '
'; + print ''.$langs->trans('MigrationProjectUserResp')."
\n"; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp"); - $obj = $db->fetch_object($result); - if ($obj) - { - $error = 0; + $result = $db->DDLDescTable(MAIN_DB_PREFIX."projet", "fk_user_resp"); + $obj = $db->fetch_object($result); + if ($obj) + { + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT rowid, fk_user_resp FROM ".MAIN_DB_PREFIX."projet"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2 .= "datecreate"; - $sql2 .= ", statut"; - $sql2 .= ", element_id"; - $sql2 .= ", fk_c_type_contact"; - $sql2 .= ", fk_socpeople"; - $sql2 .= ") VALUES ("; - $sql2 .= "'".$db->idate(dol_now())."'"; - $sql2 .= ", '4'"; - $sql2 .= ", ".$obj->rowid; - $sql2 .= ", '160'"; - $sql2 .= ", ".$obj->fk_user_resp; - $sql2 .= ")"; + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->rowid; + $sql2 .= ", '160'"; + $sql2 .= ", ".$obj->fk_user_resp; + $sql2 .= ")"; - if ($obj->fk_user_resp > 0) - { - $resql2 = $db->query($sql2); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - } - print ". "; + if ($obj->fk_user_resp > 0) + { + $resql2 = $db->query($sql2); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + } + print ". "; - $i++; - } - } + $i++; + } + } - if ($error == 0) - { - $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp"; - if ($db->query($sqlDrop)) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - print ''; + if ($error == 0) + { + $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."projet DROP COLUMN fk_user_resp"; + if ($db->query($sqlDrop)) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; } /** @@ -2701,78 +2701,78 @@ function migrate_project_user_resp($db, $langs, $conf) */ function migrate_project_task_actors($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_project_task_actors"); + dolibarr_install_syslog("upgrade2::migrate_project_task_actors"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationProjectTaskActors')."
\n"; + print '
'; + print ''.$langs->trans('MigrationProjectTaskActors')."
\n"; - if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) - { - $error = 0; + if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors")) + { + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT fk_projet_task as fk_project_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2 .= "datecreate"; - $sql2 .= ", statut"; - $sql2 .= ", element_id"; - $sql2 .= ", fk_c_type_contact"; - $sql2 .= ", fk_socpeople"; - $sql2 .= ") VALUES ("; - $sql2 .= "'".$db->idate(dol_now())."'"; - $sql2 .= ", '4'"; - $sql2 .= ", ".$obj->fk_project_task; - $sql2 .= ", '180'"; - $sql2 .= ", ".$obj->fk_user; - $sql2 .= ")"; + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->fk_project_task; + $sql2 .= ", '180'"; + $sql2 .= ", ".$obj->fk_user; + $sql2 .= ")"; - $resql2 = $db->query($sql2); + $resql2 = $db->query($sql2); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } + if (!$resql2) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } - if ($error == 0) - { - $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors"; - if ($db->query($sqlDrop)) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - print ''; + if ($error == 0) + { + $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors"; + if ($db->query($sqlDrop)) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; } /** @@ -2790,80 +2790,80 @@ function migrate_project_task_actors($db, $langs, $conf) */ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $sourcetype, $fk_target, $targettype) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationRelationshipTables', MAIN_DB_PREFIX.$table)."
\n"; + print '
'; + print ''.$langs->trans('MigrationRelationshipTables', MAIN_DB_PREFIX.$table)."
\n"; - $error = 0; + $error = 0; - if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) - { - dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); + if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) + { + dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); - $db->begin(); + $db->begin(); - $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; - $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; + $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; - $resql = $db->query($sqlSelect); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert .= "fk_source"; - $sqlInsert .= ", sourcetype"; - $sqlInsert .= ", fk_target"; - $sqlInsert .= ", targettype"; - $sqlInsert .= ") VALUES ("; - $sqlInsert .= $obj->$fk_source; - $sqlInsert .= ", '".$db->escape($sourcetype)."'"; - $sqlInsert .= ", ".$obj->$fk_target; - $sqlInsert .= ", '".$db->escape($targettype)."'"; - $sqlInsert .= ")"; + $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->$fk_source; + $sqlInsert .= ", '".$db->escape($sourcetype)."'"; + $sqlInsert .= ", ".$obj->$fk_target; + $sqlInsert .= ", '".$db->escape($targettype)."'"; + $sqlInsert .= ")"; - $result = $db->query($sqlInsert); - if (!$result) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $result = $db->query($sqlInsert); + if (!$result) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; - if ($db->query($sqlDrop)) - { - $db->commit(); - } else { - $db->rollback(); - } - } else { - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + if ($error == 0) + { + $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table; + if ($db->query($sqlDrop)) + { + $db->commit(); + } else { + $db->rollback(); + } + } else { + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - print ''; + print ''; } /** @@ -2876,103 +2876,103 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so */ function migrate_project_task_time($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_project_task_time"); + dolibarr_install_syslog("upgrade2::migrate_project_task_time"); - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationProjectTaskTime')."
\n"; + print '
'; + print ''.$langs->trans('MigrationProjectTaskTime')."
\n"; - $error = 0; + $error = 0; - $db->begin(); + $db->begin(); - $sql = "SELECT rowid, fk_task, task_duration"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $sql = "SELECT rowid, fk_task, task_duration"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - $totaltime = array(); - $oldtime = 0; + if ($num) + { + $totaltime = array(); + $oldtime = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($obj->task_duration > 0) - { - // convert to second - // only for int time and float time ex: 1,75 for 1h45 - list($hour, $min) = explode('.', $obj->task_duration); - $hour = $hour * 60 * 60; - $min = ($min / 100) * 60 * 60; - $newtime = $hour + $min; + if ($obj->task_duration > 0) + { + // convert to second + // only for int time and float time ex: 1,75 for 1h45 + list($hour, $min) = explode('.', $obj->task_duration); + $hour = $hour * 60 * 60; + $min = ($min / 100) * 60 * 60; + $newtime = $hour + $min; - $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql2 .= " task_duration = ".$newtime; - $sql2 .= " WHERE rowid = ".$obj->rowid; + $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; + $sql2 .= " task_duration = ".$newtime; + $sql2 .= " WHERE rowid = ".$obj->rowid; - $resql2 = $db->query($sql2); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - print ". "; - $oldtime++; - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; - else $totaltime[$obj->fk_task] = $newtime; - } else { - if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; - else $totaltime[$obj->fk_task] = $obj->task_duration; - } + $resql2 = $db->query($sql2); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + print ". "; + $oldtime++; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; + else $totaltime[$obj->fk_task] = $newtime; + } else { + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; + else $totaltime[$obj->fk_task] = $obj->task_duration; + } - $i++; - } + $i++; + } - if ($error == 0) - { - if ($oldtime > 0) - { - foreach ($totaltime as $taskid => $total_duration) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql .= " duration_effective = ".$total_duration; - $sql .= " WHERE rowid = ".$taskid; + if ($error == 0) + { + if ($oldtime > 0) + { + foreach ($totaltime as $taskid => $total_duration) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; + $sql .= " duration_effective = ".$total_duration; + $sql .= " WHERE rowid = ".$taskid; - $resql = $db->query($sql); - if (!$resql) - { - $error++; - dol_print_error($db); - } - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - } else { - dol_print_error($db); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } - } else { - dol_print_error($db); - } + $resql = $db->query($sql); + if (!$resql) + { + $error++; + dol_print_error($db); + } + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + } else { + dol_print_error($db); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } + } else { + dol_print_error($db); + } - if ($error == 0) - { - $db->commit(); - } else { - $db->rollback(); - } + if ($error == 0) + { + $db->commit(); + } else { + $db->rollback(); + } - print ''; + print ''; } /** @@ -2985,85 +2985,85 @@ function migrate_project_task_time($db, $langs, $conf) */ function migrate_customerorder_shipping($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationCustomerOrderShipping')."
\n"; + print '
'; + print ''.$langs->trans('MigrationCustomerOrderShipping')."
\n"; - $error = 0; + $error = 0; - $result1 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "ref_customer"); - $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery"); - $obj1 = $db->fetch_object($result1); - $obj2 = $db->fetch_object($result2); - if (!$obj1 && !$obj2) - { - dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping"); + $result1 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "ref_customer"); + $result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition", "date_delivery"); + $obj1 = $db->fetch_object($result1); + $obj2 = $db->fetch_object($result2); + if (!$obj1 && !$obj2) + { + dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping"); - $db->begin(); + $db->begin(); - $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity"; - $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition"; + $sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity"; + $sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition"; - if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) - { - $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison"; - $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; - $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; - $sqlSelect .= " WHERE e.rowid = el.fk_target"; - $sqlSelect .= " AND el.targettype = 'shipping'"; + if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) + { + $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; + $sqlSelect .= " WHERE e.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'shipping'"; - $resql = $db->query($sqlSelect); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sqlUpdate .= " ref_customer = '".$db->escape($obj->ref_client)."'"; - $sqlUpdate .= ", date_delivery = '".$db->escape($obj->date_livraison ? $obj->date_livraison : 'null')."'"; - $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; + $sqlUpdate .= " ref_customer = '".$db->escape($obj->ref_client)."'"; + $sqlUpdate .= ", date_delivery = '".$db->escape($obj->date_livraison ? $obj->date_livraison : 'null')."'"; + $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; - $result = $db->query($sqlUpdate); - if (!$result) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $result = $db->query($sqlUpdate); + if (!$result) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + if ($error == 0) + { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - print ''; + print ''; } /** @@ -3076,95 +3076,95 @@ function migrate_customerorder_shipping($db, $langs, $conf) */ function migrate_shipping_delivery($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationShippingDelivery')."
\n"; + print '
'; + print ''.$langs->trans('MigrationShippingDelivery')."
\n"; - $error = 0; + $error = 0; - $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition"); - $obj = $db->fetch_object($result); - if ($obj) - { - dolibarr_install_syslog("upgrade2::migrate_shipping_delivery"); + $result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison", "fk_expedition"); + $obj = $db->fetch_object($result); + if ($obj) + { + dolibarr_install_syslog("upgrade2::migrate_shipping_delivery"); - $db->begin(); + $db->begin(); - $sqlSelect = "SELECT rowid, fk_expedition"; - $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison"; - $sqlSelect .= " WHERE fk_expedition is not null"; + $sqlSelect = "SELECT rowid, fk_expedition"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sqlSelect .= " WHERE fk_expedition is not null"; - $resql = $db->query($sqlSelect); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert .= "fk_source"; - $sqlInsert .= ", sourcetype"; - $sqlInsert .= ", fk_target"; - $sqlInsert .= ", targettype"; - $sqlInsert .= ") VALUES ("; - $sqlInsert .= $obj->fk_expedition; - $sqlInsert .= ", 'shipping'"; - $sqlInsert .= ", ".$obj->rowid; - $sqlInsert .= ", 'delivery'"; - $sqlInsert .= ")"; + $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->fk_expedition; + $sqlInsert .= ", 'shipping'"; + $sqlInsert .= ", ".$obj->rowid; + $sqlInsert .= ", 'delivery'"; + $sqlInsert .= ")"; - $result = $db->query($sqlInsert); - if ($result) - { - $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; - $sqlUpdate .= " WHERE rowid = ".$obj->rowid; + $result = $db->query($sqlInsert); + if ($result) + { + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result = $db->query($sqlUpdate); - if (!$result) - { - $error++; - dol_print_error($db); - } - print ". "; - } else { - $error++; - dol_print_error($db); - } - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $result = $db->query($sqlUpdate); + if (!$result) + { + $error++; + dol_print_error($db); + } + print ". "; + } else { + $error++; + dol_print_error($db); + } + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'"; - $db->query($sqlDelete); + if ($error == 0) + { + $sqlDelete = "DELETE FROM ".MAIN_DB_PREFIX."element_element WHERE sourcetype = 'commande' AND targettype = 'delivery'"; + $db->query($sqlDelete); - $db->commit(); + $db->commit(); - // DDL commands must not be inside a transaction - $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_expedition"; - $db->query($sqlDrop); - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + // DDL commands must not be inside a transaction + $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_expedition"; + $db->query($sqlDrop); + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - print ''; + print ''; } /** @@ -3178,72 +3178,72 @@ function migrate_shipping_delivery($db, $langs, $conf) */ function migrate_shipping_delivery2($db, $langs, $conf) { - print ''; + print ''; - print '
'; - print ''.$langs->trans('MigrationShippingDelivery2')."
\n"; + print '
'; + print ''.$langs->trans('MigrationShippingDelivery2')."
\n"; - $error = 0; + $error = 0; - dolibarr_install_syslog("upgrade2::migrate_shipping_delivery2"); + dolibarr_install_syslog("upgrade2::migrate_shipping_delivery2"); - $db->begin(); + $db->begin(); - $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery"; - $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison as l,"; - $sqlSelect .= " ".MAIN_DB_PREFIX."element_element as el,"; - $sqlSelect .= " ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect .= " WHERE l.rowid = el.fk_target"; - $sqlSelect .= " AND el.targettype = 'delivery'"; - $sqlSelect .= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; - $sqlSelect .= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null - // Add condition to know if we never migrate this record - $sqlSelect .= " AND (l.ref_customer IS NULL".($db->type != 'pgsql' ? " or l.ref_customer = ''" : "").")"; - $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; + $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison as l,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."element_element as el,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= " WHERE l.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'delivery'"; + $sqlSelect .= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; + $sqlSelect .= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null + // Add condition to know if we never migrate this record + $sqlSelect .= " AND (l.ref_customer IS NULL".($db->type != 'pgsql' ? " or l.ref_customer = ''" : "").")"; + $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; - $resql = $db->query($sqlSelect); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlUpdate .= " ref_customer = '".$db->escape($obj->ref_customer)."',"; - $sqlUpdate .= " date_delivery = ".($obj->date_delivery ? "'".$db->escape($obj->date_delivery)."'" : 'null'); - $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; + $sqlUpdate .= " ref_customer = '".$db->escape($obj->ref_customer)."',"; + $sqlUpdate .= " date_delivery = ".($obj->date_delivery ? "'".$db->escape($obj->date_delivery)."'" : 'null'); + $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; - $result = $db->query($sqlUpdate); - if (!$result) - { - $error++; - dol_print_error($db); - } - print ". "; - $i++; - } - } else { - print $langs->trans('AlreadyDone')."
\n"; - } + $result = $db->query($sqlUpdate); + if (!$result) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } else { + print $langs->trans('AlreadyDone')."
\n"; + } - if ($error == 0) - { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - } else { - dol_print_error($db); - $db->rollback(); - } + if ($error == 0) + { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + } else { + dol_print_error($db); + $db->rollback(); + } - print ''; + print ''; } /** @@ -3413,76 +3413,76 @@ function migrate_mode_reglement($db, $langs, $conf) */ function migrate_clean_association($db, $langs, $conf) { - $result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association"); - if ($result) // result defined for version 3.2 or - - { - $obj = $db->fetch_object($result); - if ($obj) // It table categorie_association exists - { - $couples = array(); - $filles = array(); - $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; - dolibarr_install_syslog("upgrade: search duplicate"); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - while ($obj = $db->fetch_object($resql)) - { - if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). - { - if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) - { - $filles[$obj->fk_categorie_fille] = 1; // Set record for this child - $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); - } - } - } + $result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association"); + if ($result) // result defined for version 3.2 or - + { + $obj = $db->fetch_object($result); + if ($obj) // It table categorie_association exists + { + $couples = array(); + $filles = array(); + $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; + dolibarr_install_syslog("upgrade: search duplicate"); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + while ($obj = $db->fetch_object($resql)) + { + if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). + { + if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) + { + $filles[$obj->fk_categorie_fille] = 1; // Set record for this child + $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); + } + } + } - dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); + dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); - // If there is duplicates couples or child with two parents - if (count($couples) > 0 && $num > count($couples)) - { - $error = 0; + // If there is duplicates couples or child with two parents + if (count($couples) > 0 && $num > count($couples)) + { + $error = 0; - $db->begin(); + $db->begin(); - // We delete all - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; - dolibarr_install_syslog("upgrade: delete association"); - $resqld = $db->query($sql); - if ($resqld) - { - // And we insert only each record once - foreach ($couples as $key => $val) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; - $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; - dolibarr_install_syslog("upgrade: insert association"); - $resqli = $db->query($sql); - if (!$resqli) $error++; - } - } + // We delete all + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; + dolibarr_install_syslog("upgrade: delete association"); + $resqld = $db->query($sql); + if ($resqld) + { + // And we insert only each record once + foreach ($couples as $key => $val) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; + $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; + dolibarr_install_syslog("upgrade: insert association"); + $resqli = $db->query($sql); + if (!$resqli) $error++; + } + } - if (!$error) - { - print ''.$langs->trans("MigrationCategorieAssociation").''; - print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')'; - $db->commit(); - } else { - print ''.$langs->trans("MigrationCategorieAssociation").''; - print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Failed").''; - $db->rollback(); - } - } - } else { - print ''.$langs->trans("Error").''; - print '
'.$db->lasterror().'
'; - } - } - } + if (!$error) + { + print ''.$langs->trans("MigrationCategorieAssociation").''; + print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')'; + $db->commit(); + } else { + print ''.$langs->trans("MigrationCategorieAssociation").''; + print ''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Failed").''; + $db->rollback(); + } + } + } else { + print ''.$langs->trans("Error").''; + print '
'.$db->lasterror().'
'; + } + } + } } @@ -4144,13 +4144,13 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) */ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { - dolibarr_install_syslog("upgrade2::migrate_rename_directories"); + dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) - { - dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); - @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); - } + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) + { + dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); + @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); + } } @@ -4164,78 +4164,78 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) */ function migrate_delete_old_files($db, $langs, $conf) { - $result = true; + $result = true; - dolibarr_install_syslog("upgrade2::migrate_delete_old_files"); + dolibarr_install_syslog("upgrade2::migrate_delete_old_files"); - // List of files to delete - $filetodeletearray = array( - '/core/triggers/interface_demo.class.php', - '/core/menus/barre_left/default.php', - '/core/menus/barre_top/default.php', - '/core/modules/modComptabiliteExpert.class.php', - '/core/modules/modCommercial.class.php', - '/core/modules/modProduit.class.php', - '/core/modules/modSkype.class.php', - '/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php', - '/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php', - '/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php', - '/core/triggers/interface_modCommande_Ecotax.class.php', - '/core/triggers/interface_modCommande_fraisport.class.php', - '/core/triggers/interface_modPropale_PropalWorkflow.class.php', - '/core/menus/smartphone/iphone.lib.php', - '/core/menus/smartphone/iphone_backoffice.php', - '/core/menus/smartphone/iphone_frontoffice.php', - '/core/menus/standard/auguria_backoffice.php', - '/core/menus/standard/auguria_frontoffice.php', - '/core/menus/standard/eldy_backoffice.php', - '/core/menus/standard/eldy_frontoffice.php', - '/core/modules/mailings/contacts2.modules.php', - '/core/modules/mailings/contacts3.modules.php', - '/core/modules/mailings/contacts4.modules.php', - '/core/modules/mailings/framboise.modules.php', - '/core/modules/mailings/dolibarr_services_expired.modules.php', - '/core/modules/mailings/peche.modules.php', - '/core/modules/mailings/poire.modules.php', - '/core/modules/mailings/kiwi.modules.php', - '/core/modules/facture/pdf_crabe.modules.php', - '/core/modules/facture/pdf_oursin.modules.php', + // List of files to delete + $filetodeletearray = array( + '/core/triggers/interface_demo.class.php', + '/core/menus/barre_left/default.php', + '/core/menus/barre_top/default.php', + '/core/modules/modComptabiliteExpert.class.php', + '/core/modules/modCommercial.class.php', + '/core/modules/modProduit.class.php', + '/core/modules/modSkype.class.php', + '/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php', + '/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php', + '/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php', + '/core/triggers/interface_modCommande_Ecotax.class.php', + '/core/triggers/interface_modCommande_fraisport.class.php', + '/core/triggers/interface_modPropale_PropalWorkflow.class.php', + '/core/menus/smartphone/iphone.lib.php', + '/core/menus/smartphone/iphone_backoffice.php', + '/core/menus/smartphone/iphone_frontoffice.php', + '/core/menus/standard/auguria_backoffice.php', + '/core/menus/standard/auguria_frontoffice.php', + '/core/menus/standard/eldy_backoffice.php', + '/core/menus/standard/eldy_frontoffice.php', + '/core/modules/mailings/contacts2.modules.php', + '/core/modules/mailings/contacts3.modules.php', + '/core/modules/mailings/contacts4.modules.php', + '/core/modules/mailings/framboise.modules.php', + '/core/modules/mailings/dolibarr_services_expired.modules.php', + '/core/modules/mailings/peche.modules.php', + '/core/modules/mailings/poire.modules.php', + '/core/modules/mailings/kiwi.modules.php', + '/core/modules/facture/pdf_crabe.modules.php', + '/core/modules/facture/pdf_oursin.modules.php', - '/api/class/api_generic.class.php', - '/categories/class/api_category.class.php', - '/categories/class/api_deprecated_category.class.php', - '/compta/facture/class/api_invoice.class.php', - '/commande/class/api_commande.class.php', - '/user/class/api_user.class.php', - '/product/class/api_product.class.php', - '/societe/class/api_contact.class.php', - '/societe/class/api_thirdparty.class.php', - '/support/online.php', - '/takepos/class/actions_takepos.class.php', + '/api/class/api_generic.class.php', + '/categories/class/api_category.class.php', + '/categories/class/api_deprecated_category.class.php', + '/compta/facture/class/api_invoice.class.php', + '/commande/class/api_commande.class.php', + '/user/class/api_user.class.php', + '/product/class/api_product.class.php', + '/societe/class/api_contact.class.php', + '/societe/class/api_thirdparty.class.php', + '/support/online.php', + '/takepos/class/actions_takepos.class.php', - '/install/mysql/tables/llx_c_ticketsup_category.key.sql', - '/install/mysql/tables/llx_c_ticketsup_category.sql', - '/install/mysql/tables/llx_c_ticketsup_severity.key.sql', - '/install/mysql/tables/llx_c_ticketsup_severity.sql', - '/install/mysql/tables/llx_c_ticketsup_type.key.sql', - '/install/mysql/tables/llx_c_ticketsup_type.sql' - ); + '/install/mysql/tables/llx_c_ticketsup_category.key.sql', + '/install/mysql/tables/llx_c_ticketsup_category.sql', + '/install/mysql/tables/llx_c_ticketsup_severity.key.sql', + '/install/mysql/tables/llx_c_ticketsup_severity.sql', + '/install/mysql/tables/llx_c_ticketsup_type.key.sql', + '/install/mysql/tables/llx_c_ticketsup_type.sql' + ); - foreach ($filetodeletearray as $filetodelete) { - //print ''DOL_DOCUMENT_ROOT.$filetodelete."
\n"; - $result = 1; - if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { - $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, false); - if (!$result) { - $langs->load("errors"); - print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete); - print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; - } else { - //print $langs->trans("FileWasRemoved", $filetodelete).'
'; - } - } - } - return $result; + foreach ($filetodeletearray as $filetodelete) { + //print ''DOL_DOCUMENT_ROOT.$filetodelete."
\n"; + $result = 1; + if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { + $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, false); + if (!$result) { + $langs->load("errors"); + print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete); + print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; + } else { + //print $langs->trans("FileWasRemoved", $filetodelete).'
'; + } + } + } + return $result; } /** @@ -4248,28 +4248,28 @@ function migrate_delete_old_files($db, $langs, $conf) */ function migrate_delete_old_dir($db, $langs, $conf) { - $result = true; + $result = true; - dolibarr_install_syslog("upgrade2::migrate_delete_old_dir"); + dolibarr_install_syslog("upgrade2::migrate_delete_old_dir"); - // List of files to delete - $filetodeletearray = array( - DOL_DOCUMENT_ROOT.'/core/modules/facture/terre', - DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', - ); + // List of files to delete + $filetodeletearray = array( + DOL_DOCUMENT_ROOT.'/core/modules/facture/terre', + DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', + ); - foreach ($filetodeletearray as $filetodelete) { - //print ''.$filetodelete."
\n"; - if (file_exists($filetodelete)) { - $result = dol_delete_dir_recursive($filetodelete); - } - if (!$result) { - $langs->load("errors"); - print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteDir", $filetodelete); - print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; - } - } - return $result; + foreach ($filetodeletearray as $filetodelete) { + //print ''.$filetodelete."
\n"; + if (file_exists($filetodelete)) { + $result = dol_delete_dir_recursive($filetodelete); + } + if (!$result) { + $langs->load("errors"); + print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteDir", $filetodelete); + print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; + } + } + return $result; } @@ -4530,35 +4530,35 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo */ function migrate_reload_menu($db, $langs, $conf) { - global $conf; - dolibarr_install_syslog("upgrade2::migrate_reload_menu"); + global $conf; + dolibarr_install_syslog("upgrade2::migrate_reload_menu"); - // Define list of menu handlers to initialize - $listofmenuhandler = array(); - if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' - || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') - { - $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers - } + // Define list of menu handlers to initialize + $listofmenuhandler = array(); + if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' + || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') + { + $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers + } - foreach ($listofmenuhandler as $key => $val) - { - print ''; + foreach ($listofmenuhandler as $key => $val) + { + print ''; - //print "x".$key; - print '
'; - print ''.$langs->trans('Upgrade').': '.$langs->trans('MenuHandler')." ".$key."
\n"; + //print "x".$key; + print '
'; + print ''.$langs->trans('Upgrade').': '.$langs->trans('MenuHandler')." ".$key."
\n"; - // Load sql ini_menu_handler.sql file - $dir = DOL_DOCUMENT_ROOT."/core/menus/"; - $file = 'init_menu_'.$key.'.sql'; - if (file_exists($dir.$file)) - { - $result = run_sql($dir.$file, 1, '', 1, $key); - } + // Load sql ini_menu_handler.sql file + $dir = DOL_DOCUMENT_ROOT."/core/menus/"; + $file = 'init_menu_'.$key.'.sql'; + if (file_exists($dir.$file)) + { + $result = run_sql($dir.$file, 1, '', 1, $key); + } - print ''; - } + print ''; + } } /** @@ -4608,44 +4608,44 @@ function migrate_user_photospath() if (dol_is_dir($origin)) { $handle = opendir($origin_osencoded); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if ($file == '.' || $file == '..') continue; + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if ($file == '.' || $file == '..') continue; - if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs') - { - $thumbs = opendir($origin_osencoded.'/'.$file); - if (is_resource($thumbs)) - { - dol_mkdir($destin.'/'.$file); - while (($thumb = readdir($thumbs)) !== false) - { - if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) - { - if ($thumb == '.' || $thumb == '..') continue; + if (dol_is_dir($origin.'/'.$file)) // it is a dir (like 'thumbs') + { + $thumbs = opendir($origin_osencoded.'/'.$file); + if (is_resource($thumbs)) + { + dol_mkdir($destin.'/'.$file); + while (($thumb = readdir($thumbs)) !== false) + { + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) + { + if ($thumb == '.' || $thumb == '..') continue; - //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n"; - print '.'; - dol_copy($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0); - //var_dump('aaa');exit; - } - } + //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n"; + print '.'; + dol_copy($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0); + //var_dump('aaa');exit; + } + } // dol_delete_dir($origin.'/'.$file); - } - } else // it is a file - { - if (!dol_is_file($destin.'/'.$file)) - { - //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; - print '.'; - dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); - //var_dump('eee');exit; - } - } - } - } + } + } else // it is a file + { + if (!dol_is_file($destin.'/'.$file)) + { + //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; + print '.'; + dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0); + //var_dump('eee');exit; + } + } + } + } } } } @@ -4673,87 +4673,87 @@ and rowid in (...) */ function migrate_users_socialnetworks() { - global $db, $langs; - // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - $error = 0; - $db->begin(); - print ''; - $sql = 'SELECT rowid, socialnetworks'; - $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE'; - $sql .= " skype IS NOT NULL OR skype <> ''"; - $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; - $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; - $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; - $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; - $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; - $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; - $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; - $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; - //print $sql; - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $arraysocialnetworks = array(); - if (!empty($obj->skype)) { - $arraysocialnetworks['skype'] = $obj->skype; - } - if (!empty($obj->twitter)) { - $arraysocialnetworks['twitter'] = $obj->twitter; - } - if (!empty($obj->facebook)) { - $arraysocialnetworks['facebook'] = $obj->facebook; - } - if (!empty($obj->linkedin)) { - $arraysocialnetworks['linkedin'] = $obj->linkedin; - } - if (!empty($obj->instagram)) { - $arraysocialnetworks['instagram'] = $obj->instagram; - } - if (!empty($obj->snapchat)) { - $arraysocialnetworks['snapchat'] = $obj->snapchat; - } - if (!empty($obj->googleplus)) { - $arraysocialnetworks['googleplus'] = $obj->googleplus; - } - if (!empty($obj->youtube)) { - $arraysocialnetworks['youtube'] = $obj->youtube; - } - if (!empty($obj->whatsapp)) { - $arraysocialnetworks['whatsapp'] = $obj->whatsapp; - } - if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { - $obj->socialnetworks = '[]'; - } - $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."user SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd .= ', skype=null'; - $sqlupd .= ', twitter=null'; - $sqlupd .= ', facebook=null'; - $sqlupd .= ', linkedin=null'; - $sqlupd .= ', instagram=null'; - $sqlupd .= ', snapchat=null'; - $sqlupd .= ', googleplus=null'; - $sqlupd .= ', youtube=null'; - $sqlupd .= ', whatsapp=null'; - $sqlupd .= ' WHERE rowid='.$obj->rowid; - //print $sqlupd."
"; - $resqlupd = $db->query($sqlupd); - if (!$resqlupd) { - dol_print_error($db); - $error++; - } - } - } else { - $error++; - } - if (!$error) { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Users')."
\n"; - print ''; + global $db, $langs; + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE'; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; + //print $sql; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."user SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (!$resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (!$error) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Users')."
\n"; + print ''; } /** @@ -4763,88 +4763,88 @@ function migrate_users_socialnetworks() */ function migrate_members_socialnetworks() { - global $db, $langs; + global $db, $langs; - print ''; - $error = 0; - $db->begin(); - print ''; - $sql = 'SELECT rowid, socialnetworks'; - $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE '; - $sql .= " skype IS NOT NULL OR skype <> ''"; - $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; - $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; - $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; - $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; - $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; - $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; - $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; - $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; - //print $sql; - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $arraysocialnetworks = array(); - if (!empty($obj->skype)) { - $arraysocialnetworks['skype'] = $obj->skype; - } - if (!empty($obj->twitter)) { - $arraysocialnetworks['twitter'] = $obj->twitter; - } - if (!empty($obj->facebook)) { - $arraysocialnetworks['facebook'] = $obj->facebook; - } - if (!empty($obj->linkedin)) { - $arraysocialnetworks['linkedin'] = $obj->linkedin; - } - if (!empty($obj->instagram)) { - $arraysocialnetworks['instagram'] = $obj->instagram; - } - if (!empty($obj->snapchat)) { - $arraysocialnetworks['snapchat'] = $obj->snapchat; - } - if (!empty($obj->googleplus)) { - $arraysocialnetworks['googleplus'] = $obj->googleplus; - } - if (!empty($obj->youtube)) { - $arraysocialnetworks['youtube'] = $obj->youtube; - } - if (!empty($obj->whatsapp)) { - $arraysocialnetworks['whatsapp'] = $obj->whatsapp; - } - if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { - $obj->socialnetworks = '[]'; - } - $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."adherent SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd .= ', skype=null'; - $sqlupd .= ', twitter=null'; - $sqlupd .= ', facebook=null'; - $sqlupd .= ', linkedin=null'; - $sqlupd .= ', instagram=null'; - $sqlupd .= ', snapchat=null'; - $sqlupd .= ', googleplus=null'; - $sqlupd .= ', youtube=null'; - $sqlupd .= ', whatsapp=null'; - $sqlupd .= ' WHERE rowid='.$obj->rowid; - //print $sqlupd."
"; - $resqlupd = $db->query($sqlupd); - if (!$resqlupd) { - dol_print_error($db); - $error++; - } - } - } else { - $error++; - } - if (!$error) { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Members')."
\n"; - print ''; + print ''; + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE '; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; + //print $sql; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."adherent SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (!$resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (!$error) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Members')."
\n"; + print ''; } /** @@ -4854,92 +4854,92 @@ function migrate_members_socialnetworks() */ function migrate_contacts_socialnetworks() { - global $db, $langs; - // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - $error = 0; - $db->begin(); - print ''; - $sql = 'SELECT rowid, socialnetworks'; - $sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'socpeople WHERE '; - $sql .= " jabberid IS NOT NULL OR jabberid <> ''"; - $sql .= " OR skype IS NOT NULL OR skype <> ''"; - $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; - $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; - $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; - $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; - $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; - $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; - $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; - $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; - //print $sql; - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $arraysocialnetworks = array(); - if (!empty($obj->jabberid)) { - $arraysocialnetworks['jabber'] = $obj->jabberid; - } - if (!empty($obj->skype)) { - $arraysocialnetworks['skype'] = $obj->skype; - } - if (!empty($obj->twitter)) { - $arraysocialnetworks['twitter'] = $obj->twitter; - } - if (!empty($obj->facebook)) { - $arraysocialnetworks['facebook'] = $obj->facebook; - } - if (!empty($obj->linkedin)) { - $arraysocialnetworks['linkedin'] = $obj->linkedin; - } - if (!empty($obj->instagram)) { - $arraysocialnetworks['instagram'] = $obj->instagram; - } - if (!empty($obj->snapchat)) { - $arraysocialnetworks['snapchat'] = $obj->snapchat; - } - if (!empty($obj->googleplus)) { - $arraysocialnetworks['googleplus'] = $obj->googleplus; - } - if (!empty($obj->youtube)) { - $arraysocialnetworks['youtube'] = $obj->youtube; - } - if (!empty($obj->whatsapp)) { - $arraysocialnetworks['whatsapp'] = $obj->whatsapp; - } - if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { - $obj->socialnetworks = '[]'; - } - $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."socpeople SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd .= ', jabberid=null'; - $sqlupd .= ', skype=null'; - $sqlupd .= ', twitter=null'; - $sqlupd .= ', facebook=null'; - $sqlupd .= ', linkedin=null'; - $sqlupd .= ', instagram=null'; - $sqlupd .= ', snapchat=null'; - $sqlupd .= ', googleplus=null'; - $sqlupd .= ', youtube=null'; - $sqlupd .= ', whatsapp=null'; - $sqlupd .= ' WHERE rowid='.$obj->rowid; - //print $sqlupd."
"; - $resqlupd = $db->query($sqlupd); - if (!$resqlupd) { - dol_print_error($db); - $error++; - } - } - } else { - $error++; - } - if (!$error) { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Contacts')."
\n"; - print ''; + global $db, $langs; + // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'socpeople WHERE '; + $sql .= " jabberid IS NOT NULL OR jabberid <> ''"; + $sql .= " OR skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; + //print $sql; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->jabberid)) { + $arraysocialnetworks['jabber'] = $obj->jabberid; + } + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."socpeople SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; + $sqlupd .= ', jabberid=null'; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (!$resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (!$error) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Contacts')."
\n"; + print ''; } /** @@ -4949,85 +4949,85 @@ function migrate_contacts_socialnetworks() */ function migrate_thirdparties_socialnetworks() { - global $db, $langs; - // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - $error = 0; - $db->begin(); - print ''; - $sql = 'SELECT rowid, socialnetworks'; - $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe WHERE '; - $sql .= " skype IS NOT NULL OR skype <> ''"; - $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; - $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; - $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; - $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; - $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; - $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; - $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; - $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; - //print $sql; - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $arraysocialnetworks = array(); - if (!empty($obj->skype)) { - $arraysocialnetworks['skype'] = $obj->skype; - } - if (!empty($obj->twitter)) { - $arraysocialnetworks['twitter'] = $obj->twitter; - } - if (!empty($obj->facebook)) { - $arraysocialnetworks['facebook'] = $obj->facebook; - } - if (!empty($obj->linkedin)) { - $arraysocialnetworks['linkedin'] = $obj->linkedin; - } - if (!empty($obj->instagram)) { - $arraysocialnetworks['instagram'] = $obj->instagram; - } - if (!empty($obj->snapchat)) { - $arraysocialnetworks['snapchat'] = $obj->snapchat; - } - if (!empty($obj->googleplus)) { - $arraysocialnetworks['googleplus'] = $obj->googleplus; - } - if (!empty($obj->youtube)) { - $arraysocialnetworks['youtube'] = $obj->youtube; - } - if (!empty($obj->whatsapp)) { - $arraysocialnetworks['whatsapp'] = $obj->whatsapp; - } - if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { - $obj->socialnetworks = '[]'; - } - $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."societe SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; - $sqlupd .= ', skype=null'; - $sqlupd .= ', twitter=null'; - $sqlupd .= ', facebook=null'; - $sqlupd .= ', linkedin=null'; - $sqlupd .= ', instagram=null'; - $sqlupd .= ', snapchat=null'; - $sqlupd .= ', googleplus=null'; - $sqlupd .= ', youtube=null'; - $sqlupd .= ', whatsapp=null'; - $sqlupd .= ' WHERE rowid='.$obj->rowid; - //print $sqlupd."
"; - $resqlupd = $db->query($sqlupd); - if (!$resqlupd) { - dol_print_error($db); - $error++; - } - } - } else { - $error++; - } - if (!$error) { - $db->commit(); - } else { - dol_print_error($db); - $db->rollback(); - } - print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Thirdparties')."
\n"; - print ''; + global $db, $langs; + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe WHERE '; + $sql .= " skype IS NOT NULL OR skype <> ''"; + $sql .= " OR twitter IS NOT NULL OR twitter <> ''"; + $sql .= " OR facebook IS NOT NULL OR facebook <> ''"; + $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''"; + $sql .= " OR instagram IS NOT NULL OR instagram <> ''"; + $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''"; + $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''"; + $sql .= " OR youtube IS NOT NULL OR youtube <> ''"; + $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''"; + //print $sql; + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."societe SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; + $sqlupd .= ', skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', instagram=null'; + $sqlupd .= ', snapchat=null'; + $sqlupd .= ', googleplus=null'; + $sqlupd .= ', youtube=null'; + $sqlupd .= ', whatsapp=null'; + $sqlupd .= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (!$resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (!$error) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } + print ''.$langs->trans('MigrationFieldsSocialNetworks', 'Thirdparties')."
\n"; + print ''; } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 12eeb364cde..99a117562a1 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -52,8 +52,8 @@ if (!empty($conf->fournisseur->enabled)) { } if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } $langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'sendings')); @@ -122,7 +122,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { $action = ''; $object->fetch($id); // show reception also after canceling modification @@ -133,8 +133,8 @@ if (empty($reshook)) // Reopen if ($action == 'reopen' && $user->rights->reception->creer) { - $object->fetch($id); - $result = $object->reOpen(); + $object->fetch($id); + $result = $object->reOpen(); } // Confirm back to draft status @@ -164,24 +164,24 @@ if (empty($reshook)) // Set incoterm if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); + $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } if ($action == 'setref_supplier') { - $result = $object->fetch($id); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $result = $object->fetch($id); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } - $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'RECEPTION_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'editref_supplier'; - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'RECEPTION_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editref_supplier'; + } else { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } } if ($action == 'update_extras') @@ -338,76 +338,76 @@ if (empty($reshook)) } - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; - if (!$error) - { - $ret = $object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + if (!$error) + { + $ret = $object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. - if ($ret <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - } else { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("QtyToReceive").'/'.$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $error++; - } + if ($ret <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("QtyToReceive").'/'.$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); + $error++; + } - if (!$error) - { - $db->commit(); - header("Location: card.php?id=".$object->id); - exit; - } else { - $db->rollback(); - $_GET["commande_id"] = GETPOST('commande_id', 'int'); - $action = 'create'; - } + if (!$error) + { + $db->commit(); + header("Location: card.php?id=".$object->id); + exit; + } else { + $db->rollback(); + $_GET["commande_id"] = GETPOST('commande_id', 'int'); + $action = 'create'; + } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) ) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); - $result = $object->valid($user); + $result = $object->valid($user); - if ($result < 0) - { + if ($result < 0) + { $langs->load("errors"); - setEventMessages($langs->trans($object->error), null, 'errors'); - } else { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records + setEventMessages($langs->trans($object->error), null, 'errors'); + } else { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); - } - } + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db, $result); + } + } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->reception->supprimer) { - $result = $object->delete($user); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT.'/reception/index.php'); - exit; - } else { + $result = $object->delete($user); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT.'/reception/index.php'); + exit; + } else { setEventMessages($object->error, $object->errors, 'errors'); - } + } } // TODO add alternative status /*elseif ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) @@ -440,33 +440,33 @@ if (empty($reshook)) || $action == 'settrueDepth' || $action == 'setshipping_method_id') { - $error = 0; + $error = 0; - if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); - if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); - if ($action == 'settrueWeight') { - $object->trueWeight = trim(GETPOST('trueWeight', 'int')); + if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); + if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); + if ($action == 'settrueWeight') { + $object->trueWeight = trim(GETPOST('trueWeight', 'int')); $object->weight_units = GETPOST('weight_units', 'int'); - } - if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); - if ($action == 'settrueHeight') { - $object->trueHeight = trim(GETPOST('trueHeight', 'int')); + } + if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); + if ($action == 'settrueHeight') { + $object->trueHeight = trim(GETPOST('trueHeight', 'int')); $object->size_units = GETPOST('size_units', 'int'); } - if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); - if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); + if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); + if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); - if (!$error) - { - if ($object->update($user) >= 0) - { - header("Location: card.php?id=".$object->id); - exit; - } - setEventMessages($object->error, $object->errors, 'errors'); - } + if (!$error) + { + if ($object->update($user) >= 0) + { + header("Location: card.php?id=".$object->id); + exit; + } + setEventMessages($object->error, $object->errors, 'errors'); + } - $action = ""; + $action = ""; } // Build document @@ -475,22 +475,22 @@ if (empty($reshook)) // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $reception->thirdparty->default_lang; - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $reception->thirdparty->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { + if ($result <= 0) + { setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + $action = ''; + } } // Delete file in doc form @@ -505,20 +505,20 @@ if (empty($reshook)) else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } elseif ($action == 'classifybilled') { - $object->fetch($id); - $result = $object->set_billed(); - if ($result >= 0) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit(); - } + $object->fetch($id); + $result = $object->set_billed(); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit(); + } } elseif ($action == 'classifyclosed') { - $object->fetch($id); - $result = $object->setClosed(); - if ($result >= 0) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit(); - } + $object->fetch($id); + $result = $object->setClosed(); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit(); + } } /* @@ -683,165 +683,165 @@ $warehousestatic = new Entrepot($db); if ($action == 'create2') { - print load_fiche_titre($langs->trans("CreateReception"), '', 'dollyrevert'); + print load_fiche_titre($langs->trans("CreateReception"), '', 'dollyrevert'); - print '
'.$langs->trans("ReceptionCreationIsDoneFromOrder"); - $action = ''; $id = ''; $ref = ''; + print '
'.$langs->trans("ReceptionCreationIsDoneFromOrder"); + $action = ''; $id = ''; $ref = ''; } // Mode creation. if ($action == 'create') { - $recept = new Reception($db); + $recept = new Reception($db); - print load_fiche_titre($langs->trans("CreateReception")); - if (!$origin) - { - setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); - } + print load_fiche_titre($langs->trans("CreateReception")); + if (!$origin) + { + setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); + } - if ($origin) - { + if ($origin) + { if ($origin == 'supplierorder')$classname = 'CommandeFournisseur'; - else $classname = ucfirst($origin); + else $classname = ucfirst($origin); - $object = new $classname($db); - if ($object->fetch($origin_id)) // This include the fetch_lines - { - $soc = new Societe($db); - $soc->fetch($object->socid); + $object = new $classname($db); + if ($object->fetch($origin_id)) // This include the fetch_lines + { + $soc = new Societe($db); + $soc->fetch($object->socid); - $author = new User($db); - $author->fetch($object->user_author_id); + $author = new User($db); + $author->fetch($object->user_author_id); - if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); + if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (GETPOST('entrepot_id', 'int')) - { - print ''; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (GETPOST('entrepot_id', 'int')) + { + print ''; + } - print dol_get_fiche_head(''); + print dol_get_fiche_head(''); - print ''; + print '
'; - // Ref - print ''; - print "\n"; + // Ref + print ''; + print "\n"; - // Ref client - print ''; - print ''; + // Ref client + print ''; + print ''; - // Tiers - print ''; - print ''; - print ''; + // Tiers + print ''; + print ''; + print ''; - // Project - if (!empty($conf->projet->enabled)) - { - $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; - if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; - if ($origin == 'project') $projectid = ($originid ? $originid : 0); + // Project + if (!empty($conf->projet->enabled)) + { + $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; + if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); - $langs->load("projects"); - print ''; - print ''; - print ''; - } + $langs->load("projects"); + print ''; + print ''; + print ''; + } - // Date delivery planned - print ''; - print '\n"; - print ''; + // Date delivery planned + print ''; + print '\n"; + print ''; - // Note Public - print ''; - print '"; + // Note Public + print ''; + print '"; - // Note Private - if ($object->note_private && !$user->socid) - { - print ''; - print '"; - } + // Note Private + if ($object->note_private && !$user->socid) + { + print ''; + print '"; + } - // Weight - print ''; - // Dim - print ''; + // Weight + print ''; + // Dim + print ''; - // Delivery method - print ""; - print '\n"; + // Delivery method + print ""; + print '\n"; - // Tracking number - print ""; - print '\n"; + // Tracking number + print ""; + print '\n"; - // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Here $object can be of an object Order - $extrafields->fetch_name_optionals_label($object->table_element); - if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { + // Here $object can be of an object Order + $extrafields->fetch_name_optionals_label($object->table_element); + if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); @@ -917,51 +917,51 @@ if ($action == 'create') } - print ''; - print '
'; + print '
'; - print '
'; - if ($origin == 'supplierorder' && !empty($conf->fournisseur->enabled)) - { - print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; - } - if ($origin == 'propal' && !empty($conf->propal->enabled)) - { - print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; - } - print '
'; + if ($origin == 'supplierorder' && !empty($conf->fournisseur->enabled)) + { + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; + } + if ($origin == 'propal' && !empty($conf->propal->enabled)) + { + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; + } + print '
'; - if ($origin == 'supplier_order') print $langs->trans('SupplierOrder'); - else print $langs->trans('RefSupplier'); - print ''; - print ''; - print '
'; + if ($origin == 'supplier_order') print $langs->trans('SupplierOrder'); + else print $langs->trans('RefSupplier'); + print ''; + print ''; + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans("Project").''; - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">'.$langs->trans("AddProject").''; - print '
'.$langs->trans("Project").''; + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print '   id).'">'.$langs->trans("AddProject").''; + print '
'.$langs->trans("DateDeliveryPlanned").''; - //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. - $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST - print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); - print "
'.$langs->trans("DateDeliveryPlanned").''; + //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. + $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); + print "
'.$langs->trans("NotePublic").''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print "
'.$langs->trans("NotePublic").''; + $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print "
'.$langs->trans("NotePrivate").''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print "
'.$langs->trans("NotePrivate").''; + $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print "
'; - print $langs->trans("Weight"); - print ' '; - $text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); - $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); - print $form->textwithpicto($text, $htmltext); - print '
'; - print $langs->trans("Width").' x '.$langs->trans("Height").' x '.$langs->trans("Depth"); - print ' '; - print ' x '; - print ' x '; - print ' '; - $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); - $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); - print $form->textwithpicto($text, $htmltext); - print '
'; + print $langs->trans("Weight"); + print ' '; + $text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); + print $form->textwithpicto($text, $htmltext); + print '
'; + print $langs->trans("Width").' x '.$langs->trans("Height").' x '.$langs->trans("Depth"); + print ' '; + print ' x '; + print ' x '; + print ' '; + $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); + print $form->textwithpicto($text, $htmltext); + print '
".$langs->trans("ReceptionMethod")."'; - $recept->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id", $recept->meths, GETPOST('shipping_method_id', 'int'), 1, 0, 0, "", 1); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print "
".$langs->trans("ReceptionMethod")."'; + $recept->fetch_delivery_methods(); + print $form->selectarray("shipping_method_id", $recept->meths, GETPOST('shipping_method_id', 'int'), 1, 0, 0, "", 1); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print "
".$langs->trans("TrackingNumber")."'; - print ''; - print "
".$langs->trans("TrackingNumber")."'; + print ''; + print "
'; + print '
'; - // Load receptions already done for same order - $object->loadReceptions(); + // Load receptions already done for same order + $object->loadReceptions(); - if ($numAsked) - { - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - if (!empty($conf->stock->enabled)) - { + print ''; + if (!empty($conf->stock->enabled)) + { print ''; - } + } if (!empty($conf->productbatch->enabled)) { print ''; @@ -972,13 +972,13 @@ if ($action == 'create') print ''; } } - print "\n"; - } + print "\n"; + } - $indiceAsked = 1; - while ($indiceAsked <= $numAsked) - { - $product = new Product($db); + $indiceAsked = 1; + while ($indiceAsked <= $numAsked) + { + $product = new Product($db); foreach ($object->lines as $supplierLine) { if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { $line = $supplierLine; @@ -987,81 +987,81 @@ if ($action == 'create') } - // Show product and description - $type = $line->product_type ? $line->product_type : $line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($line->date_start)) $type = 1; - if (!empty($line->date_end)) $type = 1; + // Show product and description + $type = $line->product_type ? $line->product_type : $line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($line->date_start)) $type = 1; + if (!empty($line->date_end)) $type = 1; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; - // Product label - if ($line->fk_product > 0) // If predefined product - { - $product->fetch($line->fk_product); - $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch - //var_dump($product->stock_warehouse[1]); + // Product label + if ($line->fk_product > 0) // If predefined product + { + $product->fetch($line->fk_product); + $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch + //var_dump($product->stock_warehouse[1]); - print ''; - } else { - print "'; + } else { + print "\n"; - } + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + print "\n"; + } - // Qty - print ''; - $qtyProdCom = $line->qty; + print ''; + print ''; + $qtyProdCom = $line->qty; - // Qty already received - print ''; + $quantityDelivered = $object->receptions[$line->id]; + print $quantityDelivered; + print ''; + print ''; if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) @@ -1070,13 +1070,13 @@ if ($action == 'create') } else { $quantityToBeDelivered = $dispatchLines[$indiceAsked]['qty']; } - $warehouse_id = $dispatchLines[$indiceAsked]['ent']; + $warehouse_id = $dispatchLines[$indiceAsked]['ent']; $warehouseObject = null; if (!empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection { - print ''; + print ''; $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number $deliverableQty = $dispatchLines[$indiceAsked]['qty']; @@ -1085,8 +1085,8 @@ if ($action == 'create') print ''; @@ -1155,26 +1155,26 @@ if ($action == 'create') print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), $indiceAsked); } - $indiceAsked++; - } + $indiceAsked++; + } - print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").''.$langs->trans("QtyToReceive"); + if ($numAsked) + { + print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").''.$langs->trans("QtyToReceive"); if (empty($conf->productbatch->enabled)) { - print '
('.$langs->trans("Fill").''; - print ' / '.$langs->trans("Reset").')'; + print '
('.$langs->trans("Fill").''; + print ' / '.$langs->trans("Reset").')'; } - print '
'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')'.$langs->trans("batch_number").''.$langs->trans("SellByDate").'
'; - print ''; // ancre pour retourner sur la ligne + print ''; + print ''; // ancre pour retourner sur la ligne - // Show product and description - $product_static->type = $line->fk_product_type; - $product_static->id = $line->fk_product; - $product_static->ref = $line->ref; - $product_static->status_batch = $line->product_tobatch; + // Show product and description + $product_static->type = $line->fk_product_type; + $product_static->id = $line->fk_product; + $product_static->ref = $line->ref; + $product_static->status_batch = $line->product_tobatch; - $text = $product_static->getNomUrl(1); - $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); - $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); + $text = $product_static->getNomUrl(1); + $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); + $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); - // Add description in form - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; - } + // Add description in form + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; + } - print '
"; - if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); + print '"; + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); - if (!empty($line->label)) { - $text .= ' '.$line->label.''; - print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); - } else { - print $text.' '.nl2br($line->desc); - } + if (!empty($line->label)) { + $text .= ' '.$line->label.''; + print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); + } else { + print $text.' '.nl2br($line->desc); + } - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); - print "'.$line->qty; + // Qty + print ''.$line->qty; print 'id.'\' />'; print ''; - print ''; - print ''; + // Qty already received + print ''; - $quantityDelivered = $object->receptions[$line->id]; - print $quantityDelivered; - print ''; - print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty = GETPOST('qtyl'.$indiceAsked, 'int'); - print ''; + if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty = GETPOST('qtyl'.$indiceAsked, 'int'); + print ''; print ''; } else print $langs->trans("NA"); print '
"; + print ""; - print '
'; + print '
'; - print '
'; - print ''; - print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage - print '
'; + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; - print ''; + print ''; - print '
'; - } else { - dol_print_error($db); - } - } + print '
'; + } else { + dol_print_error($db); + } + } } elseif ($id || $ref) /* *************************************************************************** */ /* */ @@ -1245,9 +1245,9 @@ if ($action == 'create') if (!$formconfirm) { $parameters = array('formConfirm' => $formconfirm); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -1263,18 +1263,18 @@ if ($action == 'create') if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->$typeobject->id); + $objectsrc = new Commande($db); + $objectsrc->fetch($object->$typeobject->id); } if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) { - $objectsrc = new Propal($db); - $objectsrc->fetch($object->$typeobject->id); + $objectsrc = new Propal($db); + $objectsrc->fetch($object->$typeobject->id); } if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && !empty($conf->fournisseur->enabled)) { - $objectsrc = new CommandeFournisseur($db); - $objectsrc->fetch($object->$typeobject->id); + $objectsrc = new CommandeFournisseur($db); + $objectsrc->fetch($object->$typeobject->id); } // Reception card $linkback = ''.$langs->trans("BackToList").''; @@ -1285,53 +1285,53 @@ if ($action == 'create') $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if (0) { // Do not change on reception - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - // We don't have project on reception, so we will use the project or source object instead - // TODO Add project on reception - $morehtmlref .= ' : '; - if (!empty($objectsrc->fk_project)) { - $proj = new Project($db); - $proj->fetch($objectsrc->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if (0) { // Do not change on reception + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + // We don't have project on reception, so we will use the project or source object instead + // TODO Add project on reception + $morehtmlref .= ' : '; + if (!empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref .= '
'; $object->picto = 'sending'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; // Linked documents if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) @@ -1411,7 +1411,7 @@ if ($action == 'create') print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; } - // Calculated + // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; @@ -1461,15 +1461,15 @@ if ($action == 'create') $volumeUnit = 0; if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $volumeUnit = $object->size_units * 3; + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $volumeUnit = $object->size_units * 3; } // If reception volume not defined we use sum of products if ($calculatedVolume > 0) { if ($volumeUnit < 50) { - print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) @@ -1536,21 +1536,21 @@ if ($action == 'create') if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; + print ''; } print "
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->reception->creer) print ''.img_edit().''; - else print ' '; - print '
'; - print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->reception->creer) print ''.img_edit().''; + else print ' '; + print '
'; + print '
'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } - print '
"; @@ -1662,50 +1662,50 @@ if ($action == 'create') if ($origin && $origin_id > 0) { - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; - $sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot"; - $sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; - $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; - $sql .= ', p.description as product_desc'; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql .= ", ".MAIN_DB_PREFIX."reception as e"; - $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql .= " WHERE e.entity IN (".getEntity('reception').")"; - $sql .= " AND obj.fk_commande = ".$origin_id; - $sql .= " AND obj.rowid = ed.fk_commandefourndet"; - $sql .= " AND ed.fk_reception = e.rowid"; - $sql .= " AND ed.fk_reception !=".$object->id; - //if ($filter) $sql.= $filter; - $sql .= " ORDER BY obj.fk_product"; + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; + $sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot"; + $sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception"; + //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; + $sql .= ', p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= ", ".MAIN_DB_PREFIX."reception as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " WHERE e.entity IN (".getEntity('reception').")"; + $sql .= " AND obj.fk_commande = ".$origin_id; + $sql .= " AND obj.rowid = ed.fk_commandefourndet"; + $sql .= " AND ed.fk_reception = e.rowid"; + $sql .= " AND ed.fk_reception !=".$object->id; + //if ($filter) $sql.= $filter; + $sql .= " ORDER BY obj.fk_product"; - dol_syslog("get list of reception lines", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + dol_syslog("get list of reception lines", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - // $obj->rowid is rowid in $origin."det" table - $alreadysent[$obj->rowid][$obj->receptionline_id] = array('reception_ref'=>$obj->reception_ref, 'reception_id'=>$obj->reception_id, 'warehouse'=>$obj->fk_entrepot, 'qty'=>$obj->qty, 'date_valid'=>$obj->date_valid, 'date_delivery'=>$obj->date_delivery); - } - $i++; - } - } - //var_dump($alreadysent); + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + // $obj->rowid is rowid in $origin."det" table + $alreadysent[$obj->rowid][$obj->receptionline_id] = array('reception_ref'=>$obj->reception_ref, 'reception_id'=>$obj->reception_id, 'warehouse'=>$obj->fk_entrepot, 'qty'=>$obj->qty, 'date_valid'=>$obj->date_valid, 'date_delivery'=>$obj->date_delivery); + } + $i++; + } + } + //var_dump($alreadysent); } // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - print ''; // id of order line + print ''; // id of order line print ''; // # @@ -1765,35 +1765,35 @@ if ($action == 'create') print ''.$lines[$i]->qty_asked.''; // Qty in other receptions (with reception and warehouse used) - if ($origin && $origin_id > 0) - { - print ''; - foreach ($alreadysent as $key => $val) - { - if ($lines[$i]->fk_commandefourndet == $key) - { - $j = 0; - foreach ($val as $receptionline_id=> $receptionline_var) - { - if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) continue; // We want to show only "other receptions" + if ($origin && $origin_id > 0) + { + print ''; + foreach ($alreadysent as $key => $val) + { + if ($lines[$i]->fk_commandefourndet == $key) + { + $j = 0; + foreach ($val as $receptionline_id=> $receptionline_var) + { + if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) continue; // We want to show only "other receptions" - $j++; - if ($j > 1) print '
'; - $reception_static->fetch($receptionline_var['reception_id']); - print $reception_static->getNomUrl(1); - print ' - '.$receptionline_var['qty']; + $j++; + if ($j > 1) print '
'; + $reception_static->fetch($receptionline_var['reception_id']); + print $reception_static->getNomUrl(1); + print ' - '.$receptionline_var['qty']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) - { - $warehousestatic->fetch($receptionline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); - } - } - } - } + $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); + if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) + { + $warehousestatic->fetch($receptionline_var['warehouse']); + $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); + } + } + } + } print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) @@ -1970,7 +1970,7 @@ if ($action == 'create') if ($object->statut == Reception::STATUS_DRAFT && $num_prod > 0) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) { print ''.$langs->trans("Validate").''; } else { @@ -1990,7 +1990,7 @@ if ($action == 'create') { print ''.$langs->trans("ClassifyUnbilled").''; } else { - print ''.$langs->trans("ReOpen").''; + print ''.$langs->trans("ReOpen").''; } } @@ -2026,8 +2026,8 @@ if ($action == 'create') // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on receptions instead of orders if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? { - $label = "ClassifyBilled"; - $paramaction = 'classifybilled'; + $label = "ClassifyBilled"; + $paramaction = 'classifybilled'; } print ''.$langs->trans($label).''; } @@ -2049,9 +2049,9 @@ if ($action == 'create') if ($action != 'presend' && $action != 'editline') { - print '
'; + print '
'; - $objectref = dol_sanitizeFileName($object->ref); + $objectref = dol_sanitizeFileName($object->ref); $filedir = $conf->reception->dir_output."/".$objectref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; @@ -2108,10 +2108,10 @@ if ($action == 'create') include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels'] = (empty($newlang) ? $langs->defaultlang : $newlang); - $formmail->fromtype = (GETPOST('fromtype') ?GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); - if ($formmail->fromtype === 'user') { - $formmail->fromid = $user->id; - } + $formmail->fromtype = (GETPOST('fromtype') ?GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); + if ($formmail->fromtype === 'user') { + $formmail->fromid = $user->id; + } $formmail->trackid = 'shi'.$object->id; if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { @@ -2147,7 +2147,7 @@ if ($action == 'create') $contactarr = array(); if (is_object($objectsrc)) // For the case the reception was created without orders { - $contactarr = $objectsrc->liste_contact(-1, 'external'); + $contactarr = $objectsrc->liste_contact(-1, 'external'); } if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 25690279f71..782728bfbd0 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -57,35 +57,35 @@ class Reception extends CommonObject */ public $picto = 'dollyrevert'; - public $socid; - public $ref_supplier; + public $socid; + public $ref_supplier; - /** - * @var int Ref int - * @deprecated - */ - public $ref_int; + /** + * @var int Ref int + * @deprecated + */ + public $ref_int; - public $brouillon; - public $entrepot_id; - public $lines = array(); - public $tracking_number; - public $tracking_url; - public $billed; - public $model_pdf; + public $brouillon; + public $entrepot_id; + public $lines = array(); + public $tracking_number; + public $tracking_url; + public $billed; + public $model_pdf; - public $trueWeight; - public $weight_units; - public $trueWidth; - public $width_units; - public $trueHeight; - public $height_units; - public $trueDepth; - public $depth_units; + public $trueWeight; + public $weight_units; + public $trueWidth; + public $width_units; + public $trueHeight; + public $height_units; + public $trueDepth; + public $depth_units; // A denormalized value - public $trueSize; + public $trueSize; - public $date_delivery; // Date delivery planed + public $date_delivery; // Date delivery planed /** @@ -103,8 +103,8 @@ class Reception extends CommonObject */ public $date_valid; - public $meths; - public $listmeths; // List of carriers + public $meths; + public $listmeths; // List of carriers const STATUS_DRAFT = 0; @@ -118,7 +118,7 @@ class Reception extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; $this->lines = array(); @@ -145,33 +145,33 @@ class Reception extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for contract */ - public function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("receptions"); - if (!empty($conf->global->RECEPTION_ADDON_NUMBER)) - { + if (!empty($conf->global->RECEPTION_ADDON_NUMBER)) + { $mybool = false; $file = $conf->global->RECEPTION_ADDON_NUMBER.".php"; $classname = $conf->global->RECEPTION_ADDON_NUMBER; - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/reception/"); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/reception/"); - // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; - } + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } - if (!$mybool) - { - dol_print_error('', "Failed to include file ".$file); - return ''; - } + if (!$mybool) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } $obj = new $classname(); @@ -185,10 +185,10 @@ class Reception extends CommonObject dol_print_error($this->db, get_class($this)."::getNextNumRef ".$obj->error); return ""; } - } else { - print $langs->trans("Error")." ".$langs->trans("Error_RECEPTION_ADDON_NUMBER_NotDefined"); - return ""; - } + } else { + print $langs->trans("Error")." ".$langs->trans("Error_RECEPTION_ADDON_NUMBER_NotDefined"); + return ""; + } } /** @@ -198,7 +198,7 @@ class Reception extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si erreur, id reception creee si ok */ - public function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $hookmanager; @@ -264,8 +264,8 @@ class Reception extends CommonObject $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); - $sql .= ", ".(int) $this->fk_incoterms; - $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -313,10 +313,10 @@ class Reception extends CommonObject if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('RECEPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('RECEPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) @@ -354,10 +354,10 @@ class Reception extends CommonObject * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param string $notused Internal reference of other object + * @param string $notused Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($id, $ref = '', $ref_ext = '', $notused = '') + public function fetch($id, $ref = '', $ref_ext = '', $notused = '') { global $conf; @@ -370,16 +370,16 @@ class Reception extends CommonObject $sql .= ", e.fk_shipping_method, e.tracking_number"; $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql .= ", e.note_private, e.note_public"; - $sql .= ', e.fk_incoterms, e.location_incoterms'; - $sql .= ', i.libelle as label_incoterms'; + $sql .= ', e.fk_incoterms, e.location_incoterms'; + $sql .= ', i.libelle as label_incoterms'; $sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; $sql .= " WHERE e.entity IN (".getEntity('reception').")"; if ($id) $sql .= " AND e.rowid=".$id; - if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($notused) $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($notused) $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -481,14 +481,14 @@ class Reception extends CommonObject * Validate object and update stock if option enabled * * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if OK, >0 if KO */ - public function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_syslog(get_class($this)."::valid"); @@ -499,8 +499,8 @@ class Reception extends CommonObject return 0; } - if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) { $this->error = 'Permission denied'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); @@ -524,7 +524,7 @@ class Reception extends CommonObject $numref = $this->ref; } - $this->newref = dol_sanitizeFileName($numref); + $this->newref = dol_sanitizeFileName($numref); $now = dol_now(); @@ -594,7 +594,7 @@ class Reception extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) + // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $error++; @@ -614,22 +614,22 @@ class Reception extends CommonObject // Change status of order to "reception in process" $ret = $this->setStatut(4, $this->origin_id, 'commande_fournisseur'); - if (!$ret) + if (!$ret) { - $error++; + $error++; } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('RECEPTION_VALIDATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('RECEPTION_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) @@ -651,17 +651,17 @@ class Reception extends CommonObject if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -681,8 +681,8 @@ class Reception extends CommonObject } else { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -706,7 +706,7 @@ class Reception extends CommonObject * @param string $batch Lot number * @return int <0 if KO, >0 if OK */ - public function addline($entrepot_id, $id, $qty, $array_options = 0, $comment = '', $eatby = '', $sellby = '', $batch = '') + public function addline($entrepot_id, $id, $qty, $array_options = 0, $comment = '', $eatby = '', $sellby = '', $batch = '') { global $conf, $langs, $user; @@ -726,7 +726,7 @@ class Reception extends CommonObject if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) { - $langs->load("errors"); + $langs->load("errors"); $this->error = $langs->trans("ErrorWarehouseRequiredIntoReceptionLine"); return -1; } @@ -755,16 +755,16 @@ class Reception extends CommonObject } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf; $error = 0; // Clean parameters @@ -793,8 +793,8 @@ class Reception extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; @@ -820,32 +820,32 @@ class Reception extends CommonObject $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; $sql .= " entity=".$conf->entity; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('RECEPTION_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers - } + // Call trigger + $result = $this->call_trigger('RECEPTION_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -861,7 +861,7 @@ class Reception extends CommonObject * @param User $user Object user * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - public function delete(User $user) + public function delete(User $user) { global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -909,9 +909,9 @@ class Reception extends CommonObject if (!$error) { - $main = MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = ".$this->id.")"; + $main = MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; $sql .= " WHERE fk_reception = ".$this->id; @@ -936,18 +936,18 @@ class Reception extends CommonObject if (!empty($this->origin) && $this->origin_id > 0) { - $this->fetch_origin(); - $origin = $this->origin; - if ($this->$origin->statut == 4) // If order source of reception is "partially received" - { - // Check if there is no more reception. If not, we can move back status of order to "validated" instead of "reception in progress" - $this->$origin->loadReceptions(); - //var_dump($this->$origin->receptions);exit; - if (count($this->$origin->receptions) <= 0) - { - $this->$origin->setStatut(3); // ordered - } - } + $this->fetch_origin(); + $origin = $this->origin; + if ($this->$origin->statut == 4) // If order source of reception is "partially received" + { + // Check if there is no more reception. If not, we can move back status of order to "validated" instead of "reception in progress" + $this->$origin->loadReceptions(); + //var_dump($this->$origin->receptions);exit; + if (count($this->$origin->receptions) <= 0) + { + $this->$origin->setStatut(3); // ordered + } + } } if (!$error) @@ -1003,13 +1003,13 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return int >0 if OK, Otherwise if KO */ - public function fetch_lines() + public function fetch_lines() { // phpcs:enable dol_include_once('/fourn/class/fournisseur.commande.dispatch.class.php'); @@ -1060,22 +1060,22 @@ class Reception extends CommonObject } /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param int $option Where point the link - * @param int $max Max length to show - * @param int $short Use short labels - * @param int $notooltip 1=No tooltip - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = 0, $max = 0, $short = 0, $notooltip = 0) + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param int $option Where point the link + * @param int $max Max length to show + * @param int $short Use short labels + * @param int $notooltip 1=No tooltip + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = 0, $max = 0, $short = 0, $notooltip = 0) { global $conf, $langs; $result = ''; $label = img_picto('', $this->picto).' '.$langs->trans("Reception").''; - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); $url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id; @@ -1084,17 +1084,17 @@ class Reception extends CommonObject $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("Reception"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("Reception"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart = ''; + $linkstart = ''; $linkend = ''; if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); @@ -1104,15 +1104,15 @@ class Reception extends CommonObject } /** - * Return status label - * - * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto - * @return string Libelle - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + * Return status label + * + * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto + * @return string Libelle + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -1122,30 +1122,30 @@ class Reception extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($status, $mode) - { - // phpcs:enable - global $langs; + public function LibStatut($status, $mode) + { + // phpcs:enable + global $langs; - $labelStatus = $langs->trans($this->statuts[$status]); - $labelStatusShort = $langs->trans($this->statutshorts[$status]); + $labelStatus = $langs->trans($this->statuts[$status]); + $labelStatusShort = $langs->trans($this->statutshorts[$status]); - $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_CLOSED) $statusType = 'status6'; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { global $langs; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; @@ -1154,7 +1154,7 @@ class Reception extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -1197,11 +1197,11 @@ class Reception extends CommonObject $this->commande_id = 0; $this->commande = $order; - $this->origin_id = 1; - $this->origin = 'commande'; + $this->origin_id = 1; + $this->origin = 'commande'; - $this->note_private = 'Private note'; - $this->note_public = 'Public note'; + $this->note_private = 'Private note'; + $this->note_public = 'Public note'; $nbp = 5; $xnbp = 0; @@ -1250,7 +1250,7 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * @@ -1278,101 +1278,101 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch all deliveries method and return an array. Load array this->listmeths. - * - * @param int $id only this carrier, all if none - * @return void - */ - public function list_delivery_methods($id = '') - { - // phpcs:enable - global $langs; - - $this->listmeths = array(); - $i = 0; - - $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id != '') $sql .= " WHERE em.rowid=".$id; - - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $this->listmeths[$i]['rowid'] = $obj->rowid; - $this->listmeths[$i]['code'] = $obj->code; - $label = $langs->trans('ReceptionMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); - $this->listmeths[$i]['description'] = $obj->description; - $this->listmeths[$i]['tracking'] = $obj->tracking; - $this->listmeths[$i]['active'] = $obj->active; - $i++; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update/create delivery method. - * - * @param string $id id method to activate - * - * @return void - */ - public function update_delivery_method($id = '') - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Fetch all deliveries method and return an array. Load array this->listmeths. + * + * @param int $id only this carrier, all if none + * @return void + */ + public function list_delivery_methods($id = '') + { // phpcs:enable - if ($id == '') - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; - $resql = $this->db->query($sql); - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql .= " code='".$this->db->escape($this->update['code'])."'"; - $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql .= ",description='".$this->db->escape($this->update['description'])."'"; - $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".$id; - $resql = $this->db->query($sql); - } - if ($resql < 0) dol_print_error($this->db, ''); - } + global $langs; + + $this->listmeths = array(); + $i = 0; + + $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + if ($id != '') $sql .= " WHERE em.rowid=".$id; + + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $this->listmeths[$i]['rowid'] = $obj->rowid; + $this->listmeths[$i]['code'] = $obj->code; + $label = $langs->trans('ReceptionMethod'.$obj->code); + $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); + $this->listmeths[$i]['description'] = $obj->description; + $this->listmeths[$i]['tracking'] = $obj->tracking; + $this->listmeths[$i]['active'] = $obj->active; + $i++; + } + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Activate delivery method. - * - * @param int $id id method to activate - * - * @return void - */ - public function activ_delivery_method($id) - { + /** + * Update/create delivery method. + * + * @param string $id id method to activate + * + * @return void + */ + public function update_delivery_method($id = '') + { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql .= ' WHERE rowid='.$id; + if ($id == '') + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; + $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; + $resql = $this->db->query($sql); + } else { + $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; + $sql .= " code='".$this->db->escape($this->update['code'])."'"; + $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; + $sql .= ",description='".$this->db->escape($this->update['description'])."'"; + $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; + $sql .= " WHERE rowid=".$id; + $resql = $this->db->query($sql); + } + if ($resql < 0) dol_print_error($this->db, ''); + } - $resql = $this->db->query($sql); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * DesActivate delivery method. - * - * @param int $id id method to desactivate - * - * @return void - */ - public function disable_delivery_method($id) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Activate delivery method. + * + * @param int $id id method to activate + * + * @return void + */ + public function activ_delivery_method($id) + { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql .= ' WHERE rowid='.$id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; + $sql .= ' WHERE rowid='.$id; - $resql = $this->db->query($sql); - } + $resql = $this->db->query($sql); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * DesActivate delivery method. + * + * @param int $id id method to desactivate + * + * @return void + */ + public function disable_delivery_method($id) + { + // phpcs:enable + $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; + $sql .= ' WHERE rowid='.$id; + + $resql = $this->db->query($sql); + } /** @@ -1381,7 +1381,7 @@ class Reception extends CommonObject * @param string $value Value * @return void */ - public function getUrlTrackingStatus($value = '') + public function getUrlTrackingStatus($value = '') { if (!empty($this->shipping_method_id)) { @@ -1413,7 +1413,7 @@ class Reception extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function setClosed() + public function setClosed() { global $conf, $langs, $user; @@ -1500,8 +1500,8 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref)); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; $error++; break; } } else { @@ -1511,9 +1511,9 @@ class Reception extends CommonObject $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; - $error++; break; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; + $error++; break; } } } @@ -1526,36 +1526,36 @@ class Reception extends CommonObject // Call trigger if (!$error) { - $result = $this->call_trigger('RECEPTION_CLOSED', $user); - if ($result < 0) { - $error++; - } + $result = $this->call_trigger('RECEPTION_CLOSED', $user); + if ($result < 0) { + $error++; + } } } else { dol_print_error($this->db); - $error++; + $error++; } if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -1; + $this->db->rollback(); + return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the reception as invoiced (used when WORKFLOW_BILL_ON_RECEPTION is on) * * @return int <0 if ko, >0 if ok */ - public function set_billed() + public function set_billed() { // phpcs:enable - global $user; + global $user; $error = 0; $this->db->begin(); @@ -1595,7 +1595,7 @@ class Reception extends CommonObject * * @return int <0 if ko, >0 if ok */ - public function reOpen() + public function reOpen() { global $conf, $langs, $user; @@ -1655,8 +1655,8 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref)); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; $error++; break; } } else { @@ -1665,9 +1665,9 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; - $error++; break; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; + $error++; break; } } } @@ -1679,11 +1679,11 @@ class Reception extends CommonObject if (!$error) { - // Call trigger - $result = $this->call_trigger('RECEPTION_REOPEN', $user); - if ($result < 0) { - $error++; - } + // Call trigger + $result = $this->call_trigger('RECEPTION_REOPEN', $user); + if ($result < 0) { + $error++; + } } if ($this->origin == 'order_supplier') { @@ -1707,41 +1707,41 @@ class Reception extends CommonObject } /** - * Set draft status - * - * @param User $user Object user that modify - * @return int <0 if KO, >0 if OK - */ - public function setDraft($user) - { + * Set draft status + * + * @param User $user Object user that modify + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user) + { // phpcs:enable - global $conf, $langs; + global $conf, $langs; - $error = 0; + $error = 0; - // Protection - if ($this->statut <= self::STATUS_DRAFT) - { - return 0; - } + // Protection + if ($this->statut <= self::STATUS_DRAFT) + { + return 0; + } - if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) - { - $this->error = 'Permission denied'; - return -1; - } + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) + { + $this->error = 'Permission denied'; + return -1; + } - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql .= " SET fk_statut = ".self::STATUS_DRAFT; - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(__METHOD__, LOG_DEBUG); - if ($this->db->query($sql)) - { - // If stock increment is done on closing + dol_syslog(__METHOD__, LOG_DEBUG); + if ($this->db->query($sql)) + { + // If stock increment is done on closing if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1784,8 +1784,8 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref)); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; $error++; break; } @@ -1795,9 +1795,9 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { - $this->error = $mouvS->error; - $this->errors = $mouvS->errors; - $error++; break; + $this->error = $mouvS->error; + $this->errors = $mouvS->errors; + $error++; break; } } } @@ -1807,11 +1807,11 @@ class Reception extends CommonObject } } - if (!$error) { - // Call trigger - $result = $this->call_trigger('RECEPTION_UNVALIDATE', $user); - if ($result < 0) $error++; - } + if (!$error) { + // Call trigger + $result = $this->call_trigger('RECEPTION_UNVALIDATE', $user); + if ($result < 0) $error++; + } if ($this->origin == 'order_supplier') { if (!empty($this->origin) && $this->origin_id > 0) @@ -1843,20 +1843,20 @@ class Reception extends CommonObject } } - if (!$error) { - $this->statut = self::STATUS_DRAFT; - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + if (!$error) { + $this->statut = self::STATUS_DRAFT; + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } /** * Create a document onto disk according to template module. From 20c00d0c434bdc6e19a322f593e1c9d43edbe60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 17:54:45 +0100 Subject: [PATCH 055/247] Update timeline.inc.php --- htdocs/theme/eldy/timeline.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 21e683e42f0..f767bed594f 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -112,7 +112,7 @@ a.timeline-btn:hover { background-color: #e7e7e7; color: #333; - border-color: #adadad;; + border-color: #adadad; } From cd7cee061a4a50e8f5e1215b00f5eafb9845dd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 17:56:26 +0100 Subject: [PATCH 056/247] Update index.php --- htdocs/modulebuilder/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 97539472de2..57446d7163e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1628,7 +1628,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') $class = 'mod'.$module; } catch (Throwable $e) { // This is called in PHP 7 only. Never called with PHP 5.6 - $loadclasserrormessage = $e->getMessage()."
\n";; + $loadclasserrormessage = $e->getMessage()."
\n"; $loadclasserrormessage .= 'File: '.$e->getFile()."
\n"; $loadclasserrormessage .= 'Line: '.$e->getLine()."
\n"; } @@ -1637,8 +1637,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { try { $moduleobj = new $class($db); - } catch (Exception $e) - { + } catch (Exception $e) { $error++; print $e->getMessage(); } From 09b8d166ddc231d4659f7cf9b3c8bd084651d8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 18:21:45 +0100 Subject: [PATCH 057/247] The constant MissingIds was not found. The constant MissingIds was not found. Maybe you did not declare it correctly or list all dependencies? --- htdocs/product/price.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 3c0d28b8614..325fce0ead0 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -470,7 +470,7 @@ if (empty($reshook)) $result = $db->query($sql); } else { - setEventMessages(('delete_price_by_qty'.$langs->transnoentities(MissingIds)), null, 'errors'); + setEventMessages(('delete_price_by_qty'.$langs->transnoentities('MissingIds')), null, 'errors'); } } From 4d716e74bd328aca961dd4cc75098d9c0180ef21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 19:06:45 +0100 Subject: [PATCH 058/247] Mutualise code, introduce MAIN_ALL_TOWN_TO_UPPER --- htdocs/core/class/commonobject.class.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 04b7d4985cd..294e605125e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -569,6 +569,28 @@ abstract class CommonObject return dol_trunc($ret, $maxlen); } + /** + * Set to upper or ucwords/lower if needed + * + * @return void; + */ + public function setUpperOrLowerCase() + { + global $conf; + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) { + $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); + $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); + $this->name = dol_ucwords(dol_strtolower($this->name)); + } + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) { + $this->lastname = dol_strtoupper($this->lastname); + $this->name = dol_strtoupper($this->name); + } + if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) { + $this->town = dol_strtoupper($this->town); + } + } + /** * Return clicable link of object (with eventually picto) * From 79941a8dde381ec1a90c9cb1a4546985329f41d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 19:10:54 +0100 Subject: [PATCH 059/247] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index b67ded65c6e..c48b00050f8 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -589,9 +589,7 @@ class Adherent extends CommonObject $this->town = ($this->town ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); + $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); From e546e56b222f6b2246700880b72ef2d27f1dcbc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 20:50:33 +0100 Subject: [PATCH 060/247] Update contact.class.php --- htdocs/contact/class/contact.class.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 2034803ecb8..6e0a3a0e195 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -353,9 +353,7 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); $this->firstname = trim($this->firstname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); + $this->setUpperOrLowerCase(); if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -464,10 +462,6 @@ class Contact extends CommonObject $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); - $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->firstname = trim($this->firstname); $this->email = trim($this->email); @@ -478,8 +472,9 @@ class Contact extends CommonObject $this->skype = trim($this->skype); $this->photo = trim($this->photo); $this->fax = trim($this->fax); - $this->zip = (empty($this->zip) ? '' : $this->zip); - $this->town = (empty($this->town) ? '' : $this->town); + $this->zip = (empty($this->zip) ? '' : trim($this->zip)); + $this->town = (empty($this->town) ? '' : trim($this->town)); + $this->setUpperOrLowerCase(); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); if (empty($this->statut)) $this->statut = 0; if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility From fcb343e89133cc8224a528b95a00ce539fd5f87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 20:53:29 +0100 Subject: [PATCH 061/247] Update societe.class.php --- htdocs/societe/class/societe.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3047e986df8..3fcc7e610ac 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -789,8 +789,7 @@ class Societe extends CommonObject // Clean parameters if (empty($this->status)) $this->status = 0; $this->name = $this->name ?trim($this->name) : trim($this->nom); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); + $this->setUpperOrLowerCase(); $this->nom = $this->name; // For backward compatibility if (empty($this->client)) $this->client = 0; if (empty($this->fournisseur)) $this->fournisseur = 0; @@ -1094,8 +1093,6 @@ class Societe extends CommonObject $now = dol_now(); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name); // Clean parameters $this->id = $id; $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); @@ -1106,6 +1103,7 @@ class Societe extends CommonObject $this->address = $this->address ?trim($this->address) : trim($this->address); $this->zip = $this->zip ?trim($this->zip) : trim($this->zip); $this->town = $this->town ?trim($this->town) : trim($this->town); + $this->setUpperOrLowerCase(); $this->state_id = trim($this->state_id); $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; $this->phone = trim($this->phone); From 7ef2aaf8af2e9f862d2e8a5143d4b39aa74ce936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 20:57:36 +0100 Subject: [PATCH 062/247] Update user.class.php --- htdocs/user/class/user.class.php | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 87f36cab15a..521a9522ae4 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1122,25 +1122,19 @@ class User extends CommonObject global $mysoc; // Clean parameters - - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); - + $this->setUpperOrLowerCase(); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value dol_syslog(get_class($this)."::create login=".$this->login.", user=".(is_object($user) ? $user->id : ''), LOG_DEBUG); // Check parameters - if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) - { + if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail", $this->email); return -1; } - if (empty($this->login)) - { + if (empty($this->login)) { $langs->load("errors"); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); return -1; @@ -1467,11 +1461,6 @@ class User extends CommonObject dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember.", nosyncmemberpass=".$nosyncmemberpass); // Clean parameters - - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); - $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); $this->employee = $this->employee ? $this->employee : 0; @@ -1479,9 +1468,10 @@ class User extends CommonObject $this->gender = trim($this->gender); $this->pass = trim($this->pass); $this->api_key = trim($this->api_key); - $this->address = $this->address ?trim($this->address) : trim($this->address); - $this->zip = $this->zip ?trim($this->zip) : trim($this->zip); - $this->town = $this->town ?trim($this->town) : trim($this->town); + $this->address = $this->address ? trim($this->address) : trim($this->address); + $this->zip = $this->zip ? trim($this->zip) : trim($this->zip); + $this->town = $this->town ? trim($this->town) : trim($this->town); + $this->setUpperOrLowerCase(); $this->state_id = trim($this->state_id); $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; $this->office_phone = trim($this->office_phone); From f5673fd08a5509addfdeb009299c17a073527f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Oct 2020 22:47:29 +0100 Subject: [PATCH 063/247] doxygen --- htdocs/product/class/product.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a4469aeab7..656368a8f53 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -71,7 +71,9 @@ class Product extends CommonObject */ public $ismultientitymanaged = 1; - + /** + * @var string picto + */ public $picto = 'product'; /** @@ -86,6 +88,7 @@ class Product extends CommonObject * @see label */ public $libelle; + /** * Product label * @@ -395,7 +398,9 @@ class Product extends CommonObject */ public $supplierprices; - + /** + * @var array fields of object product + */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -3190,7 +3195,7 @@ class Product extends CommonObject * @param string $sql Request to execute * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param int $year Year (0=current year, -1=all years) - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array|int <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ private function _get_stats($sql, $mode, $year = 0) { From 1c7d293a93e6583302de9a2de8a14e78836b1f79 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Oct 2020 10:10:10 +0100 Subject: [PATCH 064/247] FIX wrong check operator --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c48a0c4be3c..12dd0e1d9b9 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -610,7 +610,7 @@ if (!empty($type)) if ($type == 'f') $label = 'NewSupplier'; } -if ($contextpage = 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { +if ($contextpage == 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); } From c3f0f3cc4ad4675499dae2285c8c4acf728a0604 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2020 10:36:48 +0100 Subject: [PATCH 065/247] Revert "FIX: various payments: bad data handling for subledger account + useless db commit/rollback" --- htdocs/compta/bank/various_payment/card.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ae147635099..6573207a117 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -115,7 +115,7 @@ if (empty($reshook)) $object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account = $subledger_account; + $object->subledger_account = GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; $object->sens = GETPOST('sens'); $object->fk_project = GETPOST('fk_project', 'int'); @@ -221,10 +221,13 @@ if (empty($reshook)) if ($action == 'setsubledger_account') { $result = $object->fetch($id); - $object->subledger_account = $subledger_account; + $object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""); $res = $object->update($user); - if ($res < 0) { + if ($res > 0) { + $db->commit(); + } else { + $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } From b1b7a7c72548e424293bb41c5d70573f897e1e9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2020 10:40:50 +0100 Subject: [PATCH 066/247] Fix missing transaction --- htdocs/compta/bank/various_payment/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 6573207a117..c592ead835b 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -219,6 +219,8 @@ if (empty($reshook)) } if ($action == 'setsubledger_account') { + $db->begin(); + $result = $object->fetch($id); $object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""); From 5e2962ef38ebecdf7c74a85d3de130035356ffd5 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Thu, 29 Oct 2020 10:50:13 +0100 Subject: [PATCH 067/247] FIX - 10.0 - remove 'action' parameter from redirect URL when reordering lines on a document --- htdocs/core/tpl/ajaxrow.tpl.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 0b92df1e519..620d0433b27 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -80,7 +80,12 @@ $(document).ready(function(){ console.log("tableDND end of ajax call"); if (reloadpage == 1) { //console.log(''); - location.href = ''; + + location.href = ''; } else { $("# .drag").each( function( intIndex ) { @@ -108,4 +113,4 @@ $(document).ready(function(){ }); - \ No newline at end of file + From 980cb095da0629806131170bbd8aace826292bb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2020 11:05:43 +0100 Subject: [PATCH 068/247] Fix sort order use last sortorder if several fields. --- htdocs/core/db/DoliDB.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 8ca84e0dd10..02864012dc3 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -229,6 +229,7 @@ abstract class DoliDB implements Database { if (! empty($sortfield)) { + $oldsortorder = ''; $return=''; $fields=explode(',', $sortfield); $orders=explode(',', $sortorder); @@ -238,15 +239,19 @@ abstract class DoliDB implements Database if (! $return) $return.=' ORDER BY '; else $return.=', '; - $return.=preg_replace('/[^0-9a-z_\.]/i', '', $val); + $return .= preg_replace('/[^0-9a-z_\.]/i', '', $val); // Add field $tmpsortorder = trim($orders[$i]); // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { + $oldsortorder = 'ASC'; $return .= ' ASC'; } elseif (strtoupper($tmpsortorder) === 'DESC') { + $oldsortorder = 'DESC'; $return .= ' DESC'; + } else { + $return .= ' '.($oldsortorder ? $oldsortorder : 'ASC'); } $i++; From 032813fa19e9c220dfa1dd40f4e9b5ac1a36f781 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Oct 2020 11:05:45 +0100 Subject: [PATCH 069/247] FIX extrafield date not recover in create/edit mode --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 04b7d4985cd..46208635cd3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6862,7 +6862,7 @@ abstract class CommonObject { $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; + $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) From 91cf5de54df20dad1fbdb6c91e66b908524e7dde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2020 11:06:18 +0100 Subject: [PATCH 070/247] Fix bad sort order --- htdocs/compta/bank/various_payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 95d84954490..3198b34a34d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -58,7 +58,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="v.datep,v.rowid"; -if (! $sortorder) $sortorder="DESC"; +if (! $sortorder) $sortorder="DESC,DESC"; $filtre=GETPOST("filtre", 'alpha'); From 2a386b6feaa79f56ad5bff2e302319957925e951 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Oct 2020 11:13:18 +0100 Subject: [PATCH 071/247] Fix set subledger account --- htdocs/compta/bank/various_payment/card.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index c592ead835b..cc2a5bd5283 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -51,8 +51,12 @@ $sens = GETPOST("sens", "int"); $amount = price2num(GETPOST("amount", "alpha")); $paymenttype = GETPOST("paymenttype", "int"); $accountancy_code = GETPOST("accountancy_code", "alpha"); -$subledger_account = GETPOST("subledger_account", "alpha"); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); +if (!empty($conf->accounting->enabled) && !empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : ''; +} else { + $subledger_account = GETPOST("subledger_account", "alpha"); +} // Security check $socid = GETPOST("socid", "int"); @@ -115,7 +119,7 @@ if (empty($reshook)) $object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account = GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; + $object->subledger_account = $subledger_account; $object->sens = GETPOST('sens'); $object->fk_project = GETPOST('fk_project', 'int'); @@ -223,7 +227,7 @@ if (empty($reshook)) $result = $object->fetch($id); - $object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""); + $object->subledger_account = $subledger_account; $res = $object->update($user); if ($res > 0) { @@ -388,7 +392,7 @@ if ($action == 'create') // Subledger account if (!empty($conf->accounting->enabled)) { - print ''.$langs->trans("SubledgerAccount").''; + print ''.$langs->trans("SubledgerAccount").'aaaa'; print ''; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { From 9e70d7ca65b1a780bf75d6563a6f07370094c352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2020 18:37:52 +0100 Subject: [PATCH 072/247] fix undefined variable --- htdocs/user/class/user.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 521a9522ae4..8e3e49fe2be 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -678,14 +678,14 @@ class User extends CommonObject } else { // On a demande suppression d'un droit sur la base d'un nom de module ou perms // Where pour la liste des droits a supprimer - if (!empty($allmodule)) - { - if ($allmodule == 'allmodules') - { + if (!empty($allmodule)) { + if ($allmodule == 'allmodules') { $wherefordel = 'allmodules'; } else { $wherefordel = "module='".$this->db->escape($allmodule)."'"; - if (!empty($allperms)) $whereforadd .= " AND perms='".$this->db->escape($allperms)."'"; + if (!empty($allperms)) { + $wherefordel .= " AND perms='".$this->db->escape($allperms)."'"; + } } } } From 0507e715864caa02166c83082ec8f6772090dcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2020 18:44:15 +0100 Subject: [PATCH 073/247] phpcs --- htdocs/core/db/DoliDB.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 976770747c6..481a4669dc6 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -242,8 +242,7 @@ abstract class DoliDB implements Database $fields=explode(',', $sortfield); $orders=explode(',', $sortorder); $i=0; - foreach($fields as $val) - { + foreach ($fields as $val) { if (!$return) $return .= ' ORDER BY '; else $return .= ', '; From f22017080d46bd284d2513db5dd71ac43bc5abf6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 03:25:33 +0100 Subject: [PATCH 074/247] Fix for php8 --- htdocs/core/ajax/check_notifications.php | 2 +- htdocs/core/lib/security2.lib.php | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 346b17e3288..77245c22494 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -75,7 +75,7 @@ if ($time >= $_SESSION['auto_check_events_not_before']) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']); + dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); $sql = 'SELECT id'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar'; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 18d1e9c680a..aa53a5b71d7 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -467,15 +467,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len { $max = strlen($lowercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $lowercase{random_int(0, $max)}; + $tmp = random_int(0, $max); + $randomCode .= $lowercase[$tmp]; } $max = strlen($uppercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $uppercase{random_int(0, $max)}; + $tmp = random_int(0, $max); + $randomCode .= $uppercase[$tmp]; } $max = strlen($numbers) - 1; for ($x = 0; $x < $nbofcharlast; $x++) { - $randomCode .= $numbers{random_int(0, $max)}; + $tmp = random_int(0, $max); + $randomCode .= $numbers[$tmp]; } $generated_password=str_shuffle($randomCode); @@ -484,15 +487,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len { $max = strlen($lowercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $lowercase{mt_rand(0, $max)}; + $tmp = mt_rand(0, $max); + $randomCode .= $lowercase[$tmp]; } $max = strlen($uppercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $uppercase{mt_rand(0, $max)}; + $tmp = mt_rand(0, $max); + $randomCode .= $uppercase[$tmp]; } $max = strlen($numbers) - 1; for ($x = 0; $x < $nbofcharlast; $x++) { - $randomCode .= $numbers{mt_rand(0, $max)}; + $tmp = mt_rand(0, $max); + $randomCode .= $numbers[$tmp]; } $generated_password=str_shuffle($randomCode); @@ -516,11 +522,13 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $max = strlen($numbers) - 1; if (function_exists('random_int')) // Cryptographic random { - $generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); + $tmp = random_int(0, $max); + $generated_password=str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password); } else { - $generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password); + $tmp = random_int(0, $max); + $generated_password=str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password); } } From 1b5bcaccc6a529a48ab90cd2753b4dc193dab9cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 04:13:31 +0100 Subject: [PATCH 075/247] Fix remove warnings --- htdocs/core/class/hookmanager.class.php | 4 ++-- htdocs/main.inc.php | 7 ++++--- htdocs/stripe/config.php | 8 ++++---- htdocs/theme/eldy/info-box.inc.php | 9 +++++++-- htdocs/theme/eldy/style.css.php | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 39c74b4f059..45dc98f8301 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -105,7 +105,7 @@ class HookManager if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) // We instantiate action class only if initialized hook is handled by module { // Include actions class overwriting hooks - if (! is_object($this->hooks[$context][$module])) // If set, class was already loaded + if (empty($this->hooks[$context][$module]) || !is_object($this->hooks[$context][$module])) // If set to an object value, class was already loaded { $path = '/'.$module.'/class/'; $actionfile = 'actions_'.$module.'.class.php'; @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (! is_array($this->hooks) || empty($this->hooks)) return ''; + if (! is_array($this->hooks) || empty($this->hooks)) return 0; $parameters['context']=join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a29de165775..b5626b8dc4a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -238,6 +238,7 @@ if (!empty($conf->debugbar->enabled) && ! GETPOST('dol_use_jmobile') && empty($_ include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; $debugbar = new DolibarrDebugBar(); $renderer = $debugbar->getRenderer(); + if (empty($conf->global->MAIN_HTML_HEADER)) $conf->global->MAIN_HTML_HEADER = ''; $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead(); $debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)'); @@ -904,7 +905,7 @@ elseif (!empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) } // set MAIN_OPTIMIZEFORCOLORBLIND -$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = $user->conf->MAIN_OPTIMIZEFORCOLORBLIND; +$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = empty($user->conf->MAIN_OPTIMIZEFORCOLORBLIND) ? '' : $user->conf->MAIN_OPTIMIZEFORCOLORBLIND; // Set terminal output option according to conf->browser. if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu = 1; @@ -1145,8 +1146,8 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) // // A default security policy that keep usage of js external component like ckeditor, stripe, google, working // $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' *.stripe.com; connect-src 'self';"; //} - //else $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY; - $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY; + //else + $contentsecuritypolicy = empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY) ? '': $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY; if (!is_object($hookmanager)) $hookmanager = new HookManager($db); $hookmanager->initHooks(array("main")); diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 0226c724165..829f377fb42 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -34,12 +34,12 @@ global $stripearrayofkeysbyenv; $stripearrayofkeysbyenv = array( 0=>array( - "secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY + "secret_key" => empty($conf->global->STRIPE_TEST_SECRET_KEY) ? '' : $conf->global->STRIPE_TEST_SECRET_KEY, + "publishable_key" => empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_TEST_PUBLISHABLE_KEY ), 1=>array( - "secret_key" => $conf->global->STRIPE_LIVE_SECRET_KEY, - "publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY + "secret_key" => empty($conf->global->STRIPE_LIVE_SECRET_KEY) ? '' : $conf->global->STRIPE_LIVE_SECRET_KEY, + "publishable_key" => empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY ) ); diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 268f1885327..175bfce3e2a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -153,10 +153,15 @@ a.info-box-text{ text-decoration: none;} include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $prefix=''; -//$prefix = 'background-'; if (! empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; -if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO) && $prefix) $conf->global->THEME_AGRESSIVENESS_RATIO=-50; +if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO)) { + if ($prefix) { + $conf->global->THEME_AGRESSIVENESS_RATIO = -50; + } else { + $conf->global->THEME_AGRESSIVENESS_RATIO = 0; + } +} if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENESS_RATIO=GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); //var_dump($conf->global->THEME_AGRESSIVENESS_RATIO); ?> diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4c8a5f2d8ee..941dba9742c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -236,7 +236,7 @@ print 'fontsizesmaller='.$fontsizesmaller."\n"; print 'topMenuFontSize='.$topMenuFontSize."\n"; print 'toolTipBgColor='.$toolTipBgColor."\n"; print 'toolTipFontColor='.$toolTipFontColor."\n"; -print 'conf->global->THEME_AGRESSIVENESS_RATIO='.$conf->global->THEME_AGRESSIVENESS_RATIO." (must be between -100 and +100)\n"; +print 'conf->global->THEME_AGRESSIVENESS_RATIO='.(empty($conf->global->THEME_AGRESSIVENESS_RATIO) ? '' : $conf->global->THEME_AGRESSIVENESS_RATIO)." (must be between -100 and +100)\n"; print '*/'."\n"; From f5a156ee06104db03591f1faa68786ca29516809 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 04:17:02 +0100 Subject: [PATCH 076/247] Fix regression --- htdocs/core/class/hookmanager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 45dc98f8301..08c290b5c4c 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (! is_array($this->hooks) || empty($this->hooks)) return 0; + if (! is_array($this->hooks) || empty($this->hooks)) return ''; $parameters['context']=join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); From f51b02026c142f6246a970aa9e4f4eae598c3285 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 04:24:06 +0100 Subject: [PATCH 077/247] Fix regression --- htdocs/core/lib/security2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index aa53a5b71d7..85a297a4bc4 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -527,7 +527,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len } else { - $tmp = random_int(0, $max); + $tmp = mt_rand(0, $max); $generated_password=str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password); } } From a24071492eb4bca739f4e51c99958eb6b800479b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 05:45:36 +0100 Subject: [PATCH 078/247] Start fix for php8 compatibility --- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 2 +- htdocs/admin/modules.php | 4 ++-- htdocs/asset/list.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 1 - htdocs/core/class/html.formother.class.php | 1 + htdocs/core/db/DoliDB.class.php | 2 +- htdocs/core/get_info.php | 15 +++++++++------ htdocs/core/js/lib_notification.js.php | 2 +- htdocs/core/lib/functions.lib.php | 17 ++++++++++------- .../class/DataCollector/DolibarrCollector.php | 4 ++-- .../class/emailcollector.class.php | 2 +- .../class/emailcollectoraction.class.php | 2 +- .../class/emailcollectorfilter.class.php | 2 +- htdocs/index.php | 2 +- htdocs/main.inc.php | 17 +++++++++++------ .../template/class/myobject.class.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/class/mo.class.php | 4 ++-- htdocs/mrp/mo_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- .../class/recruitmentcandidature.class.php | 2 +- .../class/recruitmentjobposition.class.php | 2 +- .../recruitment/recruitmentcandidature_list.php | 2 +- .../recruitment/recruitmentjobposition_list.php | 2 +- htdocs/societe/class/societe.class.php | 6 ++++-- htdocs/ticket/list.php | 2 +- 34 files changed, 68 insertions(+), 55 deletions(-) diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 98dcfd592a2..6e868d73728 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -393,7 +393,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 4556ec80bff..488997b5b78 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -474,7 +474,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index e281cb21155..c97ccb182b8 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -281,7 +281,7 @@ if ($action == 'set' && $user->admin) $form = new Form($db); -//$morejs = array("/admin/dolistore/js/dolistore.js.php"); +$morejs = array(); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed @@ -402,7 +402,7 @@ foreach ($modulesdir as $dir) $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } - $familyposition = $familyinfo[$familykey]['position']; + $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); if ($external && ! in_array($familykey, $listOfOfficialModuleGroups)) { diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index ef3ea4ce975..2a7271fed4a 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -386,7 +386,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 7687ab250ac..02cee1c4d90 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -486,7 +486,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4e5d28274a8..4a341ce2c8b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -204,7 +204,7 @@ class BOM extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { @@ -1145,7 +1145,7 @@ class BOMLine extends CommonObjectLine // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index b41e46aff76..55ad8914a9e 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -390,7 +390,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); else print ''; print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6e0a3a0e195..10c844f3149 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -281,7 +281,7 @@ class Contact extends CommonObject { foreach($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5371b8078fa..ef062b8acaf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6410,7 +6410,7 @@ abstract class CommonObject $type = 'varchar'; // convert varchar(xx) int varchar $size = $reg[1]; } elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar - if (is_array($val['arrayofkeyval'])) $type = 'select'; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $type = 'select'; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link'; $default = $val['default']; @@ -6420,7 +6420,7 @@ abstract class CommonObject $param = array(); $param['options'] = array(); - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { $type = 'link'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bf52ff5871a..42468973a69 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -509,7 +509,6 @@ class Form * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string Code html du tooltip (texte+picto) * @see textwithpicto() Use thisfunction if you can. - * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5d3bd181753..7606779afe5 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1152,6 +1152,7 @@ class FormOther } // Define boxlista and boxlistb + $boxlista = ''; $boxlistb = ''; $nbboxactivated = count($boxidactivatedforuser); if ($nbboxactivated) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 481a4669dc6..170fa42cde3 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -248,7 +248,7 @@ abstract class DoliDB implements Database $return .= preg_replace('/[^0-9a-z_\.]/i', '', $val); // Add field - $tmpsortorder = trim($orders[$i]); + $tmpsortorder = (empty($orders[$i]) ? '' : trim($orders[$i])); // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index 48b957b9e8a..a91d5a6afec 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -60,8 +60,6 @@ print ''."\n"; print '
'; //print '
'; -$nbofsearch = 0; - // Define link to login card $appli = constant('DOL_APPLICATION_TITLE'); if (!empty($conf->global->MAIN_APPLICATION_TITLE)) @@ -117,6 +115,11 @@ if (is_numeric($result)) else $toprightmenu = $hookmanager->resPrint; // replace } else $toprightmenu .= $result; // For backward compatibility +if (!isset($form) || !is_object($form)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); +} + // Link to module builder if (!empty($conf->modulebuilder->enabled)) { @@ -124,7 +127,7 @@ if (!empty($conf->modulebuilder->enabled)) //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); } // Link to print main content area @@ -144,7 +147,7 @@ if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OP //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); $text.=''; $text.=''; - $toprightmenu.=@Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); + $toprightmenu .= $form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); } */ @@ -183,13 +186,13 @@ if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPT //if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')'; $text.=''; //$toprightmenu.='
'."\n"; - $toprightmenu.=@Form::textwithtooltip('',$title,2,1,$text,'login_block_elem',2); + $toprightmenu .= $form->textwithtooltip('',$title,2,1,$text,'login_block_elem',2); } } */ // Logout link -if (GETPOST('withlogout', 'int')) $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2); +if (GETPOST('withlogout', 'int')) $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2); $toprightmenu .= '
'; diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index ee212b4373f..23290f220bd 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -51,7 +51,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP /* Launch timer */ // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. //var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds - var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; + var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; if (login != '') { setTimeout(first_execution, time_first_execution * 1000); time_js_next_test = nowtime + time_first_execution; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df2eab61378..94e7ee85586 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -185,6 +185,7 @@ function getBrowserInfo($user_agent) if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; } // Name + $reg = array(); if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end @@ -3344,13 +3345,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. // class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes. + $morestyle = ''; $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { - $morestyle = ' '.$reg[1]; + $morestyle = $reg[1]; $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); } $moreatt = trim($moreatt); @@ -6484,11 +6486,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $tmp4 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp5 = dol_get_next_month($tmp['mon'], $tmp['year']); + $daytext = $outputlangs->trans('Day'.$tmp['wday']); + $substitutionarray = array_merge($substitutionarray, array( '__DAY__' => (string) $tmp['mday'], - '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday - '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon - '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M + '__DAY_TEXT__' => $daytext, // Monday + '__DAY_TEXT_SHORT__' => dol_trunc($daytext, 3, 'right', 'UTF-8', 1), // Mon + '__DAY_TEXT_MIN__' => dol_trunc($daytext, 1, 'right', 'UTF-8', 1), // M '__MONTH__' => (string) $tmp['mon'], '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])), '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])), @@ -7198,8 +7202,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1) global $soc; // For backward compatibility //print $s."
\n"; - if ($returnvalue) - { + if ($returnvalue) { if ($hideerrors) return @eval('return '.$s.';'); else return eval('return '.$s.';'); } else { @@ -7602,7 +7605,7 @@ function printCommonFooter($zone = 'private') // A div to store page_y POST parameter so we can read it using javascript print "\n\n"; - print ''."\n"; + print ''."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php index b1b31bc9154..2e11887360f 100644 --- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -91,8 +91,8 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid $info .= $langs->trans('Port').': '.$conf->global->MAIN_MAIL_SMTP_PORT.'
'; $info .= $langs->trans('ID').': '.$conf->global->MAIN_MAIL_SMTPS_ID.'
'; $info .= $langs->trans('Pwd').': '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'; - $info .= $langs->trans('TLS/STARTTLS').': '.$conf->global->MAIN_MAIL_EMAIL_TLS.' / '.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'
'; - $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('Yes') : $langs->trans('No')).'
'; + $info .= $langs->trans('TLS/STARTTLS').': '.(empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_TLS).' / '.(empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_STARTTLS).'
'; + $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(empty($conf->global->MAIN_DISABLE_ALL_MAILS) ? $langs->trans('No') : $langs->trans('Yes')).'
'; $info .= 'dolibarr_mailing_limit_sendbyweb = '.$dolibarr_mailing_limit_sendbyweb.'
'; return $info; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 943b7c73fb3..aed02f40531 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -227,7 +227,7 @@ class EmailCollector extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index ed6942f34d6..604ed6a2d11 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -170,7 +170,7 @@ class EmailCollectorAction extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index cb8db05fa34..217416cbe89 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -139,7 +139,7 @@ class EmailCollectorFilter extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/index.php b/htdocs/index.php index ebc343b5e8d..952ff525258 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -68,7 +68,7 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis * View */ -if (!is_object($form)) $form = new Form($db); +if (!isset($form) || !is_object($form)) $form = new Form($db); // Title $title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 77958deca5f..4f1266c0afd 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1566,6 +1566,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead */ if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { + if (!isset($form) || !is_object($form)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + } + print "\n".''."\n"; print '
'; // dol_invisible_topmenu differs from dol_hide_topmenu: dol_invisible_topmenu means we output menu but we make it invisible. @@ -1632,7 +1637,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); } // Link to print main content area @@ -1651,7 +1656,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2); } // Link to Dolibarr wiki pages @@ -1688,7 +1693,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $text .= '">'; $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); } // Version @@ -1700,11 +1705,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $text = ''.DOL_VERSION.''; - $toprightmenu .= @Form::textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); } // Logout link - $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem logout-btn', 2); + $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem logout-btn', 2); $toprightmenu .= '
'; // end div class="login_block_other" @@ -1747,7 +1752,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead print "\n\n"; } - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 2c03c3dd2a9..dd802953c2d 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -254,7 +254,7 @@ class MyObject extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 4e21ea4f46c..db532d7412c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -445,7 +445,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cf4b4ccddd1..cfc34f4a637 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -223,7 +223,7 @@ class Mo extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { @@ -1436,7 +1436,7 @@ class MoLine extends CommonObjectLine { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 7734e992d48..3303c2a92b4 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -392,7 +392,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 5a19906d088..879a6196450 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -371,7 +371,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 57051393893..33923985d9a 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -419,7 +419,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 95123b7c873..e03de931a58 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -377,7 +377,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index df96744526b..5f3b1d076c6 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -222,7 +222,7 @@ class RecruitmentCandidature extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index ffe2a1373e8..0be2cfbc310 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -236,7 +236,7 @@ class RecruitmentJobPosition extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 1354dd9611f..7442523b7d3 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -433,7 +433,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 03f558b3d4a..cfc237af267 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -433,7 +433,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3fcc7e610ac..27d99cb778d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1509,8 +1509,10 @@ class Societe extends CommonObject $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; - $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; + $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; + $sql .= ', s.fk_account, s.tva_assuj'; + $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mod_supplier'; + $sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; $sql .= ', s.order_min_amount, s.supplier_order_min_amount'; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 7b456e70f02..cd5afe018f2 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -663,7 +663,7 @@ foreach ($object->fields as $key => $val) print ''; } else { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; From 5504e3b2366df7067ebb766a5c509a6e1f4b3660 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 05:58:40 +0100 Subject: [PATCH 079/247] Fix phpcs --- htdocs/core/tpl/advtarget.tpl.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index f2378ce5e4f..21bc9928af2 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -482,7 +482,6 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { print '' . $extrafields->attributes[$elementtype]['label'][$key]; if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } print ''; if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { From 412077ab51c19ca14849d174b5b180edac33beba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 08:24:02 +0100 Subject: [PATCH 080/247] doxygen --- htdocs/api/class/api.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5987ddfea66..895a0e2dc60 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2020 Frédéric France * * 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 @@ -91,8 +92,8 @@ class DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From 61cb99117a09c898b5e8ed3fbbc070db88974e0d Mon Sep 17 00:00:00 2001 From: ATM john Date: Fri, 30 Oct 2020 09:33:07 +0100 Subject: [PATCH 081/247] Add missing lang trans --- htdocs/langs/en_US/bills.lang | 3 +++ htdocs/langs/fr_FR/bills.lang | 3 +++ 2 files changed, 6 insertions(+) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index dccc80b1918..a4ac01774f3 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -572,3 +572,6 @@ MaxNumberOfGenerationReached=Max number of gen. reached BILL_DELETEInDolibarr=Invoice deleted BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted UnitPriceXQtyLessDiscount=Unit price x Qty - Discount +SituationTotalRayToRest=Remainder to pay without taxe +PDFSituationTitle=Situation n° %d +SituationTotalProgress=Total progress %d %% diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 5da6bda8133..696bbf2ac32 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -575,3 +575,6 @@ BILL_SUPPLIER_DELETEInDolibarr=Facture fournisseur supprimée UnitPriceXQtyLessDiscount=Prix unitaire x Qté - Remise CustomersInvoicesArea=Zone de facturation client SupplierInvoicesArea=Zone de facturation fournisseur +SituationTotalRayToRest=Reste à payer total HT +PDFSituationTitle=Situation n° %d +SituationTotalProgress=Total progression %d %% From 2668efa132dac44bd8ecbbc5fb19be18013a4e1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 12:44:29 +0100 Subject: [PATCH 082/247] Fix missing global --- htdocs/main.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4f1266c0afd..5dc9de05cd3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2704,6 +2704,7 @@ if (!function_exists("llxFooter")) global $conf, $db, $langs, $user, $mysoc, $object; global $delayedhtmlcontent; global $contextpage, $page, $limit; + global $dolibarr_distrib; $ext = 'layout='.$conf->browser->layout.'&version='.urlencode(DOL_VERSION); From cb3e2042818b6e4927276ef252eef741fdecf89e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 13:06:55 +0100 Subject: [PATCH 083/247] Fix use of dolibarr_main_distrib --- build/debian/conf.php.install | 4 ++-- build/debian/install.forced.php.install | 1 + build/exe/doliwamp/install.forced.php.install | 1 + build/rpm/install.forced.php.fedora | 1 + build/rpm/install.forced.php.generic | 1 + build/rpm/install.forced.php.mandriva | 1 + build/rpm/install.forced.php.opensuse | 1 + htdocs/install/step1.php | 13 ++++++++++++- 8 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build/debian/conf.php.install b/build/debian/conf.php.install index 6741d7ea544..c373664deef 100644 --- a/build/debian/conf.php.install +++ b/build/debian/conf.php.install @@ -232,7 +232,7 @@ $dolibarr_main_prod='0'; # Examples: # $dolibarr_mailing_limit_sendbycli='0'; -# dolibarr_distrib +# dolibarr_main_distrib # A key to identify the distribution used for first installation -$dolibarr_distrib = 'deb'; +$dolibarr_main_distrib = 'debian'; diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index e55ffae138e..0cb02c2342d 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -24,6 +24,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='debian'; // Value to overwrite path to use shared libraries/fonts instead of embedded one. // If during install, we enable/disable declaration to use non embedded libraries, we must also check they are diff --git a/build/exe/doliwamp/install.forced.php.install b/build/exe/doliwamp/install.forced.php.install index c59b373a7a0..8947154a57b 100644 --- a/build/exe/doliwamp/install.forced.php.install +++ b/build/exe/doliwamp/install.forced.php.install @@ -22,6 +22,7 @@ $force_install_databaserootpass='WAMPMYSQLNEWPASSWORD'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='644'; +$force_install_distrib='doliwamp'; $force_install_module=''; ?> \ No newline at end of file diff --git a/build/rpm/install.forced.php.fedora b/build/rpm/install.forced.php.fedora index a8db3e25c9e..4d25010a533 100644 --- a/build/rpm/install.forced.php.fedora +++ b/build/rpm/install.forced.php.fedora @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmfedora'; // Value to overwrite path to use shared libraries/fonts instead of embedded one $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/build/rpm/install.forced.php.generic b/build/rpm/install.forced.php.generic index 107ef533310..20ec33a1af0 100644 --- a/build/rpm/install.forced.php.generic +++ b/build/rpm/install.forced.php.generic @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmgeneric'; // Value to overwrite path to use shared libraries/fonts instead of embedded one // We don't force any external lib with generic package diff --git a/build/rpm/install.forced.php.mandriva b/build/rpm/install.forced.php.mandriva index 927877b59d0..835f5f45570 100644 --- a/build/rpm/install.forced.php.mandriva +++ b/build/rpm/install.forced.php.mandriva @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmmandriva'; // Value to overwrite path to use shared libraries/fonts instead of embedded one $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/build/rpm/install.forced.php.opensuse b/build/rpm/install.forced.php.opensuse index c91836918f4..b3cab5a0e4d 100644 --- a/build/rpm/install.forced.php.opensuse +++ b/build/rpm/install.forced.php.opensuse @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmopensuse'; // Value to overwrite path to use shared libraries/fonts instead of embedded one //$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 9d0d0a99038..32ba435d3c6 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -64,6 +64,8 @@ $main_use_alt_dir = ((GETPOST("main_use_alt_dir", 'alpha') == '' || (GETPOST("ma // Alternative root directory name $main_alt_dir_name = ((GETPOST("main_alt_dir_name", 'alpha') && GETPOST("main_alt_dir_name", 'alpha') != '') ? GETPOST("main_alt_dir_name", 'alpha') : 'custom'); +$dolibarr_main_distrib = 'standard'; + session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) // Save a flag to tell to restore input value if we go back @@ -127,6 +129,10 @@ if (@file_exists($forcedfile)) { $main_force_https = $force_install_mainforcehttps; } } + + if (!empty($force_install_distrib)) { + $dolibarr_main_distrib = $force_install_distrib; + } } @@ -833,6 +839,7 @@ function write_conf_file($conffile) global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host; global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass; global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication; + global $dolibarr_main_distrib; global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation; global $conffile, $conffiletoshow, $conffiletoshowshort; global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH; @@ -900,7 +907,7 @@ function write_conf_file($conffile) fputs($fp, '$dolibarr_main_db_collation=\''.str_replace("'", "\'", trim($db_collation)).'\';'); fputs($fp, "\n"); - /* Authentication */ + // Authentication fputs($fp, '// Authentication settings'); fputs($fp, "\n"); @@ -980,6 +987,10 @@ function write_conf_file($conffile) fputs($fp, "\n"); if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) { fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = ''; } fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';'); + fputs($fp, "\n"); + + // Other + fputs($fp, '$dolibarr_main_distrib=\''.str_replace("'", "\'", trim($dolibarr_main_distrib)).'\';'); fputs($fp, "\n"); fclose($fp); From e5c683ebb75f45456566366e3fd26f9c175625bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 14:29:41 +0100 Subject: [PATCH 084/247] Comment --- htdocs/modulebuilder/template/myobject_card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 04ea8b40d07..95dfa551ff3 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -139,6 +139,7 @@ if (empty($reshook)) else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); } } + $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen From 64b9afc5091ae8bd03b1b72dc882417275bf8612 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 14:33:16 +0100 Subject: [PATCH 085/247] Fix bad column name --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 27d99cb778d..7946a032423 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1511,7 +1511,7 @@ class Societe extends CommonObject $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; $sql .= ', s.fk_account, s.tva_assuj'; - $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mod_supplier'; + $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mode_supplier'; $sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; From d9ca9fe22d55a6013346739d009c31178b108c0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 14:50:38 +0100 Subject: [PATCH 086/247] Fix clean of contract --- htdocs/contrat/class/contrat.class.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9787802691e..8390fda0c28 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1237,8 +1237,8 @@ class Contrat extends CommonObject } } - if (!$error) - { + // Delete lines + if (!$error) { // Delete contratdet extrafields $main = MAIN_DB_PREFIX . 'contratdet'; $ef = $main . "_extrafields"; @@ -1268,9 +1268,21 @@ class Contrat extends CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + + // Delete contract if (!$error) { - // Delete contrat $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; $sql .= " WHERE rowid=".$this->id; From 38c2fea8494091994f427d0458378f061e6e7e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 15:21:28 +0100 Subject: [PATCH 087/247] Update api_members.class.php --- htdocs/adherents/class/api_members.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 230b839f726..0e611ff80da 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -405,8 +405,8 @@ class Members extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From a317d714136312dc2815b136fdd34981f59e61a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 15:23:05 +0100 Subject: [PATCH 088/247] Update api_users.class.php --- htdocs/user/class/api_users.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 5245ff0b961..d2caa8c6300 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -585,8 +585,8 @@ class Users extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From 782e062ec747d3d14211241619ccae667edfe5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 15:24:29 +0100 Subject: [PATCH 089/247] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 9a572a7e06f..a180bafb2cb 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1771,8 +1771,8 @@ class Thirdparties extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From b431d9999652bddace3915d6a90384f0b40a28b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 16:10:23 +0100 Subject: [PATCH 090/247] Update api_memberstypes.class.php --- htdocs/adherents/class/api_memberstypes.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 682fb9d707c..0e65a25c551 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -261,8 +261,8 @@ class MembersTypes extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From 28adc985b0d881aaa5922d7f7d1e8bda186aaca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 17:31:57 +0100 Subject: [PATCH 091/247] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 8e632fa0032..4516d2e1d45 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2017 Neil Orley - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018-2020 Thibault FOUCART * * @@ -525,8 +525,8 @@ class Setup extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From 406cb5a2c9e75729c1de49733d088364c6d79298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 17:49:16 +0100 Subject: [PATCH 092/247] Update api_boms.class.php --- htdocs/bom/class/api_boms.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index b9123b8c226..3509d8195d0 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -270,8 +270,8 @@ class Boms extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From 3cefb5f3366bd0b604ea7c505bba1fe3ab1ea1b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 17:59:33 +0100 Subject: [PATCH 093/247] Update listbyaccount.php --- htdocs/accountancy/bookkeeping/listbyaccount.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 5a197b2cc7d..7c6d6719235 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -376,14 +376,17 @@ print ''; print ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); + +$newcardbutton .= '   '; -$newcardbutton = dolGetButtonTitle($langs->trans('ViewSubAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields From 8190711342b4893f71661c69b59f9bb8c9c9df12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 18:01:01 +0100 Subject: [PATCH 094/247] doxygen --- htdocs/categories/class/api_categories.class.php | 2 +- htdocs/comm/action/class/api_agendaevents.class.php | 4 ++-- htdocs/comm/propal/class/api_proposals.class.php | 4 ++-- htdocs/commande/class/api_orders.class.php | 4 ++-- htdocs/compta/bank/class/api_bankaccounts.class.php | 4 ++-- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- htdocs/contrat/class/api_contracts.class.php | 4 ++-- .../interface_99_modZapier_ZapierTriggers.class.php | 6 +++--- htdocs/don/class/api_donations.class.php | 4 ++-- htdocs/expedition/class/api_shipments.class.php | 4 ++-- htdocs/expensereport/class/api_expensereports.class.php | 4 ++-- htdocs/fichinter/class/api_interventions.class.php | 4 ++-- htdocs/fourn/class/api_supplier_invoices.class.php | 4 ++-- htdocs/fourn/class/api_supplier_orders.class.php | 4 ++-- htdocs/modulebuilder/template/class/api_mymodule.class.php | 4 ++-- htdocs/mrp/class/api_mos.class.php | 4 ++-- htdocs/product/class/api_products.class.php | 4 ++-- htdocs/product/stock/class/api_stockmovements.class.php | 4 ++-- htdocs/product/stock/class/api_warehouses.class.php | 4 ++-- htdocs/projet/class/api_projects.class.php | 4 ++-- htdocs/projet/class/api_tasks.class.php | 4 ++-- htdocs/societe/class/api_contacts.class.php | 2 +- htdocs/societe/class/api_thirdparties.class.php | 4 ++-- .../class/api_supplier_proposals.class.php | 4 ++-- htdocs/ticket/class/api_tickets.class.php | 4 ++-- htdocs/zapier/class/api_zapier.class.php | 4 ++-- 26 files changed, 51 insertions(+), 51 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5f0a28340f9..e182a91d32a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -658,7 +658,7 @@ class Categories extends DolibarrApi * Clean sensible object datas * * @param Categorie $object Object to clean - * @return array Array of cleaned object properties + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 473c87e22a0..9651077df0c 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -327,8 +327,8 @@ class AgendaEvents extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index f2275d59021..61831e1e1b4 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -846,8 +846,8 @@ class Proposals extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index b9fbe8a6c1d..25796c057ed 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -950,8 +950,8 @@ class Orders extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 3293f746033..9c92eed8e70 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -391,8 +391,8 @@ class BankAccounts extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 85ad01ab7a6..9cbede6fbb7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1643,8 +1643,8 @@ class Invoices extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index b5a9bd91cf4..910ca3b621f 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -633,8 +633,8 @@ class Contracts extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php index 95595863cb3..c9adc0d03d6 100644 --- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php +++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php @@ -368,8 +368,8 @@ function zapierPostWebhook($url, $json) /** * Clean sensible object datas * - * @param object $toclean Object to clean - * @return array Array of cleaned object properties + * @param Object $toclean Object to clean + * @return Object Object with cleaned properties */ function cleanObjectDatas($toclean) { @@ -454,7 +454,7 @@ function cleanObjectDatas($toclean) * Clean sensible object datas * * @param object $toclean Object to clean - * @return array Array of cleaned object properties + * @return Object Object with cleaned properties */ function cleanAgendaEventsDatas($toclean) { diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 2d61241c738..73613863e31 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -327,8 +327,8 @@ class Donations extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 1f85ade883b..f5d9a7cdedb 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -610,8 +610,8 @@ class Shipments extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 405ba52be93..f18f6614ce4 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -494,8 +494,8 @@ class ExpenseReports extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index c2328e5cfd3..c4682d555ce 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -420,8 +420,8 @@ class Interventions extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 8c3ca0108e3..36bcbd76aa7 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -677,8 +677,8 @@ class SupplierInvoices extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 0fd06790011..f1f9563cce3 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -339,8 +339,8 @@ class SupplierOrders extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 32113b71ef0..da1b243979f 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -290,8 +290,8 @@ class MyModuleApi extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index d502e5cc99d..7eecaac860a 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -270,8 +270,8 @@ class Mos extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6c75d96fe89..86be8d8f5d9 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1740,8 +1740,8 @@ class Products extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 71f687a1b03..be183e6451f 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -276,8 +276,8 @@ class StockMovements extends DolibarrApi /** * Clean sensible object datas * - * @param MouvementStock $object Object to clean - * @return array Array of cleaned object properties + * @param MouvementStock $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 1c31bbbc2af..933e8be66c9 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -255,8 +255,8 @@ class Warehouses extends DolibarrApi /** * Clean sensible object datas * - * @param Entrepot $object Object to clean - * @return array Array of cleaned object properties + * @param Entrepot $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 214cbe96154..f060f56e615 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -542,8 +542,8 @@ class Projects extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 5181beb3707..707e14a2c44 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -550,8 +550,8 @@ class Tasks extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index d5280ee80dd..bcebc4ad22b 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -519,7 +519,7 @@ class Contacts extends DolibarrApi * Clean sensible object datas * * @param Object $object Object to clean - * @return array Array of cleaned object properties + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 9a572a7e06f..98c8f657713 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1771,8 +1771,8 @@ class Thirdparties extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index ba2fa37e1b9..156dd66e5f6 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -193,8 +193,8 @@ class Supplierproposals extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 4a3c9b66203..a26a01e1a98 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -487,8 +487,8 @@ class Tickets extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties * * @todo use an array for properties to clean * diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 5ad97434d07..6118aa71241 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -335,8 +335,8 @@ class ZapierApi extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ public function _cleanObjectDatas($object) { From 23d0d4635a21ff9afacf1064d74e19473c650573 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 18:16:19 +0100 Subject: [PATCH 095/247] Trans --- htdocs/langs/en_US/accountancy.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 24255577b11..1d75fa153e8 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -118,6 +118,7 @@ UpdateMvts=Modification of a transaction ValidTransaction=Validate transaction WriteBookKeeping=Register transactions in accounting Bookkeeping=Ledger +BookkeepingSubAccount=Subledger AccountBalance=Account balance ObjectsRef=Source object ref CAHTF=Total purchase vendor before tax From aafac6f98946947e229b47a9adecdf8a3d06d481 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 18:58:40 +0100 Subject: [PATCH 096/247] Fix box of events --- htdocs/core/boxes/box_actions.php | 38 +++++++++++++++++------------ htdocs/core/boxes/modules_boxes.php | 3 ++- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index a951402fd7b..eeebb520ab1 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -42,7 +42,7 @@ class box_actions extends ModeleBoxes */ public $db; - public $param; + public $enabled = 1; public $info_box_head = array(); public $info_box_contents = array(); @@ -54,12 +54,14 @@ class box_actions extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - public function __construct($db, $param = '') + public function __construct($db, $param) { - global $user; + global $conf, $user; $this->db = $db; + $this->enabled = $conf->agenda->enabled; + $this->hidden = !($user->rights->agenda->myactions->read); } @@ -93,7 +95,7 @@ class box_actions extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE a.fk_action = ta.id"; - $sql .= " AND a.entity = ".$conf->entity; + $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; $sql .= " AND a.percent >= 0 AND a.percent < 100"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; @@ -101,13 +103,14 @@ class box_actions extends ModeleBoxes $sql .= " ORDER BY a.datec DESC"; $sql .= $this->db->plimit($max, 0); - dol_syslog("Box_actions::loadBox", LOG_DEBUG); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $num = $this->db->num_rows($result); + $line = 0; while ($line < $num) { $late = ''; @@ -127,32 +130,35 @@ class box_actions extends ModeleBoxes //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label = empty($objp->label) ? $objp->type_label : $objp->label; - $this->info_box_contents[$line][] = array( + $this->info_box_contents[$line][0] = array( 'td' => '', 'text' => $actionstatic->getNomUrl(1), 'text2'=> $late, - 'asis' => 1, + 'asis' => 1 ); - $this->info_box_contents[$line][] = array( + $this->info_box_contents[$line][1] = array( 'td' => '', 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), - 'asis' => 1, + 'asis' => 1 ); - $this->info_box_contents[$line][] = array( + $this->info_box_contents[$line][2] = array( 'td' => 'class="nowrap left"', 'text' => dol_print_date($datelimite, "dayhour"), + 'asis' => 1 ); - $this->info_box_contents[$line][] = array( + $this->info_box_contents[$line][3] = array( 'td' => 'class="right"', 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), + 'asis' => 1 ); - $this->info_box_contents[$line][] = array( + $this->info_box_contents[$line][4] = array( 'td' => 'class="right" width="18"', 'text' => $actionstatic->LibStatut($objp->percentage, 3), + 'asis' => 1 ); $line++; @@ -160,8 +166,8 @@ class box_actions extends ModeleBoxes if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoActionsToDo"), + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoActionsToDo") ); $this->db->free($result); @@ -169,7 +175,7 @@ class box_actions extends ModeleBoxes $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql) ); } } else { @@ -191,7 +197,7 @@ class box_actions extends ModeleBoxes public function showBox($head = null, $contents = null, $nooutput = 0) { global $langs, $conf; - $out = parent::showBox($this->info_box_head, $this->info_box_contents); + $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1); if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) { diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index fd179dec7b6..d68d8b4dc3b 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -458,6 +458,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box { // Define disabledbyname and disabledbymodule $disabledbyname = 0; + $disabledbymodule = 0; // TODO Set to 2 if module is not enabled $module = ''; // Check if widget file is disabled by name @@ -476,7 +477,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box $text = ''.$langs->trans("Description").':
'; $text .= $objMod->boxlabel.'
'; $text .= '
'.$langs->trans("Status").':
'; - if ($disabledbymodule == 2) $text .= $langs->trans("HooksDisabledAsModuleDisabled", $module).'
'; + if ($disabledbymodule == 2) $text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'
'; $widget[$j]['info'] = $text; } From 460af5813490270ef04697b1f01d7e626ea38689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 30 Oct 2020 22:09:15 +0100 Subject: [PATCH 097/247] typo --- htdocs/api/class/api_documents.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 70cdeb14ade..fa570caed77 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -474,15 +474,13 @@ class Documents extends DolibarrApi } $upload_dir = $conf->categorie->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/".dol_sanitizeFileName($object->ref); - } - else - { + } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { - throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); + throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); } return $filearray; From 44f532e1da7f58dfccd05cce75472a9a11489847 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 03:50:16 +0100 Subject: [PATCH 098/247] Fix look and feel v13 --- htdocs/comm/action/index.php | 40 ++++++++++++++++-------------- htdocs/core/js/lib_head.js.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 2 ++ htdocs/website/index.php | 3 ++- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e62f411d786..79c1eb41cea 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1265,7 +1265,7 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days before the beginning of the current month (previous month) */ $style = 'cal_other_month cal_past'; if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo ' '; + echo ' '; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " \n"; } elseif ($tmpday <= $max_day_in_month) { @@ -1278,14 +1278,14 @@ if (empty($action) || $action == 'show_month') // View by month if ($today) $style = 'cal_today'; if ($curtime < $todaytms) $style .= ' cal_past'; //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); - echo ' '; + echo ' '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo " \n"; + echo "\n"; } else { /* Show days after the current month (next month) */ $style = 'cal_other_month'; if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo ' '; + echo ' '; show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo "\n"; } @@ -1477,28 +1477,30 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print "\n"; - // Line with title of day $curtime = dol_mktime(0, 0, 0, $month, $day, $year); - print '
'."\n"; + $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; + $urltocreate = ''; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + $hourminsec = '100000'; + $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); + } + + // Line with title of day + print '
'."\n"; if ($nonew <= 0) { - print '
'; - print ''; + print '
'; + print '
'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; - - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - print ''; + print ''; // Explicit link, usefull for nojs interfaces print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; } @@ -1838,7 +1840,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa break; } } - if (!$i) print ' '; + if (!$i) { // No events + print ' '; + } if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index b71dfc3eeb2..9bd9227fffa 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1135,7 +1135,7 @@ $(document).ready(function() { if (window.location !== window.parent.location ) { console.log("Page is detected to be into an iframe, we hide by CSS the menus"); // The page is in an iframe - jQuery(".side-nav-vert, .side-nav").hide(); + jQuery(".side-nav-vert, .side-nav, .websitebar").hide(); jQuery(".id-container").css('width', '100%'); } diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index b037cfdc851..3109083b451 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -214,6 +214,8 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { text-transform: uppercase; font-weight: bold; margin-bottom: 3px; /* not too much space so we can add another lines */ + opacity: 1; + color: var(--colortexttitlenotab); } .info-box-text{ font-size: 0.92em; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index dc3407b8f21..32ced5dc2dd 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2406,7 +2406,8 @@ if (!GETPOST('hide_websitemenu')) if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { print ''; - print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("MediaFiles")).'">'; + //print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("MediaFiles")).'">'; + print dolButtonToOpenUrlInDialogPopup('file_manager', $langs->transnoentitiesnoconv("MediaFiles"), '', '/website/index.php?action=file_manager&website='.$website->ref, $disabled); if (! empty($conf->categorie->enabled)) { //print ''; From 0a9c7fc577e9b7ed8c30f0b694c10b7fec6f3ce4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 04:19:22 +0100 Subject: [PATCH 099/247] Look and feel v13 --- htdocs/core/lib/admin.lib.php | 34 ++++++++++++++++++++++++++++------ htdocs/install/upgrade.php | 10 +++++----- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 49ababf4a25..ac95b6062a8 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -296,8 +296,8 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql); - // Ajout trace sur requete (eventuellement a commenter si beaucoup de requetes) - if (!$silent) print ''.$langs->trans("Request").' '.($i + 1)." sql='".dol_htmlentities($newsql, ENT_NOQUOTES)."'\n"; + // Add log of request + if (!$silent) print ''.$langs->trans("Request").' '.($i + 1)." sql='".dol_htmlentities($newsql, ENT_NOQUOTES)."'\n"; dol_syslog('Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG); $sqlmodified = 0; @@ -404,12 +404,34 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($error == 0) { - if (!$silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (!$silent) print ''.$langs->trans("OK").''."\n"; + if (!$silent) { + print ''.$langs->trans("ProcessMigrateScript").''; + print ''.$langs->trans("OK"); + //if (! empty($conf->use_javascript_ajax)) { + print ''; + print ' - '.$langs->trans("ShowHideDetails").''; + //} + print ''."\n"; + } $ok = 1; } else { - if (!$silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (!$silent) print ''.$langs->trans("KO").''."\n"; + if (!$silent) { + print ''.$langs->trans("ProcessMigrateScript").''; + print ''.$langs->trans("KO").''; + print ''."\n"; + } $ok = 0; } diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index af05fb374d2..5545c4a3bcf 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -146,11 +146,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->connected) { print ''; - print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK")."\n"; + print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->transnoentities("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->transnoentities("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -160,11 +160,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->database_selected) { print ''; - print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK")."\n"; + print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->trans("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -354,7 +354,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ { if (in_array($dir.$file, $listoffileprocessed)) continue; - print '
'; + print '
'; print ''.$langs->trans("ChoosedMigrateScript").''.$file.''."\n"; // Run sql script diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e47390b9ce0..7c583329ef0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -80,6 +80,7 @@ AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a JavascriptDisabled=JavaScript disabled UsePreviewTabs=Use preview tabs ShowPreview=Show preview +ShowHideDetails=Show-Hide details PreviewNotAvailable=Preview not available ThemeCurrentlyActive=Theme currently active CurrentTimeZone=TimeZone PHP (server) From f7172a9a3c657aee84add6df8af22e32557e41d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 04:50:26 +0100 Subject: [PATCH 100/247] css --- htdocs/theme/eldy/info-box.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 3109083b451..1bb6ae7c67e 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -214,8 +214,8 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { text-transform: uppercase; font-weight: bold; margin-bottom: 3px; /* not too much space so we can add another lines */ - opacity: 1; - color: var(--colortexttitlenotab); + opacity: 0.6; + /* color: var(--colortexttitlenotab); */ } .info-box-text{ font-size: 0.92em; From 9b10de3a8c9847704cdeead048b31725372e4d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:22:02 +0100 Subject: [PATCH 101/247] Update api_boms.class.php public function update(User $user, $notrigger = false) --- htdocs/bom/class/api_boms.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 3509d8195d0..d0e2e12ec0c 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2020 Frédéric France * * 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 @@ -131,8 +132,7 @@ class Boms extends DolibarrApi } if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -224,8 +224,7 @@ class Boms extends DolibarrApi $this->bom->$field = $value; } - if ($this->bom->update($id, DolibarrApiAccess::$user) > 0) - { + if ($this->bom->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { throw new RestException(500, $this->bom->error); From f1beca047168fe748597a7a67d97780d9850fa23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:27:58 +0100 Subject: [PATCH 102/247] fix undefined variable --- htdocs/contrat/class/api_contracts.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 910ca3b621f..3e9cfb908d8 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2018 Frédéric France +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2018-2020 Frédéric France * * 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 @@ -416,7 +416,7 @@ class Contracts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + // $request_data = (object) $request_data; $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); From c6433ef58b225b815b10d2bf98f9a10b8033b1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:32:00 +0100 Subject: [PATCH 103/247] fix undefined variable --- htdocs/expensereport/class/api_expensereports.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index f18f6614ce4..a294799a959 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2020 Frédéric France * * 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 @@ -111,8 +112,7 @@ class ExpenseReports extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -121,8 +121,7 @@ class ExpenseReports extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -136,6 +135,7 @@ class ExpenseReports extends DolibarrApi { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $this->db->fetch_object($result); From 21a933f15c87112da67c81f70188001d2b7e0c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:37:56 +0100 Subject: [PATCH 104/247] fix undefined variable --- htdocs/fourn/class/api_supplier_orders.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index f1f9563cce3..386d67ff7c7 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -108,18 +108,18 @@ class SupplierOrders extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if (!empty($product_ids)) $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; // We need this table joined to the select in order to filter by product $sql .= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; if (!empty($product_ids)) $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$product_ids.")"; if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale From a64e676dad0472f5f5eb72c702da8ef453f566e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:40:15 +0100 Subject: [PATCH 105/247] fix undefined variable --- htdocs/projet/class/api_projects.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index f060f56e615..a0875ee2001 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -146,8 +146,7 @@ class Projects extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -162,8 +161,8 @@ class Projects extends DolibarrApi { $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + $i = 0; + while ($i < $min) { $obj = $this->db->fetch_object($result); $project_static = new Project($this->db); if ($project_static->fetch($obj->rowid)) { From 25741a618ebc162af25ede4936b8087f580e85bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 09:50:50 +0100 Subject: [PATCH 106/247] fix result is a resource --- .../societe/class/api_thirdparties.class.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 3b38ebd8cc7..8dbac54eaff 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1374,7 +1374,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result) { - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { throw new RestException(404, 'Bank account not found'); } @@ -1443,7 +1443,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); } @@ -1514,7 +1514,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."'"; $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { $account = new SocieteAccount($this->db); if (!isset($request_data['login'])) { $account->login = ""; @@ -1570,7 +1570,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); } @@ -1595,7 +1595,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); - if ($result->num_rows !== 0) { + if ($result && $this->db->num_rows !== 0) { throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key."); } } @@ -1652,7 +1652,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { // If the user tries to edit the site member, we check first if @@ -1660,7 +1660,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); - if ($result->num_rows !== 0) + if ($result && $this->db->num_rows !== 0) throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); } @@ -1705,7 +1705,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '".$this->db->escape($site)."'"; $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { throw new RestException(404); } else { $obj = $this->db->fetch_object($result); @@ -1724,9 +1724,9 @@ class Thirdparties extends DolibarrApi * @param int $id ID of thirdparty * * @return void - * @throws RestException(401) Unauthorized: User does not have permission to delete thirdparties gateways - * @throws RestException(404) Not Found: Specified thirdparty ID does not belongs to an existing thirdparty - * @throws RestException(500) Internal Server Error: Error deleting SocieteAccount entity + * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties gateways + * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty + * @throws RestException 500 Internal Server Error: Error deleting SocieteAccount entity * * @url DELETE {id}/gateways */ @@ -1747,7 +1747,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($result && $this->db->num_rows == 0) { throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); } else { $i = 0; From 72c443868c235c31cb192c1202d277b6df4cd380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 11:57:35 +0100 Subject: [PATCH 107/247] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 8dbac54eaff..711a194d527 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1374,7 +1374,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result) { - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { throw new RestException(404, 'Bank account not found'); } @@ -1443,7 +1443,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); } @@ -1514,7 +1514,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."'"; $result = $this->db->query($sql); - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { $account = new SocieteAccount($this->db); if (!isset($request_data['login'])) { $account->login = ""; @@ -1595,7 +1595,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); - if ($result && $this->db->num_rows !== 0) { + if ($result && $this->db->num_rows($result) !== 0) { throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key."); } } @@ -1652,7 +1652,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $this->db->query($sql); - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { // If the user tries to edit the site member, we check first if @@ -1660,7 +1660,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); - if ($result && $this->db->num_rows !== 0) + if ($result && $this->db->num_rows($result) !== 0) throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); } @@ -1705,7 +1705,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '".$this->db->escape($site)."'"; $result = $this->db->query($sql); - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { throw new RestException(404); } else { $obj = $this->db->fetch_object($result); @@ -1747,7 +1747,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); } else { $i = 0; From fcb3245295d197cddae00093dd5e21522772db9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:11:41 +0100 Subject: [PATCH 108/247] Fix for #15016 --- htdocs/core/actions_linkedfiles.inc.php | 10 +++++++--- htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 75633c75585..3a8e37a6c2b 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -99,7 +99,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path - // Si elle existe, on efface la vignette + // If it exists, remove thumb. + $regs = array(); if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); @@ -120,8 +121,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } else { setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); } - } elseif ($linkid) // delete of external link - { + } elseif ($linkid) { // delete of external link require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($db); $link->fetch($linkid); @@ -179,6 +179,10 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents + // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because + // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + $filenameto = dol_string_nohtmltag($filenameto); + if ($filenamefrom != $filenameto) { // Security: diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1e0d298bb69..1ffb9121d8e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1562,7 +1562,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $destfile = dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because - // this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + // this function is also applied when we rename and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $destfile = dol_string_nohtmltag($destfile); $destfull = dol_string_nohtmltag($destfull); From a4d2927f82b01e70ba62da905d0a1b26bebffec8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:11:41 +0100 Subject: [PATCH 109/247] Fix for #15016 Conflicts: htdocs/core/actions_linkedfiles.inc.php --- htdocs/core/actions_linkedfiles.inc.php | 11 +++++++---- htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index a1b2c12e10b..8f90234f8ab 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -103,7 +103,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path - // Si elle existe, on efface la vignette + // If it exists, remove thumb. + $regs = array(); if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); @@ -124,9 +125,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } else { setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); } - } - elseif ($linkid) // delete of external link - { + } elseif ($linkid) { // delete of external link require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($db); $link->fetch($linkid); @@ -190,6 +189,10 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents + // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because + // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + $filenameto = dol_string_nohtmltag($filenameto); + if ($filenamefrom != $filenameto) { // Security: diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index eeac3566961..3fa1d083553 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1592,7 +1592,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $destfile = dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because - // this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + // this function is also applied when we rename and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $destfile = dol_string_nohtmltag($destfile); $destfull = dol_string_nohtmltag($destfull); From 623cb54480c68ad213ae6a128a03c4c278bf5441 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:30:47 +0100 Subject: [PATCH 110/247] Prepare a more complete fix for #15016 --- htdocs/core/lib/functions.lib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1a47d634299..d5ccf561e83 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5647,11 +5647,12 @@ function picto_required() * @param integer $removelinefeed 1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with \n, 2=Ending new lines are removed but others are kept with a same number of \n than nb of
when there is both "...
\n..." * @param string $pagecodeto Encoding of input/output string * @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag) + * @param integer $removedoublespace Replace double space into one space * @return string String cleaned * * @see dol_escape_htmltag() strip_tags() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags() */ -function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) +function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0, $removedoublespaces = 1) { if ($removelinefeed == 2) $stringtoclean = preg_replace('/]*>(\n|\r)+/ims', '
', $stringtoclean); $temp = preg_replace('/]*>/i', "\n", $stringtoclean); @@ -5669,13 +5670,14 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); - // Supprime aussi les retours + // Remove also backspaces if ($removelinefeed == 1) $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); - // et les espaces doubles - while (strpos($temp, " ")) - { - $temp = str_replace(" ", " ", $temp); + // And double quotes + if ($removedoublespaces) { + while (strpos($temp, " ")) { + $temp = str_replace(" ", " ", $temp); + } } return trim($temp); From df7218b6a47636b873e0ddcb33a37e66f7d5c4b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:39:14 +0100 Subject: [PATCH 111/247] Fix for multicompany --- htdocs/categories/class/categorie.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 086e14b27d0..d37bdfed04d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1415,11 +1415,12 @@ class Categorie extends CommonObject if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; - if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code - // Load bank groups + if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code after migration of llx_bank_categ into llx_categorie + // Load bank categories $sql = "SELECT c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " AND c.entity IN (".getEntity('category').")"; $sql .= " ORDER BY c.label"; $res = $this->db->query($sql); From 8d6fa350b983436d28fdc9bbb235e32aa88185f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:41:26 +0100 Subject: [PATCH 112/247] Clean code --- htdocs/admin/fckeditor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 4c1e495939a..22f0be20bd5 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -216,9 +216,8 @@ if (empty($conf->use_javascript_ajax)) print ''."\n"; // Add env of ckeditor - // This is to show how CKEditor detect browser to understand why editor is disabled or not - if (1 == 2) // Change this to enable output - { + // This is to show how CKEditor detect browser to understand why editor is disabled or not. To help debug. + /* print '
'; } + */ } // End of page From cea61d3b52adfa6d47dc9b5f48673fdadec021cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:44:14 +0100 Subject: [PATCH 113/247] Fix var --- htdocs/core/class/emailsenderprofile.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 7cf18ae4801..2eaf5f744bd 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -127,8 +127,7 @@ class EmailSenderProfile extends CommonObject public $tms; - //public $fk_user_creat; - //public $fk_user_modif; + public $private; public $signature; public $position; public $active; From 9113ecedfad12a3e54a8c58a5cfc10bc02f64bc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:55:26 +0100 Subject: [PATCH 114/247] code comment --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d5ccf561e83..62b88e53859 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5670,7 +5670,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); - // Remove also backspaces + // Remove also carriage returns if ($removelinefeed == 1) $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); // And double quotes From f485ebc2cf07821764198dbd322cf6b9a9f3355f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 12:56:30 +0100 Subject: [PATCH 115/247] Removed dead code --- .../adherents/class/adherent_type.class.php | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 94bf34208ff..e31d1e8fbc7 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -707,7 +707,7 @@ class AdherentType extends CommonObject */ public function initAsSpecimen() { - global $conf, $user, $langs; + global $user; // Initialise parametres $this->id = 0; @@ -735,46 +735,10 @@ class AdherentType extends CommonObject */ public function getMailOnValid() { - global $conf; - if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) { return $this->mail_valid; } return ''; } - - /** - * getMailOnSubscription - * - * @return string Return mail content of type or empty - */ - public function getMailOnSubscription() - { - global $conf; - - // mail_subscription not defined so never used - if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined - return $this->mail_subscription; - } - - return ''; - } - - /** - * getMailOnResiliate - * - * @return string Return mail model content of type or empty - */ - public function getMailOnResiliate() - { - global $conf; - - // NOTE mail_resiliate not defined so never used - if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined - return $this->mail_resiliate; - } - - return ''; - } } From ae351a565979a1a5b4b39e00dd7b881a77fdb4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:13:55 +0100 Subject: [PATCH 116/247] doxygen --- htdocs/societe/class/societe.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7946a032423..f98e49b05e6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -501,7 +501,9 @@ class Societe extends CommonObject */ public $user_creation; - + /** + * @var int 1 if object is specimen + */ public $specimen; /** From 499069ae512701ca293db27b2b8e867710307567 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 13:19:00 +0100 Subject: [PATCH 117/247] Fix position of fields in MO list --- htdocs/mrp/mo_movements.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 4a01c39f854..2a1a2ba51cc 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -105,21 +105,21 @@ $objectlist = new MouvementStock($db); // Definition of fields for list $arrayfields = array( - 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), - 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), - 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1), - 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), - 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), - 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), - 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), - 'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0), - 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), - 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'enabled'=>0, 'checked'=>0), + 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>1), + 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1, 'position'=>2), + 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100', 'position'=>10), + 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1, 'position'=>15), + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>20), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>21), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>22), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'position'=>30), + 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0, 'position'=>40), + 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1, 'position'=>42), + 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1, 'position'=>45), + 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1, 'position'=>48), + 'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0, 'position'=>50), + 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1, 'position'=>60), + 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'enabled'=>0, 'checked'=>0, 'position'=>62), //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); From c4a7e58435dfcc8ce2798392732e95630ff6909d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:22:04 +0100 Subject: [PATCH 118/247] Update societe.class.php --- htdocs/societe/class/societe.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f98e49b05e6..e1cfd822b79 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -501,11 +501,6 @@ class Societe extends CommonObject */ public $user_creation; - /** - * @var int 1 if object is specimen - */ - public $specimen; - /** * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int From 85b3b5de36a9b37d84f84a7e197c8f1d35e9dfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:24:09 +0100 Subject: [PATCH 119/247] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ef062b8acaf..c92eadd206c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2019 Nicolas ZABOURI * Copyright (C) 2017 Rui Strecht - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -334,6 +334,12 @@ abstract class CommonObject */ public $last_main_doc; + /** + * @var int Bank account ID + * @see $fk_account + */ + public $fk_bank; + /** * @var int Bank account ID * @see SetBankAccount() @@ -437,6 +443,11 @@ abstract class CommonObject public $next_prev_filter; + /** + * @var int 1 if object is specimen + */ + public $specimen = 0; + /** * @var array List of child tables. To test if we can delete object. */ From 7b6bc3de630c454f56964a8271ba4e88697b7f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:25:19 +0100 Subject: [PATCH 120/247] Update propal.class.php --- htdocs/comm/propal/class/propal.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2e02323c090..e5176cebdde 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -214,8 +214,6 @@ class Propal extends CommonObject public $labelStatus = array(); public $labelStatusShort = array(); - public $specimen; - // Multicurrency /** * @var int ID From 8daf0c168cd17975681fc9fe2b8afdcc15967697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:27:29 +0100 Subject: [PATCH 121/247] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 16309d31658..6abbab2acff 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -95,6 +95,9 @@ class Facture extends CommonInvoice */ protected $table_ref_field = 'ref'; + /** + * @var int thirdparty ID + */ public $socid; public $author; @@ -111,6 +114,10 @@ class Facture extends CommonInvoice public $date; // Date invoice public $datem; + + /** + * @var string customer ref + */ public $ref_client; /** @@ -169,7 +176,6 @@ class Facture extends CommonInvoice public $line; public $extraparams = array(); - public $specimen; public $fac_rec; From d122238439562fe3a8a2a12afb80e27fa7ab949c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:29:08 +0100 Subject: [PATCH 122/247] Update supplier_proposal.class.php --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bb8387c55e3..56d872126df 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2020 Frédéric France * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify @@ -177,8 +177,6 @@ class SupplierProposal extends CommonObject public $nbtodo; public $nbtodolate; - public $specimen; - // Multicurrency /** * @var int ID From 2b09b7be8e3037acc3b53750dea51c4eb5351471 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 13:47:50 +0100 Subject: [PATCH 123/247] Fix css --- htdocs/core/class/commonobject.class.php | 3 ++- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/class/mo.class.php | 4 ++-- htdocs/mrp/mo_list.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ef062b8acaf..9de8f5470de 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6306,7 +6306,8 @@ abstract class CommonObject $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' $param_list_array = explode(':', $param_list[0]); $showempty = (($required && $default != '') ? 0 : 1); - if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button + + if (!preg_match('/search_/', $keyprefix) && !empty($param_list_array[2])) { // If the entry into $fields is set to add a create button $morecss .= ' widthcentpercentminusx'; } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index db532d7412c..3d45026de10 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -447,7 +447,7 @@ foreach ($object->fields as $key => $val) print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cfc34f4a637..2509d3a1b25 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -102,12 +102,12 @@ class Mo extends CommonObject 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth300'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>51, 'notnull'=>-1, 'index'=>1,), - 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'css'=>'maxwidth300'), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>1, 'position'=>52, 'css'=>'maxwidth300'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), - 'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>2, 'position'=>502,), + 'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 3303c2a92b4..49a8fa87dd1 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -394,7 +394,7 @@ foreach ($object->fields as $key => $val) print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; } From 24df254e927265003ce80284d5305e7cbb306d56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 13:54:23 +0100 Subject: [PATCH 124/247] Update multicurrency.class.php --- htdocs/multicurrency/class/multicurrency.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index a09607ef1c4..2c2691f1ab8 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -866,11 +866,9 @@ class CurrencyRate extends CommonObjectLine // Update request $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= ' rate='.$this->rate; - if (!empty($this->date_sync)) - $sql .= ', date_sync=\''.$this->date_sync.'\''; - if (!empty($this->fk_multicurrency)) - $sql .= ', fk_multicurrency='.$this->fk_multicurrency; - $sql .= ' WHERE rowid=' . $this->id; + if (!empty($this->date_sync)) $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; + if (!empty($this->fk_multicurrency)) $sql .= ', fk_multicurrency='.$this->fk_multicurrency; + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); From ffb8c91dc495b0d319e04bd821dc52c6ad192fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:58:07 +0100 Subject: [PATCH 125/247] doxygen --- htdocs/asset/class/asset.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 05782b8ec67..25cac778264 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -130,9 +130,6 @@ class Asset extends CommonObject */ public $description; - public $note_public; - public $note_private; - /** * @var integer|string date_creation */ @@ -151,6 +148,9 @@ class Asset extends CommonObject */ public $fk_user_modif; + /** + * @var string import key + */ public $import_key; /** From 78b94c775b842abbefd2c1cbf7649faf1b547e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 13:59:46 +0100 Subject: [PATCH 126/247] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a5b6e0b84de..6befae46f64 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -336,6 +336,7 @@ abstract class CommonObject /** * @var int Bank account ID + * @deprecated * @see $fk_account */ public $fk_bank; From 80efdcf260d5091e7776fdeb18c58fc83f56628a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 14:24:00 +0100 Subject: [PATCH 127/247] Debug multicurrency editor --- .../class/multicurrency.class.php | 30 ++++--- htdocs/multicurrency/multicurrency_rate.php | 79 +++++++++---------- 2 files changed, 53 insertions(+), 56 deletions(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 190efb0da48..ec4b55f39dc 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -687,6 +687,7 @@ class MultiCurrency extends CommonObject } } + /** * Class CurrencyRate */ @@ -727,6 +728,7 @@ class CurrencyRate extends CommonObjectLine */ public $entity; + /** * Constructor * @@ -744,8 +746,7 @@ class CurrencyRate extends CommonObjectLine * * @param int $fk_multicurrency Id of currency * @param bool $trigger true=launch triggers after, false=disable triggers - * - * @return int <0 if KO, Id of created object if OK + * @return int <0 if KO, Id of created object if OK */ public function create($fk_multicurrency, $trigger = true) { @@ -756,7 +757,7 @@ class CurrencyRate extends CommonObjectLine $error = 0; $this->rate = price2num($this->rate); if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; - $now = !empty($this->date_sync) ? $this->date_sync : date('Y-m-d H:i:s'); + $now = empty($this->date_sync) ? dol_now() : $this->date_sync; // Insert request $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; @@ -766,9 +767,9 @@ class CurrencyRate extends CommonObjectLine $sql .= ' entity'; $sql .= ') VALUES ('; $sql .= ' '.$this->rate.','; - $sql .= ' \''.$now.'\','; - $sql .= ' \''.$fk_multicurrency.'\','; - $sql .= ' \''.$this->entity.'\''; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " ".((int) $fk_multicurrency).","; + $sql .= " ".((int) $this->entity); $sql .= ')'; $this->db->begin(); @@ -806,9 +807,8 @@ class CurrencyRate extends CommonObjectLine /** * Load object in memory from the database * - * @param int $id Id object - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id) { @@ -827,7 +827,7 @@ class CurrencyRate extends CommonObjectLine $this->id = $obj->rowid; $this->rate = $obj->rate; - $this->date_sync = $obj->date_sync; + $this->date_sync = $this->db->jdate($obj->date_sync); $this->fk_multicurrency = $obj->fk_multicurrency; $this->entity = $obj->entity; } @@ -849,9 +849,8 @@ class CurrencyRate extends CommonObjectLine /** * Update object into database * - * @param bool $trigger true=launch triggers after, false=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param bool $trigger true=launch triggers after, false=disable triggers + * @return int <0 if KO, >0 if OK */ public function update($trigger = true) { @@ -900,9 +899,8 @@ class CurrencyRate extends CommonObjectLine /** * Delete object in database * - * @param bool $trigger true=launch triggers after, false=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param bool $trigger true=launch triggers after, false=disable triggers + * @return int <0 if KO, >0 if OK */ public function delete($trigger = true) { diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 2340df84ce5..37f4693fd9a 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -50,9 +50,8 @@ $search_date_sync = GETPOST('search_date_sync', 'alpha'); $search_rate = GETPOST('search_rate', 'alpha'); $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); -$dateinput = GETPOST('dateinput', 'alpha'); -$rateinput = GETPOST('rateinput', 'int'); -$search_tobatch = GETPOST('search_tobatch', 'int'); +$dateinput = dol_mktime(0, 0, 0, GETPOST('dateinputmonth', 'int'), GETPOST('dateinputday', 'int'), GETPOST('dateinputyear', 'int')); +$rateinput = price2num(GETPOST('rateinput', 'alpha')); $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -86,9 +85,9 @@ $fieldstosearchall = array( // Definition of fields for lists $arrayfields=array( - 'cr.date_sync'=>array('label'=>$langs->trans("date_sync"), 'checked'=>1), - 'cr.rate'=>array('label'=>$langs->trans("rate"), 'checked'=>1), - 'm.code'=>array('label'=>$langs->trans("code"), 'checked'=>1), + 'cr.date_sync'=>array('label'=>'Date', 'checked'=>1), + 'cr.rate'=>array('label'=>'Rate', 'checked'=>1), + 'm.code'=>array('label'=>'Code', 'checked'=>1), ); @@ -112,14 +111,14 @@ if ($action == "create"){ $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); - if ($result) { - setEventMessage($langs->trans('successRateCreate', $multicurrency_code)); + if ($result > 0) { + setEventMessages($langs->trans('successRateCreate', $multicurrency_code), null); } else { dol_syslog("currencyRate:createRate", LOG_WARNING); - setEventMessage($langs->trans('successRateCreate')); + setEventMessages($currencyRate_static->error, $currencyRate_static->errors, 'errors'); } } else { - setEventMessage($langs->trans('NoEmptyRate'), "errors"); + setEventMessages($langs->trans('NoEmptyRate'),null, "errors"); } } @@ -129,17 +128,17 @@ if ($action == 'update'){ if ( $result > 0){ $currency_static = new MultiCurrency($db); $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code); - $currencyRate->date_sync = $db->escape(GETPOST('dateinput', 'alpha')); + $currencyRate->date_sync = $dateinput; $currencyRate->fk_multicurrency = $fk_currency; - $currencyRate->rate = $db->escape(GETPOST('rateinput', 'int')); + $currencyRate->rate = $rateinput; $res = $currencyRate->update(); if ($res){ - setEventMessage($langs->trans('successUpdateRate')); + setEventMessages($langs->trans('successUpdateRate'), null); }else { - setEventMessage($langs->trans('errorUpdateRate'), "errors"); + setEventMessages($currencyRate->error, $currencyRate->errors, "errors"); } }else { - setEventMessage($langs->trans(''), "warnings"); + setEventMessages($langs->trans('Error'), null, "warnings"); } } @@ -151,7 +150,7 @@ if ($action == "deleteRate"){ $current_currency = new MultiCurrency($db); $current_currency->fetch($current_rate->fk_multicurrency); if ($current_currency){ - $delayedhtmlcontent .= $form->formconfirm( + $delayedhtmlcontent = $form->formconfirm( $_SERVER["PHP_SELF"].'?id_rate='.$id_rate_selected, $langs->trans('DeleteLineRate'), $langs->trans('ConfirmDeleteLineRate', $current_rate->rate, $current_currency->name, $current_rate->date_sync), @@ -174,12 +173,12 @@ if ($action == "confirm_delete"){ if ($current_rate){ $result = $current_rate->delete(); if ($result){ - setEventMessage($langs->trans('successRateDelete')); + setEventMessages($langs->trans('successRateDelete'), null); }else { - setEventMessage($langs->trans('errorRateDelete'), 'errors'); + setEventMessages($current_rate->error, $current_rate->errors, 'errors'); } }else { - setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings"); + setEventMessages($langs->trans('NoCurrencyRateSelected'), null, "warnings"); dol_syslog($langs->trans('NoCurrencyRateSelected'), LOG_WARNING); } } @@ -244,13 +243,15 @@ if ($action!= "updateRate" && $action!= "deleteRate" ) { print '
'; print ''; - print ' '; - print ' '; + print ' '; + print ' '; - print ' '; + print ''; print ''; - print ' '; + print ' '; print ' '; print '
' . $langs->trans('date') . '' . $langs->trans('Date') . ''; + print $form->selectDate($dateinput, 'dateinput'); + print '' . $langs->trans('Codemulticurrency') . ' ' . $langs->trans('Currency') . '' . $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true) . '' . $langs->trans('rate') . '' . $langs->trans('Rate') . ''; @@ -260,6 +261,8 @@ if ($action!= "updateRate" && $action!= "deleteRate" ) { print '
'; print '
'; + + print '
'; } if ($action == "updateRate"){ @@ -282,15 +285,17 @@ if ($action == "updateRate"){ print ''; $form = new Form($db); - print '
'; + print ''; print ''; - print ' '; - print ''; + print ' '; + print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print '
' . $langs->trans('date') . '' . $langs->trans('Date') . ''; + print $form->selectDate($current_rate->date_sync, 'dateinput'); + print '' . $langs->trans('Codemulticurrency') . ' ' . $langs->trans('Currency') . '' . $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true) . '' . $langs->trans('rate') . '' . $langs->trans('Rate') . ''; @@ -309,28 +314,23 @@ if ($action == "updateRate"){ $sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; - // 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.'multicurrency_rate as cr '; $sql .=" INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; - - if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); - -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); -if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); +if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); +if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); - -$sql.= ' WHERE m.code != \''.$conf->currency. '\''; +$sql.= " WHERE m.code <> '".$db->escape($conf->currency)."'"; // 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; -$sql.= " GROUP BY cr.rowid, cr.date_sync, cr.rate, m.code, cr.entity "; +$sql.= " GROUP BY cr.rowid, cr.date_sync, cr.rate, m.code, cr.entity, m.code, m.name"; // Add fields from hooks $parameters=array(); @@ -377,12 +377,11 @@ if ($resql) // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - if ($user->admin) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -522,7 +521,7 @@ if ($resql) { $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print 'rowid.'" class="like-link " style="margin-right:15px;important">' . img_picto('edit', 'edit') . ''; + print 'rowid.'" class="like-link " style="margin-right:15px;important">' . img_picto('edit', 'edit') . ''; print 'rowid.'" class="like-link" style="margin-right:45px;important">' . img_picto('delete', 'delete') . ''; print ''; } From 5ab90eeb164c2418ecf43a9ca6b9ab9b22910c08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 14:25:03 +0100 Subject: [PATCH 128/247] Update doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 2e365b4f645..d8fdafeae95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ NEW: Accountancy - Add options to disable binding on sales, purchases & expense NEW: Accountancy balance - Add a input to show subtotal by group NEW: Accountancy - Move to real ledger, real journals, menu disposition NEW: Accountancy - On transfers, select the periodicity by default +NEW: New currency rate editor. NEW: Add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: Add a counter of number of words of pages in website module NEW: add alert before change thirdparty in takepos From 92bdcd017d22d1aa30f390b50247ce6575c1d017 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Oct 2020 14:26:11 +0100 Subject: [PATCH 129/247] Fix --- htdocs/langs/en_US/multicurrency.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index 710a5555833..26313c6bfb9 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -21,7 +21,7 @@ AmountToOthercurrency=Amount To (in currency of receiving account) CurrencyRateSyncSucceed=Currency rate synchronization done successfuly MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT=Use the currency of the document for online payments TabTitleMulticurrencyRate=Rate list -ListCurrencyRate=list of exchange rates for the currency +ListCurrencyRate=List of exchange rates for the currency CreateRate=Create a rate FormCreateRate=Rate creation FormUpdateRate=Rate modification From 7f52920716f97876c8c29f22d98191e606dd495b Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 31 Oct 2020 13:32:18 +0000 Subject: [PATCH 130/247] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/account.php | 160 +- htdocs/accountancy/admin/accountmodel.php | 14 +- htdocs/accountancy/admin/card.php | 22 +- htdocs/accountancy/admin/categories_list.php | 1104 +++--- htdocs/accountancy/admin/closure.php | 48 +- htdocs/accountancy/admin/export.php | 136 +- htdocs/accountancy/admin/fiscalyear.php | 2 +- htdocs/accountancy/admin/journals_list.php | 46 +- htdocs/accountancy/admin/productaccount.php | 258 +- htdocs/accountancy/bookkeeping/balance.php | 16 +- htdocs/accountancy/bookkeeping/card.php | 10 +- htdocs/accountancy/bookkeeping/list.php | 470 +-- .../accountancy/bookkeeping/listbyaccount.php | 46 +- .../thirdparty_lettering_customer.php | 46 +- .../thirdparty_lettering_supplier.php | 40 +- .../class/accountancycategory.class.php | 128 +- .../class/accountancyexport.class.php | 454 +-- .../class/accountancysystem.class.php | 114 +- .../class/accountingaccount.class.php | 148 +- .../class/accountingjournal.class.php | 48 +- htdocs/accountancy/closure/validate.php | 36 +- htdocs/accountancy/customer/card.php | 14 +- htdocs/accountancy/index.php | 72 +- htdocs/accountancy/journal/bankjournal.php | 20 +- .../journal/expensereportsjournal.php | 90 +- .../accountancy/journal/purchasesjournal.php | 4 +- htdocs/accountancy/journal/sellsjournal.php | 6 +- htdocs/accountancy/supplier/card.php | 14 +- htdocs/adherents/admin/adherent.php | 60 +- .../adherents/admin/adherent_extrafields.php | 4 +- htdocs/adherents/admin/website.php | 32 +- htdocs/adherents/agenda.php | 56 +- .../actions_adherentcard_common.class.php | 308 +- .../actions_adherentcard_default.class.php | 72 +- .../default/tpl/adherentcard_view.tpl.php | 22 +- htdocs/adherents/card.php | 2 +- htdocs/adherents/cartes/carte.php | 278 +- .../adherents/class/adherentstats.class.php | 56 +- htdocs/adherents/class/api_members.class.php | 22 +- .../class/api_subscriptions.class.php | 386 +- htdocs/adherents/class/subscription.class.php | 734 ++-- htdocs/adherents/document.php | 46 +- htdocs/adherents/index.php | 164 +- htdocs/adherents/ldap.php | 32 +- htdocs/adherents/list.php | 42 +- htdocs/adherents/note.php | 50 +- htdocs/adherents/stats/byproperties.php | 8 +- htdocs/adherents/stats/geo.php | 368 +- htdocs/adherents/stats/index.php | 128 +- htdocs/adherents/subscription.php | 332 +- htdocs/adherents/subscription/list.php | 66 +- .../adherents/tpl/linkedobjectblock.tpl.php | 14 +- htdocs/adherents/type_ldap.php | 36 +- htdocs/adherents/type_translation.php | 16 +- htdocs/adherents/vcard.php | 10 +- htdocs/admin/agenda.php | 20 +- htdocs/admin/agenda_extrafields.php | 16 +- htdocs/admin/agenda_extsites.php | 20 +- htdocs/admin/agenda_other.php | 280 +- htdocs/admin/agenda_reminder.php | 116 +- htdocs/admin/agenda_xcal.php | 32 +- htdocs/admin/bank_extrafields.php | 16 +- htdocs/admin/barcode.php | 170 +- htdocs/admin/bom_extrafields.php | 16 +- htdocs/admin/clicktodial.php | 18 +- htdocs/admin/compta.php | 90 +- htdocs/admin/const.php | 2 +- htdocs/admin/contract.php | 2 +- htdocs/admin/dav.php | 10 +- htdocs/admin/debugbar.php | 10 +- htdocs/admin/delais.php | 112 +- htdocs/admin/deliverydet_extrafields.php | 16 +- htdocs/admin/dolistore/ajax/image.php | 2 +- .../class/PSWebServiceLibrary.class.php | 14 +- .../admin/dolistore/class/dolistore.class.php | 190 +- htdocs/admin/emailcollector_list.php | 40 +- htdocs/admin/expeditiondet_extrafields.php | 16 +- htdocs/admin/expensereport.php | 206 +- htdocs/admin/external_rss.php | 120 +- htdocs/admin/facture_situation.php | 114 +- htdocs/admin/fckeditor.php | 46 +- htdocs/admin/fichinter.php | 264 +- htdocs/admin/geoipmaxmind.php | 2 +- htdocs/admin/holiday_extrafields.php | 16 +- htdocs/admin/ihm.php | 2 +- htdocs/admin/index.php | 36 +- htdocs/admin/ldap_groups.php | 24 +- htdocs/admin/limits.php | 238 +- htdocs/admin/loan.php | 28 +- htdocs/admin/mailman.php | 164 +- htdocs/admin/mails.php | 66 +- htdocs/admin/mails_emailing.php | 46 +- htdocs/admin/mails_templates.php | 24 +- htdocs/admin/mails_ticket.php | 46 +- htdocs/admin/menus/index.php | 56 +- htdocs/admin/modulehelp.php | 550 +-- htdocs/admin/modules.php | 4 +- htdocs/admin/mrp_extrafields.php | 16 +- htdocs/admin/multicurrency.php | 70 +- htdocs/admin/notification.php | 150 +- htdocs/admin/oauth.php | 102 +- htdocs/admin/oauthlogintokens.php | 2 +- htdocs/admin/openinghours.php | 50 +- htdocs/admin/order_extrafields.php | 16 +- htdocs/admin/orderdet_extrafields.php | 16 +- htdocs/admin/payment.php | 198 +- htdocs/admin/pdf.php | 8 +- htdocs/admin/perms.php | 146 +- htdocs/admin/propal.php | 238 +- htdocs/admin/resource_extrafields.php | 16 +- htdocs/admin/security.php | 192 +- htdocs/admin/security_other.php | 4 +- htdocs/admin/sms.php | 36 +- htdocs/admin/socialnetworks.php | 48 +- htdocs/admin/spip.php | 102 +- htdocs/admin/stock.php | 6 +- htdocs/admin/supplier_invoice.php | 412 +- htdocs/admin/supplier_order.php | 446 +-- htdocs/admin/supplier_payment.php | 412 +- htdocs/admin/supplier_proposal.php | 270 +- htdocs/admin/supplierinvoice_extrafields.php | 16 +- htdocs/admin/supplierorderdet_extrafields.php | 16 +- htdocs/admin/syslog.php | 26 +- htdocs/admin/system/about.php | 36 +- htdocs/admin/system/database-tables.php | 2 +- htdocs/admin/system/database.php | 2 +- htdocs/admin/system/dolibarr.php | 98 +- htdocs/admin/system/filecheck.php | 566 +-- htdocs/admin/system/index.php | 8 +- htdocs/admin/system/modules.php | 8 +- htdocs/admin/system/perf.php | 2 +- htdocs/admin/system/phpinfo.php | 4 +- htdocs/admin/system/security.php | 2 +- htdocs/admin/ticket_public.php | 470 +-- htdocs/admin/tools/dolibarr_export.php | 4 +- htdocs/admin/tools/dolibarr_import.php | 92 +- htdocs/admin/tools/export.php | 116 +- htdocs/admin/tools/export_files.php | 92 +- htdocs/admin/tools/listevents.php | 34 +- htdocs/admin/tools/listsessions.php | 6 +- htdocs/admin/tools/purge.php | 26 +- htdocs/admin/user.php | 208 +- htdocs/admin/usergroup.php | 208 +- htdocs/admin/workflow.php | 2 +- htdocs/api/admin/explorer.php | 146 +- htdocs/api/admin/index.php | 28 +- htdocs/api/class/api.class.php | 404 +- htdocs/api/class/api_access.class.php | 84 +- htdocs/api/class/api_documents.class.php | 98 +- htdocs/api/class/api_login.class.php | 62 +- htdocs/api/class/api_status.class.php | 32 +- htdocs/api/index.php | 188 +- .../asset/admin/assets_type_extrafields.php | 4 +- htdocs/asset/class/asset_type.class.php | 38 +- htdocs/asterisk/cidlookup.php | 4 +- htdocs/asterisk/wrapper.php | 92 +- htdocs/barcode/printsheet.php | 56 +- htdocs/blockedlog/admin/blockedlog_list.php | 2 +- htdocs/blockedlog/class/authority.class.php | 68 +- htdocs/blockedlog/class/blockedlog.class.php | 62 +- htdocs/bom/bom_agenda.php | 100 +- htdocs/bom/bom_document.php | 4 +- htdocs/bom/bom_list.php | 30 +- htdocs/bom/class/bom.class.php | 570 +-- htdocs/bom/lib/bom.lib.php | 86 +- htdocs/bom/tpl/linkedobjectblock.tpl.php | 56 +- htdocs/bom/tpl/objectline_edit.tpl.php | 6 +- htdocs/bookmarks/bookmarks.lib.php | 192 +- htdocs/bookmarks/card.php | 8 +- htdocs/bookmarks/class/bookmark.class.php | 324 +- htdocs/cashdesk/admin/cashdesk.php | 36 +- htdocs/cashdesk/affContenu.php | 4 +- htdocs/cashdesk/class/Auth.class.php | 62 +- htdocs/cashdesk/class/Facturation.class.php | 962 ++--- htdocs/cashdesk/facturation_verif.php | 84 +- htdocs/cashdesk/index_verif.php | 18 +- htdocs/cashdesk/tpl/facturation1.tpl.php | 2 +- htdocs/cashdesk/tpl/liste_articles.tpl.php | 26 +- htdocs/cashdesk/tpl/ticket.tpl.php | 28 +- htdocs/cashdesk/validation_ticket.php | 2 +- htdocs/cashdesk/validation_verif.php | 62 +- htdocs/categories/admin/categorie.php | 32 +- .../admin/categorie_extrafields.php | 16 +- htdocs/categories/card.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/categories/edit.php | 12 +- htdocs/categories/info.php | 6 +- htdocs/categories/viewcat.php | 130 +- htdocs/comm/action/card.php | 878 ++--- .../action/class/actioncommreminder.class.php | 16 +- .../comm/action/class/cactioncomm.class.php | 12 +- htdocs/comm/action/class/ical.class.php | 700 ++-- htdocs/comm/action/info.php | 34 +- htdocs/comm/action/list.php | 288 +- htdocs/comm/action/pertype.php | 332 +- htdocs/comm/action/peruser.php | 358 +- htdocs/comm/action/rapport/index.php | 22 +- htdocs/comm/admin/propal_extrafields.php | 18 +- htdocs/comm/card.php | 16 +- htdocs/comm/contact.php | 24 +- htdocs/comm/mailing/card.php | 158 +- htdocs/comm/mailing/cibles.php | 108 +- .../mailing/class/advtargetemailing.class.php | 80 +- .../html.formadvtargetemailing.class.php | 54 +- htdocs/comm/mailing/class/mailing.class.php | 74 +- htdocs/comm/mailing/index.php | 192 +- htdocs/comm/mailing/list.php | 8 +- htdocs/comm/propal/card.php | 198 +- htdocs/comm/propal/class/propal.class.php | 282 +- .../comm/propal/class/propalestats.class.php | 140 +- htdocs/comm/propal/contact.php | 72 +- htdocs/comm/propal/document.php | 64 +- htdocs/comm/propal/index.php | 2 +- htdocs/comm/propal/info.php | 64 +- htdocs/comm/propal/note.php | 58 +- htdocs/comm/propal/stats/index.php | 232 +- .../comm/propal/tpl/linkedobjectblock.tpl.php | 66 +- htdocs/comm/prospect/index.php | 20 +- htdocs/comm/prospect/recap-prospect.php | 40 +- htdocs/comm/recap-client.php | 42 +- htdocs/comm/remise.php | 88 +- htdocs/comm/remx.php | 396 +- htdocs/commande/card.php | 14 +- htdocs/commande/class/commande.class.php | 4 +- htdocs/commande/class/commandestats.class.php | 90 +- htdocs/commande/contact.php | 82 +- htdocs/commande/document.php | 58 +- htdocs/commande/index.php | 198 +- htdocs/commande/info.php | 64 +- htdocs/commande/list.php | 32 +- htdocs/commande/note.php | 58 +- htdocs/commande/stats/index.php | 188 +- htdocs/commande/tpl/linkedobjectblock.tpl.php | 70 +- htdocs/compta/accounting-files.php | 892 ++--- htdocs/compta/bank/annuel.php | 28 +- htdocs/compta/bank/class/account.class.php | 250 +- .../bank/class/api_bankaccounts.class.php | 182 +- htdocs/compta/bank/class/bankcateg.class.php | 64 +- .../bank/class/paymentvarious.class.php | 68 +- htdocs/compta/bank/document.php | 78 +- htdocs/compta/bank/graph.php | 4 +- htdocs/compta/bank/line.php | 786 ++-- htdocs/compta/bank/list.php | 376 +- htdocs/compta/bank/releve.php | 40 +- htdocs/compta/bank/transfer.php | 6 +- htdocs/compta/bank/treso.php | 34 +- htdocs/compta/bank/various_payment/card.php | 102 +- htdocs/compta/bank/various_payment/list.php | 2 +- .../compta/cashcontrol/cashcontrol_card.php | 470 +-- .../cashcontrol/class/cashcontrol.class.php | 44 +- htdocs/compta/cashcontrol/report.php | 128 +- htdocs/compta/charges/index.php | 174 +- .../deplacement/class/deplacement.class.php | 140 +- .../class/deplacementstats.class.php | 52 +- htdocs/compta/deplacement/document.php | 20 +- htdocs/compta/deplacement/index.php | 120 +- htdocs/compta/deplacement/info.php | 8 +- htdocs/compta/deplacement/list.php | 148 +- htdocs/compta/deplacement/stats/index.php | 56 +- .../admin/facture_cust_extrafields.php | 14 +- .../admin/facture_rec_cust_extrafields.php | 14 +- .../admin/facturedet_cust_extrafields.php | 16 +- .../admin/facturedet_rec_cust_extrafields.php | 16 +- htdocs/compta/facture/card-rec.php | 70 +- htdocs/compta/facture/card.php | 1202 +++--- .../facture/class/api_invoices.class.php | 4 +- htdocs/compta/facture/class/facture.class.php | 6 +- .../facture/class/facturestats.class.php | 96 +- .../facture/class/paymentterm.class.php | 174 +- htdocs/compta/facture/contact.php | 72 +- htdocs/compta/facture/document.php | 90 +- htdocs/compta/facture/index.php | 96 +- .../compta/facture/invoicetemplate_list.php | 104 +- htdocs/compta/facture/list.php | 128 +- htdocs/compta/facture/note.php | 96 +- htdocs/compta/facture/prelevement.php | 236 +- htdocs/compta/facture/stats/index.php | 88 +- .../facture/tpl/linkedobjectblock.tpl.php | 58 +- .../tpl/linkedobjectblockForRec.tpl.php | 6 +- htdocs/compta/index.php | 150 +- htdocs/compta/journal/purchasesjournal.php | 6 +- htdocs/compta/journal/sellsjournal.php | 18 +- htdocs/compta/localtax/card.php | 56 +- .../compta/localtax/class/localtax.class.php | 632 +-- htdocs/compta/localtax/clients.php | 42 +- htdocs/compta/localtax/index.php | 416 +- htdocs/compta/localtax/list.php | 58 +- htdocs/compta/localtax/quadri_detail.php | 100 +- htdocs/compta/paiement.php | 950 ++--- htdocs/compta/paiement/card.php | 66 +- htdocs/compta/paiement/cheque/card.php | 302 +- .../cheque/class/remisecheque.class.php | 320 +- htdocs/compta/paiement/cheque/index.php | 28 +- htdocs/compta/paiement/cheque/list.php | 112 +- .../compta/paiement/class/paiement.class.php | 930 ++--- htdocs/compta/paiement/list.php | 36 +- htdocs/compta/paiement/rapport.php | 126 +- htdocs/compta/paiement/tovalidate.php | 86 +- htdocs/compta/paiement_charge.php | 116 +- htdocs/compta/payment_sc/card.php | 36 +- htdocs/compta/paymentbybanktransfer/index.php | 156 +- .../class/ligneprelevement.class.php | 12 +- .../class/rejetprelevement.class.php | 40 +- htdocs/compta/prelevement/create.php | 2 +- htdocs/compta/prelevement/index.php | 156 +- htdocs/compta/prelevement/list.php | 196 +- htdocs/compta/prelevement/orders_list.php | 176 +- htdocs/compta/recap-compta.php | 12 +- htdocs/compta/resultat/clientfourn.php | 1148 +++--- htdocs/compta/resultat/index.php | 268 +- htdocs/compta/resultat/result.php | 6 +- htdocs/compta/sociales/card.php | 10 +- .../sociales/class/cchargesociales.class.php | 118 +- .../class/paymentsocialcontribution.class.php | 268 +- htdocs/compta/sociales/document.php | 82 +- htdocs/compta/sociales/list.php | 30 +- htdocs/compta/sociales/payments.php | 206 +- htdocs/compta/stats/cabyprodserv.php | 58 +- htdocs/compta/stats/cabyuser.php | 370 +- htdocs/compta/stats/casoc.php | 168 +- htdocs/compta/stats/index.php | 8 +- htdocs/compta/stats/supplier_turnover.php | 8 +- .../stats/supplier_turnover_by_prodserv.php | 30 +- .../stats/supplier_turnover_by_thirdparty.php | 164 +- htdocs/compta/tva/card.php | 130 +- htdocs/compta/tva/class/tva.class.php | 734 ++-- htdocs/compta/tva/clients.php | 1050 ++--- htdocs/compta/tva/document.php | 56 +- htdocs/compta/tva/index.php | 458 +-- htdocs/compta/tva/list.php | 26 +- htdocs/compta/tva/quadri_detail.php | 8 +- htdocs/contact/agenda.php | 212 +- .../actions_contactcard_common.class.php | 398 +- .../actions_contactcard_default.class.php | 88 +- htdocs/contact/card.php | 14 +- htdocs/contact/class/contact.class.php | 416 +- htdocs/contact/consumption.php | 196 +- htdocs/contact/document.php | 90 +- htdocs/contact/ldap.php | 2 +- htdocs/contact/note.php | 56 +- htdocs/contact/perso.php | 248 +- htdocs/contact/vcard.php | 10 +- htdocs/contrat/card.php | 142 +- htdocs/contrat/class/contrat.class.php | 640 ++-- htdocs/contrat/contact.php | 126 +- htdocs/contrat/document.php | 22 +- htdocs/contrat/index.php | 186 +- htdocs/contrat/list.php | 10 +- htdocs/contrat/note.php | 152 +- htdocs/contrat/services_list.php | 86 +- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 8 +- htdocs/core/actions_builddoc.inc.php | 146 +- .../core/actions_changeselectedfields.inc.php | 16 +- htdocs/core/actions_comments.inc.php | 26 +- htdocs/core/actions_extrafields.inc.php | 576 +-- htdocs/core/actions_fetchobject.inc.php | 30 +- htdocs/core/actions_linkedfiles.inc.php | 4 +- htdocs/core/actions_massactions.inc.php | 244 +- htdocs/core/actions_printing.inc.php | 2 +- htdocs/core/actions_setmoduleoptions.inc.php | 112 +- htdocs/core/actions_setnotes.inc.php | 4 +- htdocs/core/ajax/ajaxdirtree.php | 18 +- htdocs/core/ajax/box.php | 12 +- htdocs/core/ajax/check_notifications.php | 84 +- htdocs/core/ajax/constantonoff.php | 2 +- htdocs/core/ajax/contacts.php | 2 +- htdocs/core/ajax/selectsearchbox.php | 42 +- .../box_accountancy_last_manual_entries.php | 176 +- .../box_accountancy_suspense_account.php | 98 +- htdocs/core/boxes/box_actions.php | 22 +- htdocs/core/boxes/box_birthdays.php | 82 +- htdocs/core/boxes/box_birthdays_members.php | 86 +- htdocs/core/boxes/box_boms.php | 236 +- htdocs/core/boxes/box_bookmarks.php | 152 +- htdocs/core/boxes/box_clients.php | 116 +- htdocs/core/boxes/box_commandes.php | 280 +- htdocs/core/boxes/box_comptes.php | 190 +- htdocs/core/boxes/box_contacts.php | 32 +- htdocs/core/boxes/box_contracts.php | 256 +- htdocs/core/boxes/box_external_rss.php | 178 +- htdocs/core/boxes/box_factures.php | 202 +- htdocs/core/boxes/box_factures_fourn.php | 194 +- htdocs/core/boxes/box_factures_fourn_imp.php | 140 +- htdocs/core/boxes/box_factures_imp.php | 138 +- htdocs/core/boxes/box_ficheinter.php | 70 +- htdocs/core/boxes/box_fournisseurs.php | 196 +- htdocs/core/boxes/box_goodcustomers.php | 68 +- .../boxes/box_graph_invoices_permonth.php | 34 +- .../box_graph_invoices_supplier_permonth.php | 48 +- .../core/boxes/box_graph_orders_permonth.php | 56 +- .../box_graph_orders_supplier_permonth.php | 52 +- .../boxes/box_graph_product_distribution.php | 46 +- .../boxes/box_graph_propales_permonth.php | 48 +- .../core/boxes/box_last_modified_ticket.php | 292 +- htdocs/core/boxes/box_last_ticket.php | 294 +- htdocs/core/boxes/box_lastlogin.php | 122 +- htdocs/core/boxes/box_members.php | 126 +- htdocs/core/boxes/box_mos.php | 232 +- htdocs/core/boxes/box_produits.php | 192 +- .../core/boxes/box_produits_alerte_stock.php | 192 +- htdocs/core/boxes/box_project.php | 286 +- htdocs/core/boxes/box_propales.php | 250 +- htdocs/core/boxes/box_prospect.php | 126 +- htdocs/core/boxes/box_services_contracts.php | 88 +- htdocs/core/boxes/box_services_expired.php | 246 +- htdocs/core/boxes/box_shipments.php | 246 +- htdocs/core/boxes/box_supplier_orders.php | 260 +- htdocs/core/boxes/box_task.php | 96 +- htdocs/core/boxes/box_validated_projects.php | 244 +- htdocs/core/boxes/intracommreport_box.php | 96 +- htdocs/core/boxes/modules_boxes.php | 288 +- htdocs/core/class/CMailFile.class.php | 22 +- htdocs/core/class/CSMSFile.class.php | 176 +- htdocs/core/class/antivir.class.php | 22 +- htdocs/core/class/canvas.class.php | 106 +- htdocs/core/class/ccountry.class.php | 230 +- htdocs/core/class/comment.class.php | 26 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commoninvoice.class.php | 10 +- htdocs/core/class/commonobject.class.php | 20 +- htdocs/core/class/commonorder.class.php | 2 +- .../class/commonstickergenerator.class.php | 120 +- htdocs/core/class/conf.class.php | 260 +- htdocs/core/class/cproductnature.class.php | 350 +- htdocs/core/class/cstate.class.php | 206 +- htdocs/core/class/ctypent.class.php | 206 +- htdocs/core/class/ctyperesource.class.php | 14 +- htdocs/core/class/cunits.class.php | 364 +- htdocs/core/class/discount.class.php | 1146 +++--- htdocs/core/class/doleditor.class.php | 294 +- htdocs/core/class/dolexception.class.php | 12 +- htdocs/core/class/dolgeoip.class.php | 90 +- htdocs/core/class/dolgraph.class.php | 200 +- htdocs/core/class/dolreceiptprinter.class.php | 1398 +++---- .../core/class/emailsenderprofile.class.php | 20 +- htdocs/core/class/evalmath.class.php | 18 +- htdocs/core/class/events.class.php | 34 +- htdocs/core/class/extralanguages.class.php | 18 +- htdocs/core/class/fileupload.class.php | 52 +- htdocs/core/class/fiscalyear.class.php | 38 +- htdocs/core/class/genericobject.class.php | 18 +- htdocs/core/class/google.class.php | 96 +- htdocs/core/class/hookmanager.class.php | 2 +- htdocs/core/class/html.form.class.php | 248 +- .../core/class/html.formaccounting.class.php | 342 +- htdocs/core/class/html.formadmin.class.php | 328 +- htdocs/core/class/html.formbank.class.php | 52 +- htdocs/core/class/html.formbarcode.class.php | 334 +- htdocs/core/class/html.formcompany.class.php | 10 +- htdocs/core/class/html.formcontract.class.php | 92 +- htdocs/core/class/html.formcron.class.php | 124 +- .../class/html.formexpensereport.class.php | 182 +- htdocs/core/class/html.formfile.class.php | 4 +- .../class/html.formintervention.class.php | 32 +- htdocs/core/class/html.formmail.class.php | 4 +- htdocs/core/class/html.formmailing.class.php | 50 +- htdocs/core/class/html.formmargin.class.php | 44 +- htdocs/core/class/html.formorder.class.php | 60 +- htdocs/core/class/html.formpropal.class.php | 200 +- htdocs/core/class/html.formsms.class.php | 502 +-- .../class/html.formsocialcontrib.class.php | 144 +- htdocs/core/class/html.formwebsite.class.php | 444 +-- htdocs/core/class/infobox.class.php | 434 +-- htdocs/core/class/interfaces.class.php | 596 +-- htdocs/core/class/ldap.class.php | 170 +- htdocs/core/class/link.class.php | 602 +-- htdocs/core/class/menu.class.php | 182 +- htdocs/core/class/notify.class.php | 52 +- htdocs/core/class/openid.class.php | 914 ++--- htdocs/core/class/rssparser.class.php | 2 +- htdocs/core/class/smtps.class.php | 3376 ++++++++--------- htdocs/core/class/stats.class.php | 259 +- htdocs/core/class/translate.class.php | 380 +- htdocs/core/class/utils.class.php | 78 +- htdocs/core/class/vcard.class.php | 512 +-- htdocs/core/commonfieldsinexport.inc.php | 6 +- htdocs/core/customreports.php | 622 +-- htdocs/core/db/DoliDB.class.php | 40 +- htdocs/core/db/mysqli.class.php | 1622 ++++---- htdocs/core/db/pgsql.class.php | 726 ++-- htdocs/core/db/sqlite3.class.php | 2208 +++++------ htdocs/core/extrafieldsinexport.inc.php | 44 +- .../connectors/php/commands.php | 18 +- .../connectors/php/connector.php | 6 +- .../core/filemanagerdol/connectors/php/io.php | 58 +- .../filemanagerdol/connectors/php/util.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/js/lib_head.js.php | 2 +- htdocs/core/js/lib_notification.js.php | 14 +- htdocs/core/lib/admin.lib.php | 1494 ++++---- htdocs/core/lib/agenda.lib.php | 222 +- htdocs/core/lib/bank.lib.php | 348 +- htdocs/core/lib/barcode.lib.php | 472 +-- htdocs/core/lib/company.lib.php | 20 +- htdocs/core/lib/contact.lib.php | 86 +- htdocs/core/lib/contract.lib.php | 50 +- htdocs/core/lib/cron.lib.php | 48 +- htdocs/core/lib/date.lib.php | 398 +- htdocs/core/lib/doleditor.lib.php | 116 +- htdocs/core/lib/donation.lib.php | 6 +- htdocs/core/lib/emailing.lib.php | 8 +- htdocs/core/lib/expensereport.lib.php | 42 +- htdocs/core/lib/fichinter.lib.php | 50 +- htdocs/core/lib/files.lib.php | 8 +- htdocs/core/lib/fiscalyear.lib.php | 4 +- htdocs/core/lib/format_cards.lib.php | 40 +- htdocs/core/lib/fourn.lib.php | 42 +- htdocs/core/lib/functions.lib.php | 48 +- htdocs/core/lib/functions2.lib.php | 10 +- htdocs/core/lib/geturl.lib.php | 222 +- htdocs/core/lib/holiday.lib.php | 68 +- htdocs/core/lib/intracommreport.lib.php | 60 +- htdocs/core/lib/invoice.lib.php | 68 +- htdocs/core/lib/json.lib.php | 186 +- htdocs/core/lib/memory.lib.php | 56 +- htdocs/core/lib/oauth.lib.php | 452 +-- htdocs/core/lib/order.lib.php | 24 +- htdocs/core/lib/parsemd.lib.php | 72 +- htdocs/core/lib/pdf.lib.php | 690 ++-- htdocs/core/lib/price.lib.php | 154 +- htdocs/core/lib/product.lib.php | 238 +- htdocs/core/lib/project.lib.php | 422 +-- htdocs/core/lib/security.lib.php | 14 +- htdocs/core/lib/security2.lib.php | 124 +- htdocs/core/lib/signature.lib.php | 2 +- htdocs/core/lib/stock.lib.php | 52 +- htdocs/core/lib/supplier_proposal.lib.php | 40 +- htdocs/core/lib/tax.lib.php | 1430 +++---- htdocs/core/lib/treeview.lib.php | 102 +- htdocs/core/lib/usergroups.lib.php | 46 +- htdocs/core/lib/vat.lib.php | 32 +- htdocs/core/lib/website.lib.php | 14 +- htdocs/core/lib/ws.lib.php | 76 +- htdocs/core/login/functions_dolibarr.php | 8 +- htdocs/core/login/functions_googleoauth.php | 18 +- htdocs/core/login/functions_ldap.php | 6 +- htdocs/core/login/functions_openid.php | 152 +- htdocs/core/menus/standard/auguria.lib.php | 78 +- htdocs/core/menus/standard/auguria_menu.php | 416 +- htdocs/core/menus/standard/eldy.lib.php | 22 +- htdocs/core/menus/standard/eldy_menu.php | 462 +-- htdocs/core/menus/standard/empty.php | 390 +- htdocs/core/modules/action/modules_action.php | 78 +- htdocs/core/modules/action/rapport.pdf.php | 76 +- htdocs/core/modules/bank/modules_bank.php | 12 +- .../barcode/doc/phpbarcode.modules.php | 14 +- .../barcode/doc/tcpdfbarcode.modules.php | 6 +- .../barcode/mod_barcode_product_standard.php | 34 +- .../modules/barcode/modules_barcode.class.php | 244 +- .../bom/doc/doc_generic_bom_odt.modules.php | 58 +- htdocs/core/modules/bom/mod_bom_advanced.php | 56 +- .../cheque/mod_chequereceipt_thyme.php | 64 +- .../doc/doc_generic_order_odt.modules.php | 70 +- .../commande/doc/pdf_einstein.modules.php | 368 +- .../commande/doc/pdf_eratosthene.modules.php | 1072 +++--- .../modules/commande/mod_commande_saphir.php | 70 +- .../doc/doc_generic_contract_odt.modules.php | 52 +- .../modules/contract/mod_contract_magre.php | 46 +- .../modules/contract/mod_contract_olive.php | 8 +- .../modules/contract/mod_contract_serpis.php | 20 +- .../modules/contract/modules_contract.php | 12 +- .../delivery/doc/pdf_storm.modules.php | 56 +- .../modules/dons/html_cerfafr.modules.php | 68 +- .../doc/doc_generic_shipment_odt.modules.php | 72 +- .../expedition/doc/pdf_espadon.modules.php | 6 +- .../expedition/mod_expedition_ribera.php | 48 +- .../expedition/mod_expedition_safor.php | 28 +- .../modules/expedition/modules_expedition.php | 24 +- .../expensereport/mod_expensereport_sand.php | 70 +- .../expensereport/modules_expensereport.php | 56 +- .../modules/export/export_csv.modules.php | 58 +- .../export/export_excel2007new.modules.php | 300 +- .../modules/export/export_tsv.modules.php | 304 +- htdocs/core/modules/export/modules_export.php | 70 +- .../doc/doc_generic_invoice_odt.modules.php | 64 +- .../core/modules/facture/mod_facture_mars.php | 74 +- .../modules/facture/mod_facture_mercure.php | 240 +- .../modules/facture/mod_facture_terre.php | 114 +- .../fichinter/doc/pdf_soleil.modules.php | 104 +- htdocs/core/modules/fichinter/mod_arctic.php | 68 +- htdocs/core/modules/fichinter/mod_pacific.php | 26 +- .../holiday/mod_holiday_immaculate.php | 44 +- .../modules/holiday/mod_holiday_madonna.php | 20 +- .../core/modules/holiday/modules_holiday.php | 14 +- .../modules/import/import_csv.modules.php | 598 +-- .../modules/import/import_xlsx.modules.php | 646 ++-- htdocs/core/modules/import/modules_import.php | 140 +- .../mailings/advthirdparties.modules.php | 152 +- .../modules/mailings/contacts1.modules.php | 112 +- .../core/modules/mailings/example.modules.php | 168 +- .../core/modules/mailings/fraise.modules.php | 468 +-- .../modules/mailings/modules_mailings.php | 354 +- .../core/modules/mailings/pomme.modules.php | 68 +- .../modules/mailings/thirdparties.modules.php | 216 +- .../thirdparties_services_expired.modules.php | 354 +- .../modules/mailings/xinputfile.modules.php | 124 +- .../modules/mailings/xinputuser.modules.php | 40 +- .../modules/member/doc/pdf_standard.class.php | 90 +- htdocs/core/modules/member/modules_cards.php | 6 +- htdocs/core/modules/modAccounting.class.php | 106 +- htdocs/core/modules/modAdherent.class.php | 620 +-- htdocs/core/modules/modAgenda.class.php | 54 +- htdocs/core/modules/modApi.class.php | 42 +- htdocs/core/modules/modAsset.class.php | 54 +- htdocs/core/modules/modBarcode.class.php | 40 +- htdocs/core/modules/modBlockedLog.class.php | 350 +- htdocs/core/modules/modCashDesk.class.php | 36 +- htdocs/core/modules/modCategorie.class.php | 200 +- htdocs/core/modules/modCollab.class.php | 130 +- htdocs/core/modules/modCommande.class.php | 14 +- htdocs/core/modules/modComptabilite.class.php | 38 +- htdocs/core/modules/modContrat.class.php | 24 +- htdocs/core/modules/modCron.class.php | 84 +- htdocs/core/modules/modDataPolicy.class.php | 342 +- htdocs/core/modules/modDebugBar.class.php | 114 +- htdocs/core/modules/modDeplacement.class.php | 20 +- .../modules/modDocumentGeneration.class.php | 10 +- htdocs/core/modules/modDon.class.php | 2 +- .../core/modules/modDynamicPrices.class.php | 80 +- htdocs/core/modules/modECM.class.php | 22 +- .../core/modules/modEmailCollector.class.php | 32 +- htdocs/core/modules/modExpedition.class.php | 22 +- .../core/modules/modExpenseReport.class.php | 38 +- htdocs/core/modules/modExternalRss.class.php | 14 +- htdocs/core/modules/modExternalSite.class.php | 14 +- htdocs/core/modules/modFTP.class.php | 26 +- htdocs/core/modules/modFacture.class.php | 38 +- htdocs/core/modules/modFckeditor.class.php | 12 +- htdocs/core/modules/modFicheinter.class.php | 274 +- htdocs/core/modules/modFournisseur.class.php | 34 +- htdocs/core/modules/modIncoterm.class.php | 40 +- .../core/modules/modIntracommreport.class.php | 116 +- htdocs/core/modules/modLabel.class.php | 8 +- htdocs/core/modules/modLoan.class.php | 2 +- htdocs/core/modules/modMailing.class.php | 2 +- .../core/modules/modModuleBuilder.class.php | 128 +- .../core/modules/modMultiCurrency.class.php | 38 +- htdocs/core/modules/modNotification.class.php | 6 +- htdocs/core/modules/modOauth.class.php | 162 +- htdocs/core/modules/modOpenSurvey.class.php | 120 +- htdocs/core/modules/modPaybox.class.php | 268 +- .../modPaymentByBankTransfer.class.php | 40 +- htdocs/core/modules/modPaypal.class.php | 252 +- htdocs/core/modules/modPrelevement.class.php | 46 +- htdocs/core/modules/modPrinting.class.php | 136 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modProductBatch.class.php | 34 +- htdocs/core/modules/modProjet.class.php | 90 +- htdocs/core/modules/modPropale.class.php | 18 +- .../core/modules/modReceiptPrinter.class.php | 178 +- htdocs/core/modules/modReception.class.php | 20 +- htdocs/core/modules/modService.class.php | 456 +-- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/core/modules/modStock.class.php | 52 +- htdocs/core/modules/modStripe.class.php | 122 +- .../modules/modSupplierProposal.class.php | 16 +- htdocs/core/modules/modTakePos.class.php | 38 +- htdocs/core/modules/modTax.class.php | 14 +- htdocs/core/modules/modTicket.class.php | 462 +-- htdocs/core/modules/modUser.class.php | 118 +- htdocs/core/modules/modVariants.class.php | 2 +- htdocs/core/modules/modWebServices.class.php | 68 +- htdocs/core/modules/modWebsite.class.php | 212 +- htdocs/core/modules/modWorkflow.class.php | 130 +- htdocs/core/modules/modZapier.class.php | 528 +-- .../mrp/doc/doc_generic_mo_odt.modules.php | 58 +- htdocs/core/modules/mrp/mod_mo_advanced.php | 56 +- .../modules/oauth/github_oauthcallback.php | 94 +- .../modules/oauth/google_oauthcallback.php | 82 +- .../oauth/stripelive_oauthcallback.php | 92 +- .../core/modules/payment/mod_payment_ant.php | 66 +- .../modules/printing/modules_printing.php | 84 +- .../modules/printing/printgcp.modules.php | 36 +- .../modules/printing/printipp.modules.php | 576 +-- .../doc/pdf_standardlabel.class.php | 28 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 20 +- .../modules/printsheet/modules_labels.php | 12 +- .../doc/doc_generic_product_odt.modules.php | 50 +- .../product/doc/pdf_standard.modules.php | 438 +-- .../product/mod_codeproduct_elephant.php | 34 +- .../product/mod_codeproduct_leopard.php | 8 +- .../modules_product_batch.class.php | 44 +- .../doc/doc_generic_project_odt.modules.php | 138 +- .../modules/project/mod_project_universal.php | 100 +- .../core/modules/project/modules_project.php | 32 +- .../task/doc/doc_generic_task_odt.modules.php | 148 +- .../modules/project/task/modules_task.php | 26 +- .../doc/doc_generic_proposal_odt.modules.php | 66 +- .../modules/propale/mod_propale_saphir.php | 56 +- .../core/modules/propale/modules_propale.php | 10 +- .../modules/rapport/pdf_paiement.class.php | 202 +- .../rapport/pdf_paiement_fourn.class.php | 6 +- .../doc/doc_generic_reception_odt.modules.php | 76 +- .../modules/reception/mod_reception_beryl.php | 18 +- .../reception/mod_reception_moonstone.php | 48 +- .../modules/reception/modules_reception.php | 14 +- .../generate/modGeneratePassNone.class.php | 14 +- .../generate/modGeneratePassPerso.class.php | 20 +- .../modGeneratePassStandard.class.php | 34 +- .../security/generate/modules_genpassword.php | 84 +- .../societe/doc/doc_generic_odt.modules.php | 220 +- .../societe/mod_codeclient_elephant.php | 16 +- .../societe/mod_codeclient_leopard.php | 8 +- .../modules/societe/mod_codeclient_monkey.php | 32 +- .../societe/mod_codecompta_aquarium.php | 32 +- .../societe/mod_codecompta_digitaria.php | 324 +- .../societe/mod_codecompta_panicum.php | 10 +- htdocs/core/modules/stock/modules_stock.php | 44 +- .../mod_facture_fournisseur_cactus.php | 188 +- .../mod_facture_fournisseur_tulip.php | 110 +- .../modules_facturefournisseur.php | 44 +- ...doc_generic_supplier_order_odt.modules.php | 64 +- .../mod_commande_fournisseur_orchidee.php | 86 +- .../modules_commandefournisseur.php | 20 +- .../mod_supplier_payment_brodator.php | 70 +- ..._generic_supplier_proposal_odt.modules.php | 36 +- .../mod_supplier_proposal_saphir.php | 54 +- .../modules_supplier_proposal.php | 16 +- .../core/modules/syslog/mod_syslog_file.php | 36 +- .../core/modules/syslog/mod_syslog_syslog.php | 10 +- .../takepos/mod_takepos_ref_simple.php | 226 +- .../takepos/mod_takepos_ref_universal.php | 160 +- .../modules/ticket/mod_ticket_universal.php | 158 +- htdocs/core/modules/ticket/modules_ticket.php | 16 +- .../user/doc/doc_generic_user_odt.modules.php | 64 +- .../core/modules/user/modules_user.class.php | 10 +- .../doc/doc_generic_usergroup_odt.modules.php | 44 +- .../usergroup/modules_usergroup.class.php | 44 +- htdocs/core/photos_resize.php | 214 +- htdocs/core/tpl/admin_extrafields_add.tpl.php | 18 +- .../core/tpl/admin_extrafields_edit.tpl.php | 46 +- htdocs/core/tpl/advtarget.tpl.php | 82 +- .../tpl/ajax/objectlinked_lineimport.tpl.php | 2 +- htdocs/core/tpl/card_presend.tpl.php | 2 +- .../tpl/document_actions_post_headers.tpl.php | 52 +- .../tpl/extrafields_list_print_fields.tpl.php | 26 +- .../tpl/extrafields_list_search_input.tpl.php | 66 +- .../tpl/extrafields_list_search_param.tpl.php | 14 +- .../tpl/extrafields_list_search_sql.tpl.php | 6 +- .../tpl/extrafields_list_search_title.tpl.php | 2 +- htdocs/core/tpl/extrafields_view.tpl.php | 42 +- htdocs/core/tpl/filemanager.tpl.php | 84 +- htdocs/core/tpl/login.tpl.php | 20 +- htdocs/core/tpl/massactions_pre.tpl.php | 4 +- htdocs/core/tpl/objectline_edit.tpl.php | 36 +- htdocs/core/tpl/objectline_view.tpl.php | 16 +- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 158 +- htdocs/core/tpl/resource_view.tpl.php | 6 +- .../core/triggers/dolibarrtriggers.class.php | 28 +- .../interface_20_all_Logevents.class.php | 206 +- ...e_20_modWorkflow_WorkflowManager.class.php | 510 +-- ...terface_50_modAgenda_ActionsAuto.class.php | 30 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 44 +- ...interface_50_modLdap_Ldapsynchro.class.php | 30 +- ...odMailmanspip_Mailmanspipsynchro.class.php | 174 +- ..._50_modNotification_Notification.class.php | 30 +- .../interface_80_modStripe_Stripe.class.php | 32 +- ...rface_90_modSociete_ContactRoles.class.php | 30 +- ...face_99_modZapier_ZapierTriggers.class.php | 768 ++-- htdocs/core/website.inc.php | 2 +- htdocs/cron/admin/cron.php | 10 +- htdocs/cron/card.php | 130 +- htdocs/cron/class/cronjob.class.php | 602 +-- htdocs/cron/list.php | 92 +- htdocs/datapolicy/admin/setup.php | 140 +- .../class/actions_datapolicy.class.php | 716 ++-- htdocs/datapolicy/class/datapolicy.class.php | 570 +-- .../datapolicy/class/datapolicycron.class.php | 692 ++-- htdocs/datapolicy/lib/datapolicy.lib.php | 34 +- htdocs/datapolicy/public/index.php | 126 +- htdocs/dav/dav.class.php | 34 +- htdocs/dav/fileserver.php | 6 +- .../DataCollector/DolConfigCollector.php | 4 +- .../class/DataCollector/DolLogsCollector.php | 132 +- .../DataCollector/DolMemoryCollector.php | 30 +- htdocs/debugbar/class/TraceableDB.php | 18 +- htdocs/debugbar/class/autoloader.php | 2 +- htdocs/delivery/card.php | 14 +- htdocs/delivery/class/delivery.class.php | 80 +- htdocs/document.php | 2 +- htdocs/don/admin/donation.php | 146 +- htdocs/don/card.php | 312 +- htdocs/don/class/api_donations.class.php | 408 +- htdocs/don/class/don.class.php | 18 +- htdocs/don/class/donstats.class.php | 92 +- htdocs/don/class/paymentdonation.class.php | 256 +- htdocs/don/document.php | 86 +- htdocs/don/index.php | 182 +- htdocs/don/info.php | 62 +- htdocs/don/list.php | 170 +- htdocs/don/note.php | 62 +- htdocs/don/payment/card.php | 30 +- htdocs/don/payment/payment.php | 108 +- htdocs/don/stats/index.php | 50 +- htdocs/don/tpl/linkedobjectblock.tpl.php | 24 +- htdocs/ecm/class/ecmdirectory.class.php | 172 +- htdocs/ecm/class/ecmfiles.class.php | 6 +- htdocs/ecm/class/htmlecm.form.class.php | 16 +- htdocs/ecm/dir_add_card.php | 6 +- htdocs/ecm/file_card.php | 2 +- htdocs/ecm/index.php | 218 +- htdocs/ecm/index_auto.php | 300 +- .../class/emailcollectoraction.class.php | 812 ++-- .../class/emailcollectorfilter.class.php | 158 +- .../expedition/class/api_shipments.class.php | 718 ++-- htdocs/expedition/class/expedition.class.php | 38 +- .../class/expeditionbatch.class.php | 24 +- .../class/expeditionstats.class.php | 66 +- htdocs/expedition/contact.php | 162 +- htdocs/expedition/document.php | 2 +- htdocs/expedition/index.php | 30 +- htdocs/expedition/list.php | 16 +- htdocs/expedition/note.php | 116 +- htdocs/expedition/shipment.php | 70 +- htdocs/expedition/stats/index.php | 50 +- htdocs/expedition/stats/month.php | 16 +- .../expedition/tpl/linkedobjectblock.tpl.php | 28 +- htdocs/expensereport/ajax/ajaxprojet.php | 16 +- htdocs/expensereport/card.php | 2 +- .../class/api_expensereports.class.php | 228 +- .../class/expensereport.class.php | 94 +- .../class/expensereport_ik.class.php | 40 +- .../class/expensereportstats.class.php | 34 +- .../class/paymentexpensereport.class.php | 320 +- htdocs/expensereport/document.php | 24 +- htdocs/expensereport/index.php | 158 +- htdocs/expensereport/list.php | 438 +-- htdocs/expensereport/payment/card.php | 46 +- htdocs/expensereport/payment/payment.php | 12 +- htdocs/expensereport/stats/index.php | 56 +- .../tpl/expensereport_addfile.tpl.php | 42 +- .../tpl/expensereport_linktofile.tpl.php | 238 +- htdocs/exports/class/export.class.php | 262 +- htdocs/exports/export.php | 1206 +++--- htdocs/exports/index.php | 10 +- .../admin/fichinterdet_extrafields.php | 14 +- htdocs/fichinter/card-rec.php | 40 +- .../class/api_interventions.class.php | 328 +- htdocs/fichinter/class/fichinter.class.php | 148 +- .../fichinter/class/fichinterstats.class.php | 306 +- htdocs/fichinter/contact.php | 80 +- htdocs/fichinter/document.php | 88 +- htdocs/fichinter/index.php | 180 +- htdocs/fichinter/list.php | 126 +- htdocs/fichinter/note.php | 62 +- htdocs/fichinter/stats/index.php | 144 +- .../fichinter/tpl/linkedobjectblock.tpl.php | 6 +- htdocs/filefunc.inc.php | 118 +- htdocs/fourn/card.php | 478 +-- htdocs/fourn/class/fournisseur.class.php | 14 +- .../class/fournisseur.commande.class.php | 20 +- .../fourn/class/fournisseur.product.class.php | 1732 ++++----- htdocs/fourn/class/paiementfourn.class.php | 22 +- htdocs/fourn/commande/card.php | 18 +- htdocs/fourn/commande/contact.php | 68 +- htdocs/fourn/commande/dispatch.php | 68 +- htdocs/fourn/commande/document.php | 58 +- htdocs/fourn/commande/index.php | 16 +- htdocs/fourn/commande/info.php | 118 +- htdocs/fourn/commande/note.php | 90 +- .../commande/tpl/linkedobjectblock.tpl.php | 16 +- htdocs/fourn/contact.php | 70 +- htdocs/fourn/facture/card.php | 74 +- htdocs/fourn/facture/contact.php | 60 +- htdocs/fourn/facture/impayees.php | 10 +- htdocs/fourn/facture/index.php | 34 +- htdocs/fourn/facture/list.php | 32 +- htdocs/fourn/facture/note.php | 92 +- htdocs/fourn/facture/paiement.php | 860 ++--- htdocs/fourn/facture/rapport.php | 122 +- .../facture/tpl/linkedobjectblock.tpl.php | 32 +- htdocs/fourn/paiement/card.php | 2 +- htdocs/fourn/paiement/list.php | 20 +- htdocs/fourn/product/list.php | 78 +- htdocs/fourn/recap-fourn.php | 208 +- htdocs/ftp/admin/ftpclient.php | 20 +- htdocs/ftp/index.php | 172 +- htdocs/holiday/card.php | 4 +- htdocs/holiday/class/holiday.class.php | 182 +- htdocs/holiday/common.inc.php | 12 +- htdocs/holiday/define_holiday.php | 332 +- htdocs/holiday/document.php | 206 +- htdocs/holiday/list.php | 70 +- htdocs/holiday/month_report.php | 262 +- htdocs/holiday/view_log.php | 48 +- htdocs/imports/class/import.class.php | 82 +- htdocs/imports/emptyexample.php | 6 +- htdocs/imports/import.php | 644 ++-- htdocs/imports/index.php | 2 +- htdocs/index.php | 2 +- htdocs/install/check.php | 300 +- htdocs/install/fileconf.php | 136 +- htdocs/install/inc.php | 430 +-- htdocs/install/step1.php | 1202 +++--- htdocs/install/step2.php | 874 ++--- htdocs/install/step4.php | 58 +- htdocs/install/upgrade.php | 2 +- .../intracommreport/admin/intracommreport.php | 114 +- htdocs/intracommreport/card.php | 284 +- .../class/intracommreport.class.php | 94 +- htdocs/intracommreport/list.php | 522 +-- htdocs/loan/card.php | 10 +- htdocs/loan/class/loan.class.php | 92 +- htdocs/loan/class/loanschedule.class.php | 178 +- htdocs/loan/document.php | 44 +- htdocs/loan/note.php | 14 +- htdocs/loan/payment/card.php | 2 +- htdocs/loan/payment/payment.php | 196 +- htdocs/loan/schedule.php | 132 +- .../mailmanspip/class/mailmanspip.class.php | 652 ++-- htdocs/main.inc.php | 6 +- htdocs/margin/agentMargins.php | 148 +- htdocs/margin/checkMargins.php | 84 +- htdocs/margin/customerMargins.php | 12 +- htdocs/margin/productMargins.php | 40 +- htdocs/margin/tabs/productMargins.php | 220 +- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/master.inc.php | 16 +- htdocs/modulebuilder/index.php | 10 +- .../template/admin/myobject_extrafields.php | 16 +- htdocs/modulebuilder/template/admin/setup.php | 2 +- .../core/modules/modMyModule.class.php | 18 +- .../doc/doc_generic_myobject_odt.modules.php | 6 +- ..._99_modMyModule_MyModuleTriggers.class.php | 2 +- .../modulebuilder/template/myobject_card.php | 8 +- .../template/test/phpunit/MyObjectTest.php | 38 +- htdocs/mrp/class/mo.class.php | 246 +- htdocs/mrp/index.php | 182 +- htdocs/mrp/mo_agenda.php | 100 +- htdocs/mrp/mo_document.php | 4 +- htdocs/mrp/mo_list.php | 26 +- htdocs/mrp/mo_movements.php | 122 +- htdocs/mrp/mo_production.php | 1138 +++--- htdocs/opensurvey/list.php | 106 +- htdocs/opensurvey/results.php | 2 +- htdocs/opensurvey/wizard/choix_autre.php | 2 +- htdocs/opensurvey/wizard/choix_date.php | 2 +- htdocs/paybox/admin/paybox.php | 8 +- htdocs/paybox/lib/paybox.lib.php | 216 +- htdocs/paypal/admin/paypal.php | 76 +- htdocs/printing/admin/printing.php | 480 +-- htdocs/product/admin/price_rules.php | 2 +- htdocs/product/admin/product.php | 378 +- htdocs/product/admin/product_extrafields.php | 14 +- .../product/admin/product_lot_extrafields.php | 14 +- .../admin/product_supplier_extrafields.php | 14 +- htdocs/product/admin/product_tools.php | 2 +- htdocs/product/admin/stock_extrafields.php | 18 +- htdocs/product/agenda.php | 102 +- htdocs/product/ajax/products.php | 4 +- .../product/actions_card_product.class.php | 112 +- .../service/actions_card_service.class.php | 82 +- htdocs/product/card.php | 6 +- htdocs/product/class/api_products.class.php | 4 +- .../product/class/html.formproduct.class.php | 214 +- htdocs/product/class/product.class.php | 62 +- htdocs/product/class/productbatch.class.php | 258 +- .../class/productcustomerprice.class.php | 92 +- .../class/propalmergepdfproduct.class.php | 408 +- htdocs/product/composition/card.php | 92 +- htdocs/product/document.php | 192 +- .../class/price_expression.class.php | 574 +-- .../class/price_global_variable.class.php | 542 +-- .../price_global_variable_updater.class.php | 1208 +++--- .../class/price_parser.class.php | 460 +-- htdocs/product/fournisseurs.php | 530 +-- htdocs/product/index.php | 86 +- .../product/inventory/lib/inventory.lib.php | 36 +- htdocs/product/list.php | 4 +- htdocs/product/note.php | 32 +- htdocs/product/popuprop.php | 2 +- htdocs/product/reassort.php | 112 +- htdocs/product/reassortlot.php | 86 +- htdocs/product/stats/bom.php | 46 +- htdocs/product/stats/card.php | 50 +- htdocs/product/stats/commande.php | 108 +- htdocs/product/stats/commande_fournisseur.php | 22 +- htdocs/product/stats/contrat.php | 48 +- htdocs/product/stats/facture.php | 216 +- htdocs/product/stats/facture_fournisseur.php | 28 +- htdocs/product/stats/mo.php | 40 +- htdocs/product/stats/propal.php | 58 +- htdocs/product/stats/supplier_proposal.php | 58 +- .../stock/class/api_stockmovements.class.php | 312 +- .../stock/class/mouvementstock.class.php | 4 +- .../product/stock/class/productlot.class.php | 164 +- .../class/productstockentrepot.class.php | 54 +- htdocs/product/stock/list.php | 12 +- htdocs/product/stock/massstockmove.php | 56 +- htdocs/product/stock/movement_card.php | 1350 +++---- htdocs/product/stock/productlot_card.php | 116 +- htdocs/product/stock/productlot_document.php | 50 +- htdocs/product/stock/replenish.php | 378 +- htdocs/product/stock/replenishorders.php | 316 +- htdocs/product/stock/stockatdate.php | 28 +- htdocs/product/stock/valo.php | 138 +- htdocs/product/traduction.php | 44 +- htdocs/projet/activity/index.php | 206 +- htdocs/projet/activity/perday.php | 28 +- htdocs/projet/activity/perweek.php | 38 +- htdocs/projet/admin/project_extrafields.php | 4 +- .../projet/admin/project_task_extrafields.php | 4 +- htdocs/projet/card.php | 34 +- htdocs/projet/class/api_projects.class.php | 24 +- htdocs/projet/class/project.class.php | 4 +- htdocs/projet/class/projectstats.class.php | 32 +- htdocs/projet/class/task.class.php | 4 +- htdocs/projet/class/taskstats.class.php | 12 +- htdocs/projet/contact.php | 190 +- htdocs/projet/element.php | 508 +-- htdocs/projet/ganttview.php | 244 +- htdocs/projet/index.php | 64 +- htdocs/projet/info.php | 32 +- htdocs/projet/list.php | 2 +- htdocs/projet/note.php | 6 +- htdocs/projet/tasks/comment.php | 240 +- htdocs/projet/tasks/contact.php | 304 +- htdocs/projet/tasks/document.php | 204 +- htdocs/projet/tasks/list.php | 94 +- htdocs/projet/tasks/note.php | 36 +- htdocs/projet/tasks/time.php | 74 +- htdocs/public/agenda/agendaexport.php | 2 +- htdocs/public/cron/cron_run_jobs.php | 84 +- htdocs/public/donations/donateurs_code.php | 4 +- htdocs/public/notice.php | 6 +- htdocs/public/payment/newpayment.php | 24 +- htdocs/public/stripe/confirm_payment.php | 82 +- htdocs/public/stripe/ipn.php | 82 +- htdocs/public/website/styles.css.php | 42 +- htdocs/reception/card.php | 38 +- htdocs/reception/class/reception.class.php | 8 +- .../reception/class/receptionstats.class.php | 64 +- htdocs/reception/contact.php | 156 +- htdocs/reception/index.php | 18 +- htdocs/reception/list.php | 710 ++-- htdocs/reception/note.php | 118 +- htdocs/reception/stats/index.php | 50 +- htdocs/reception/stats/month.php | 14 +- .../reception/tpl/linkedobjectblock.tpl.php | 28 +- htdocs/recruitment/admin/public_interface.php | 12 +- htdocs/recruitment/admin/setup.php | 2 +- htdocs/recruitment/recruitmentindex.php | 4 +- .../recruitmentjobposition_agenda.php | 10 +- .../recruitmentjobposition_card.php | 38 +- .../recruitmentjobposition_document.php | 10 +- .../recruitmentjobposition_note.php | 10 +- htdocs/resource/agenda.php | 66 +- htdocs/resource/card.php | 2 +- .../class/html.formresource.class.php | 280 +- htdocs/resource/document.php | 18 +- htdocs/resource/element_resource.php | 288 +- htdocs/salaries/admin/salaries.php | 28 +- .../salaries/admin/salaries_extrafields.php | 4 +- htdocs/salaries/card.php | 26 +- htdocs/salaries/class/paymentsalary.class.php | 2 +- htdocs/salaries/class/salariesstats.class.php | 228 +- htdocs/salaries/list.php | 156 +- htdocs/societe/admin/societe.php | 204 +- htdocs/societe/agenda.php | 90 +- htdocs/societe/ajaxcompanies.php | 40 +- .../canvas/actions_card_common.class.php | 570 +-- .../company/actions_card_company.class.php | 84 +- .../canvas/company/tpl/card_edit.tpl.php | 2 +- .../actions_card_individual.class.php | 88 +- .../canvas/individual/tpl/card_edit.tpl.php | 2 +- htdocs/societe/card.php | 1424 +++---- htdocs/societe/checkvat/checkVatPopup.php | 8 +- htdocs/societe/class/api_contacts.class.php | 180 +- .../societe/class/api_thirdparties.class.php | 222 +- htdocs/societe/class/client.class.php | 114 +- .../class/companybankaccount.class.php | 32 +- .../class/companypaymentmode.class.php | 160 +- htdocs/societe/class/societe.class.php | 540 +-- htdocs/societe/class/societeaccount.class.php | 166 +- htdocs/societe/consumption.php | 138 +- htdocs/societe/contact.php | 28 +- htdocs/societe/document.php | 8 +- htdocs/societe/list.php | 72 +- htdocs/societe/note.php | 76 +- htdocs/societe/price.php | 18 +- htdocs/societe/project.php | 20 +- htdocs/societe/societecontact.php | 44 +- .../tpl/linesalesrepresentative.tpl.php | 12 +- htdocs/societe/website.php | 64 +- htdocs/stripe/admin/stripe.php | 172 +- htdocs/stripe/class/actions_stripe.class.php | 28 +- htdocs/stripe/lib/stripe.lib.php | 96 +- htdocs/stripe/payout.php | 32 +- htdocs/stripe/transaction.php | 40 +- .../admin/supplier_proposal_extrafields.php | 18 +- .../supplier_proposaldet_extrafields.php | 14 +- htdocs/supplier_proposal/card.php | 20 +- .../class/supplier_proposal.class.php | 2 +- htdocs/supplier_proposal/contact.php | 66 +- htdocs/supplier_proposal/document.php | 58 +- htdocs/supplier_proposal/index.php | 148 +- htdocs/supplier_proposal/info.php | 58 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/supplier_proposal/note.php | 60 +- .../tpl/linkedobjectblock.tpl.php | 18 +- htdocs/takepos/admin/appearance.php | 16 +- htdocs/takepos/admin/receipt.php | 26 +- htdocs/takepos/admin/setup.php | 28 +- htdocs/takepos/admin/terminal.php | 72 +- htdocs/takepos/ajax/ajax.php | 122 +- htdocs/takepos/css/pos.css.php | 2 +- htdocs/takepos/floors.php | 36 +- htdocs/takepos/genimg/index.php | 2 +- htdocs/takepos/index.php | 126 +- htdocs/takepos/invoice.php | 4 +- htdocs/takepos/phone.php | 42 +- htdocs/takepos/public/menu.php | 32 +- htdocs/takepos/receipt.php | 30 +- htdocs/takepos/reduction.php | 30 +- htdocs/takepos/send.php | 6 +- htdocs/theme/eldy/global.inc.php | 118 +- htdocs/theme/eldy/style.css.php | 30 +- htdocs/theme/md/manifest.json.php | 24 +- htdocs/theme/md/style.css.php | 32 +- htdocs/ticket/agenda.php | 30 +- htdocs/ticket/card.php | 6 +- htdocs/ticket/class/ticket.class.php | 38 +- htdocs/ticket/class/ticketstats.class.php | 232 +- htdocs/ticket/class/utils_diff.class.php | 122 +- htdocs/ticket/contact.php | 236 +- htdocs/ticket/document.php | 170 +- htdocs/ticket/index.php | 338 +- htdocs/ticket/list.php | 250 +- htdocs/ticket/messaging.php | 22 +- htdocs/ticket/stats/index.php | 146 +- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 16 +- htdocs/user/admin/user_extrafields.php | 4 +- htdocs/user/bank.php | 144 +- htdocs/user/card.php | 8 +- htdocs/user/class/api_users.class.php | 560 +-- htdocs/user/class/userbankaccount.class.php | 312 +- htdocs/user/class/usergroup.class.php | 114 +- htdocs/user/clicktodial.php | 200 +- htdocs/user/document.php | 26 +- htdocs/user/group/card.php | 132 +- htdocs/user/group/ldap.php | 16 +- htdocs/user/group/list.php | 170 +- htdocs/user/hierarchy.php | 230 +- htdocs/user/home.php | 22 +- htdocs/user/note.php | 34 +- htdocs/user/passwordforgotten.php | 156 +- htdocs/user/perms.php | 2 +- htdocs/user/vcard.php | 10 +- htdocs/variants/admin/admin.php | 14 +- htdocs/variants/ajax/getCombinations.php | 14 +- htdocs/variants/ajax/get_attribute_values.php | 24 +- htdocs/variants/card.php | 8 +- .../class/ProductCombination.class.php | 18 +- .../ProductCombination2ValuePair.class.php | 18 +- htdocs/variants/generator.php | 10 +- htdocs/variants/list.php | 2 +- htdocs/viewimage.php | 116 +- htdocs/webservices/admin/index.php | 26 +- htdocs/webservices/server_category.php | 36 +- htdocs/webservices/server_invoice.php | 702 ++-- htdocs/webservices/server_order.php | 10 +- htdocs/webservices/server_payment.php | 222 +- .../webservices/server_productorservice.php | 102 +- htdocs/webservices/server_project.php | 554 +-- .../webservices/server_supplier_invoice.php | 412 +- htdocs/webservices/server_thirdparty.php | 682 ++-- htdocs/webservices/server_user.php | 238 +- htdocs/website/class/website.class.php | 180 +- htdocs/website/class/websitepage.class.php | 4 +- htdocs/website/index.php | 18 +- htdocs/zapier/admin/setup.php | 68 +- htdocs/zapier/hook_agenda.php | 86 +- htdocs/zapier/hook_document.php | 4 +- htdocs/zapier/lib/zapier.lib.php | 44 +- scripts/bank/export-bank-receipts.php | 18 +- scripts/cron/cron_run_jobs.php | 6 +- scripts/user/sync_groups_ldap2dolibarr.php | 2 +- 1177 files changed, 82257 insertions(+), 82262 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 88282447c51..47a984cd467 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -65,12 +65,12 @@ if (!$sortfield) $sortfield = "aa.account_number"; if (!$sortorder) $sortorder = "ASC"; $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), + 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), + 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); @@ -93,24 +93,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (!empty($cancel)) $action = ''; + if (!empty($cancel)) $action = ''; - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $search_account = ""; - $search_label = ""; + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_account = ""; + $search_label = ""; $search_labelshort = ""; $search_accountparent = ""; - $search_pcgtype = ""; + $search_pcgtype = ""; $search_array_options = array(); - } - if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on - || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified - { - if ($chartofaccounts > 0) - { + } + if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified + { + if ($chartofaccounts > 0) + { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; @@ -147,34 +147,34 @@ if (empty($reshook)) } } - if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } - } + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } + } - if ($action == 'disable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->accountDeactivate($id, $mode); - } + if ($action == 'disable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->accountDeactivate($id, $mode); + } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } elseif ($action == 'enable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->account_activate($id, $mode); - } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } elseif ($action == 'enable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->account_activate($id, $mode); + } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } } @@ -273,9 +273,9 @@ if ($resql) if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if (!empty($conf->use_javascript_ajax)) - { - print ' + if (!empty($conf->use_javascript_ajax)) + { + print ' '; - } + } print ''; if ($optioncss != '') print ''; @@ -296,48 +296,48 @@ if ($resql) print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); // Box to select active chart of account - print $langs->trans("Selectchartofaccounts")." : "; - print ''; + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; + $sql .= " WHERE a.active = 1"; + dol_syslog('accountancy/admin/account.php $sql='.$sql); + print $sql; + $resqlchart = $db->query($sql); + if ($resqlchart) { + $numbis = $db->num_rows($resqlchart); + $i = 0; + while ($i < $numbis) { + $obj = $db->fetch_object($resqlchart); - print ''; + print ''; - $i++; - } - } else dol_print_error($db); - print ""; - print ajax_combobox("chartofaccounts"); - print ''; + $i++; + } + } else dol_print_error($db); + print ""; + print ajax_combobox("chartofaccounts"); + print ''; - print '
'; + print '
'; print '
'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $moreforfilter = ''; - $massactionbutton = ''; + $moreforfilter = ''; + $massactionbutton = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; // Line for search fields print ''; @@ -358,7 +358,7 @@ if ($resql) print ''; print ''; - print ''; + print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); @@ -422,7 +422,7 @@ if ($resql) print ''; $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; - $accountparent->account_number = $obj->account_number2; // Sotre an account number for output + $accountparent->account_number = $obj->account_number2; // Sotre an account number for output print $accountparent->getNomUrl(1); print "\n"; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d3bd17d95a5..acec1468d79 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -472,13 +472,13 @@ if ($id) if ($valuetoshow != '') { print ''; } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index d015d8f07b5..b4f90f19675 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -108,16 +108,16 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) setEventMessages($object->error, $object->errors, 'errors'); } elseif ($res < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } if (!$error) { - setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); - header("Location: ".$urltogo); - exit; + setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + header("Location: ".$urltogo); + exit; } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { @@ -158,15 +158,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $result = $object->update($user); if ($result > 0) { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } else { $mesg = $object->error; } } else { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } } elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) { diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9469a1e64f1..c9adac2f5a3 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -135,249 +135,249 @@ $sourceList = array(); if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert = explode(',', $tabfieldinsert[$id]); - $listfieldmodify = explode(',', $tabfieldinsert[$id]); - $listfieldvalue = explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); - // Check that all fields are filled - $ok = 1; - foreach ($listfield as $f => $value) - { + // Check that all fields are filled + $ok = 1; + foreach ($listfield as $f => $value) + { if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'country' || $value == 'country_id') continue; if (!GETPOSTISSET($value) || GETPOST($value) == '') - { - $ok = 0; - $fieldnamekey = $listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; + { + $ok = 0; + $fieldnamekey = $listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; + if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } - } - if (isset($_POST["code"])) - { - if ($_POST["code"] == '0') - { - $ok = 0; - setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); - } - } - if (!is_numeric(GETPOST('position', 'alpha'))) - { - $langs->loadLangs(array("errors")); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + } + } + if (isset($_POST["code"])) + { + if ($_POST["code"] == '0') + { + $ok = 0; + setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); + } + } + if (!is_numeric(GETPOST('position', 'alpha'))) + { + $langs->loadLangs(array("errors")); $ok = 0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); - } + } // Clean some parameters if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd', 'alpha')) - { - if ($tabrowid[$id]) - { - // Recupere id libre pour insertion - $newid = 0; - $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; - $result = $db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - $newid = ($obj->newid + 1); - } else { - dol_print_error($db); - } - } + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd', 'alpha')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $newid = 0; + $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $newid = ($obj->newid + 1); + } else { + dol_print_error($db); + } + } - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; - $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; - $sql .= " VALUES("; + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; - // List of values - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; - $i = 0; - foreach ($listfieldinsert as $f => $value) - { - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= ",1)"; + // List of values + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; + $i = 0; + foreach ($listfieldinsert as $f => $value) + { + if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql .= ",1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST = array('id'=>$id); // Clean $_POST array, we keep only - } else { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST = array('id'=>$id); // Clean $_POST array, we keep only + } else { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify', 'alpha')) - { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify', 'alpha')) + { + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) - { - $sql .= $tabrowid[$id]."="; - $sql .= "'".$db->escape($rowid)."', "; - } - $i = 0; - foreach ($listfieldmodify as $field) - { - if ($field == 'fk_country' && $_POST['country'] > 0) { - $_POST[$listfieldvalue[$i]] = $_POST['country']; - } elseif ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - $sql .= $field."="; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) + { + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'fk_country' && $_POST['country'] > 0) { + $_POST[$listfieldvalue[$i]] = $_POST['country']; + } elseif ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + $sql .= $field."="; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if (!$resql) - { - setEventMessages($db->error(), null, 'errors'); - } - } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (!$resql) + { + setEventMessages($db->error(), null, 'errors'); + } + } + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } else { - dol_print_error($db); - } - } + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } else { + dol_print_error($db); + } + } } // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } @@ -401,7 +401,7 @@ print ''.$langs->trans("AccountingAccountGroupsDesc" // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -410,407 +410,407 @@ if ($action == 'delete') */ if ($id) { - // Complete requete recherche valeurs avec critere de tri - $sql = $tabsql[$id]; + // Complete requete recherche valeurs avec critere de tri + $sql = $tabsql[$id]; - if ($search_country_id > 0) - { - if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; - else $sql .= " WHERE "; - $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; - } + if ($search_country_id > 0) + { + if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; + else $sql .= " WHERE "; + $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; + } - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield = 'country_code'; - $sql .= $db->order($sortfield, $sortorder); - $sql .= $db->plimit($listlimit + 1, $offset); - //print $sql; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($listlimit + 1, $offset); + //print $sql; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; - print '
'; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); - } else { - print $valuetoshow; - } + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { + print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif (!empty($tabhelp[$id][$value])) { + print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + } else { + print $valuetoshow; + } print '
'; + print '
'; - // Form to add a new line - if ($tabname[$id]) - { - $alabelisused = 0; + // Form to add a new line + if ($tabname[$id]) + { + $alabelisused = 0; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - // Line for title - print ''; - foreach ($fieldlist as $field => $value) - { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - $class = "left"; - if ($fieldlist[$field] == 'type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { - $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - } else { - $valuetoshow = $langs->trans("Type"); - } - } - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } - if ($fieldlist[$field] == 'libelle_facture') { - $valuetoshow = $langs->trans("LabelOnDocuments"); - } - if ($fieldlist[$field] == 'country') { - $valuetoshow = $langs->trans("Country"); - } - if ($fieldlist[$field] == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($fieldlist[$field] == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - } - if ($fieldlist[$field] == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - } - if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($fieldlist[$field] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } - if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - - if ($valuetoshow != '') { - print ''; - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to enter new values - print ''; - - $obj = new stdClass(); - // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd', 'alpha')) - { - foreach ($fieldlist as $key=>$val) - { - if (GETPOST($val) != '') - $obj->$val = GETPOST($val); - } - } - - $tmpaction = 'create'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; - - if (empty($reshook)) - { - fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); - } - - print ''; - print ""; - - $colspan = count($fieldlist) + 3; - if ($id == 32) $colspan++; - - print ''; // Keep   to have a line with enough height - } - - // List of available record in database - dol_syslog("htdocs/admin/dict", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - $param = '&id='.$id; - if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; - if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; - if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - // There is several pages - if ($num > $listlimit) - { - print ''; - } - - // Title line with search boxes - print ''; - $filterfound = 0; - foreach ($fieldlist as $field => $value) - { - $showfield = 1; // By defaut - - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } - - if ($showfield) - { - if ($value == 'country') - { - print ''; - $filterfound++; - } else { - print ''; - } - } - } - print ''; - print ''; - print ''; - print ''; - print ''; - - // Title of lines - 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 - $class = "left"; - $sortable = 1; - $valuetoshow = ''; - - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field] == 'source') { - $valuetoshow = $langs->trans("Contact"); - } - if ($fieldlist[$field] == 'price') { - $valuetoshow = $langs->trans("PriceUHT"); - } - if ($fieldlist[$field] == 'taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { - $valuetoshow = $langs->trans("Rate"); - } else { - $valuetoshow = $langs->trans("Amount"); - } - $class = 'center'; - } - if ($fieldlist[$field] == 'type') { - $valuetoshow = $langs->trans("Type"); - } - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } - if ($fieldlist[$field] == 'country') { - $valuetoshow = $langs->trans("Country"); - } - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } - if ($fieldlist[$field] == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($fieldlist[$field] == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - $sortable = 0; - } - if ($fieldlist[$field] == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - $sortable = 0; - } - if ($fieldlist[$field] == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($fieldlist[$field] == 'account_parent') { - $valuetoshow = $langs->trans("Accountsparent"); - } - if ($fieldlist[$field] == 'pcg_type') { - $valuetoshow = $langs->trans("Pcg_type"); - } - if ($fieldlist[$field] == 'type_template') { - $valuetoshow = $langs->trans("TypeOfTemplate"); - } + // Line for title + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = "left"; + if ($fieldlist[$field] == 'type') { + if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + } else { + $valuetoshow = $langs->trans("Type"); + } + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); + } + if ($fieldlist[$field] == 'libelle_facture') { + $valuetoshow = $langs->trans("LabelOnDocuments"); + } + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); + } + if ($fieldlist[$field] == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($fieldlist[$field] == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + } + if ($fieldlist[$field] == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + } + if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } if ($fieldlist[$field] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } + $valuetoshow = $langs->trans("Comment"); + } if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - // Affiche nom du champ - if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); - } - } + $valuetoshow = $langs->trans("Calculated"); + } + + if ($valuetoshow != '') { + print ''; + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Line to enter new values + print ''; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd', 'alpha')) + { + foreach ($fieldlist as $key=>$val) + { + if (GETPOST($val) != '') + $obj->$val = GETPOST($val); + } + } + + $tmpaction = 'create'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; + + if (empty($reshook)) + { + fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); + } + + print ''; + print ""; + + $colspan = count($fieldlist) + 3; + if ($id == 32) $colspan++; + + print ''; // Keep   to have a line with enough height + } + + // List of available record in database + dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $param = '&id='.$id; + if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; + if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); + // There is several pages + if ($num > $listlimit) + { + print ''; + } + + // Title line with search boxes + print ''; + $filterfound = 0; + foreach ($fieldlist as $field => $value) + { + $showfield = 1; // By defaut + + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } + + if ($showfield) + { + if ($value == 'country') + { + print ''; + $filterfound++; + } else { + print ''; + } + } + } + print ''; + print ''; + print ''; + print ''; + print ''; + + // Title of lines + 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 + $class = "left"; + $sortable = 1; + $valuetoshow = ''; + + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'source') { + $valuetoshow = $langs->trans("Contact"); + } + if ($fieldlist[$field] == 'price') { + $valuetoshow = $langs->trans("PriceUHT"); + } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { + $valuetoshow = $langs->trans("Rate"); + } else { + $valuetoshow = $langs->trans("Amount"); + } + $class = 'center'; + } + if ($fieldlist[$field] == 'type') { + $valuetoshow = $langs->trans("Type"); + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); + } + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); + } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } + if ($fieldlist[$field] == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($fieldlist[$field] == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + $sortable = 0; + } + if ($fieldlist[$field] == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + $sortable = 0; + } + if ($fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } + if ($fieldlist[$field] == 'account_parent') { + $valuetoshow = $langs->trans("Accountsparent"); + } + if ($fieldlist[$field] == 'pcg_type') { + $valuetoshow = $langs->trans("Pcg_type"); + } + if ($fieldlist[$field] == 'type_template') { + $valuetoshow = $langs->trans("TypeOfTemplate"); + } + if ($fieldlist[$field] == 'range_account') { + $valuetoshow = $langs->trans("Comment"); + } + if ($fieldlist[$field] == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); + } + // Affiche nom du champ + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); + } + } print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print ''; + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print ''; - if ($num) - { - // Lines with values - while ($i < $num) - { - $obj = $db->fetch_object($resql); - //print_r($obj); - print ''; - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) - { - $tmpaction = 'edit'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); + //print_r($obj); + print ''; + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) + { + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields - if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); + // Show fields + if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); - print ''; - print ''; - print ''; - print ''; - } else { - $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + print ''; + print ''; + print ''; + print ''; + } else { + $tmpaction = 'view'; + $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { - foreach ($fieldlist as $field => $value) - { - $showfield = 1; - $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'category_type') - { - $valuetoshow = yn($valuetoshow); - } elseif ($valuetoshow == 'all') { - $valuetoshow = $langs->trans('All'); - } elseif ($fieldlist[$field] == 'country') { - if (empty($obj->country_code)) - { - $valuetoshow = '-'; - } else { - $key = $langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); - } - } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { - $key = $langs->trans("Country".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { - $langs->loadLangs(array("propal")); - $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { - $key = $langs->trans("Action".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + $showfield = 1; + $class = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($value == 'category_type') + { + $valuetoshow = yn($valuetoshow); + } elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); + } elseif ($fieldlist[$field] == 'country') { + if (empty($obj->country_code)) + { + $valuetoshow = '-'; + } else { + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); + } + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + $key = $langs->trans("Country".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { + $langs->loadLangs(array("propal")); + $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + $key = $langs->trans("Action".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } - $class = 'tddict'; + $class = 'tddict'; // Show value for field if ($showfield) print ''; - } - } + } + } - // Can an entry be erased or disabled ? - $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - if (isset($obj->code)) - { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } - } + // Can an entry be erased or disabled ? + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (isset($obj->code)) + { + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } + } - $canbemodified = $iserasable; + $canbemodified = $iserasable; - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if ($param) $url .= '&'.$param; - $url .= '&'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if ($param) $url .= '&'.$param; + $url .= '&'; - // Active - print '"; + // Active + print '"; - // Modify link - if ($canbemodified) print ''; - else print ''; + // Modify link + if ($canbemodified) print ''; + else print ''; - // Delete link - if ($iserasable) - { - print ''; - } else print ''; + // Delete link + if ($iserasable) + { + print ''; + } else print ''; - // Link to setup the group - print ''; - } - print "\n"; - $i++; - } - } - } else { - dol_print_error($db); - } + // Link to setup the group + print ''; + } + print "\n"; + $i++; + } + } + } else { + dol_print_error($db); + } - print '
'; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); - else print $valuetoshow; - print ''; - print ''; - print '
'; - print ''; - print '
 
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); - print ''; - if ($filterfound) - { - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - } - print '
'; + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + else print $valuetoshow; + print ''; + print ''; + print '
'; + print ''; + print '
 
'; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
'; + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print ''; + if ($filterfound) + { + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print '
'; - print ''; - print ''; - print ''; - print '
'; - print ''; - print '
'; + print ''; + print ''; + print ''; + print '
'; + print ''; + print '
'.$valuetoshow.''; - if ($canbedisabled) print ''.$actl[$obj->active].''; - else { - print $langs->trans("AlwaysActive"); - } - print "'; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else { + print $langs->trans("AlwaysActive"); + } + print "'.img_edit().' '.img_edit().' '; - if ($user->admin) print ''.img_delete().''; - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin - print ' '; + if ($user->admin) print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin + print ' '; - if (empty($obj->formula)) - { - print ''; - print $langs->trans("ListOfAccounts"); - print ''; - } - print '
'; + if (empty($obj->formula)) + { + print ''; + print $langs->trans("ListOfAccounts"); + print ''; + } + print '
'; + print '
'; print '
'; - print ''; + print ''; } print '
'; @@ -865,7 +865,7 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co print ''; } } elseif ($fieldlist[$field] == 'category_type') { - print ''; + print ''; print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index a425fd45768..7e781b3fc71 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -39,8 +39,8 @@ $action = GETPOST('action', 'aZ09'); $list_account_main = array( - 'ACCOUNTING_RESULT_PROFIT', - 'ACCOUNTING_RESULT_LOSS' + 'ACCOUNTING_RESULT_PROFIT', + 'ACCOUNTING_RESULT_LOSS' ); /* @@ -48,17 +48,17 @@ $list_account_main = array( */ if ($action == 'update') { - $error = 0; + $error = 0; - $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); + $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); - if (!empty($defaultjournal)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (!empty($defaultjournal)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); @@ -99,20 +99,20 @@ print ''; print ''; foreach ($list_account_main as $key) { - print ''; - // Param - $label = $langs->trans($key); - $keydesc = $key.'_Desc'; + print ''; + // Param + $label = $langs->trans($key); + $keydesc = $key.'_Desc'; - $htmltext = $langs->trans($keydesc); - print ''; - // Value - print ''; - print ''; + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; } // Journal diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index b2262c603f9..ba45220c8cc 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_EXPORT_* $main_option = array( - 'ACCOUNTING_EXPORT_PREFIX_SPEC', + 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); $configuration = AccountancyExport::getTypeConfig(); @@ -58,22 +58,22 @@ $listcr = $configuration['cr']; $model_option = array( - '1' => array( - 'label' => 'ACCOUNTING_EXPORT_FORMAT', - 'param' => $listformat, - ), - '2' => array( - 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', - 'param' => '', - ), - '3' => array( - 'label' => 'ACCOUNTING_EXPORT_ENDLINE', - 'param' => $listcr, - ), - '4' => array( - 'label' => 'ACCOUNTING_EXPORT_DATE', - 'param' => '', - ), + '1' => array( + 'label' => 'ACCOUNTING_EXPORT_FORMAT', + 'param' => $listformat, + ), + '2' => array( + 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', + 'param' => '', + ), + '3' => array( + 'label' => 'ACCOUNTING_EXPORT_ENDLINE', + 'param' => $listcr, + ), + '4' => array( + 'label' => 'ACCOUNTING_EXPORT_DATE', + 'param' => '', + ), ); @@ -105,22 +105,22 @@ if ($action == 'update') { } } - foreach ($listparam[$modelcsv] as $key => $value) { - $constante = $key; + foreach ($listparam[$modelcsv] as $key => $value) { + $constante = $key; - if (strpos($constante, 'ACCOUNTING') !== false) { - $constvalue = GETPOST($key, 'alpha'); - if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - } + if (strpos($constante, 'ACCOUNTING') !== false) { + $constvalue = GETPOST($key, 'alpha'); + if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + } if (!$error) { - // reload - $configuration = AccountancyExport::getTypeConfig(); - $listparam = $configuration['param']; - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + // reload + $configuration = AccountancyExport::getTypeConfig(); + $listparam = $configuration['param']; + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } @@ -148,36 +148,36 @@ print 'jQuery(document).ready(function () {'."\n"; print ' function initfields()'."\n"; print ' {'."\n"; foreach ($listparam as $key => $param) { - print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; - print ' {'."\n"; - print ' //console.log("'.$param['label'].'");'."\n"; - if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_DATE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; - } - print ' }'."\n"; + print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; + print ' {'."\n"; + print ' //console.log("'.$param['label'].'");'."\n"; + if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_DATE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; + } + print ' }'."\n"; } print ' }'."\n"; print ' initfields();'."\n"; @@ -262,17 +262,17 @@ if ($num2) { foreach ($model_option as $key) { print ''; - // Param - $label = $key['label']; + // Param + $label = $key['label']; print ''; // Value - print ''; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 1ddcddf13e6..4aa1fd99ff4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -113,7 +113,7 @@ if ($result) $i = 0; - $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); + $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $title = $langs->trans('AccountingPeriods'); diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 819160e7d23..68a9660a0e9 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -420,15 +420,15 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $class = "left"; - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } - if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + if ($fieldlist[$field] == 'nature') { + $valuetoshow = $langs->trans("NatureOfJournal"); + } if ($valuetoshow != '') { print ''; + print ''; + print '
'; - print $form->textwithpicto($label, $htmltext); - print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); - print '
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force class=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
'.$langs->trans($label).''; - if (is_array($key['param'])) { - print $form->selectarray($label, $key['param'], $conf->global->$label, 0); - } else { - print ''; - } + print ''; + if (is_array($key['param'])) { + print $form->selectarray($label, $key['param'], $conf->global->$label, 0); + } else { + print ''; + } print '
'; @@ -540,14 +540,14 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } + $valuetoshow = $langs->trans("Label"); + } if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + $valuetoshow = $langs->trans("NatureOfJournal"); + } // Affiche nom du champ if ($showfield) { @@ -594,7 +594,7 @@ if ($id) if (empty($reshook)) { - $langs->load("accountancy"); + $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { $showfield = 1; @@ -607,7 +607,7 @@ if ($id) $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { $valuetoshow = $langs->trans($obj->label); - } + } $class = 'tddict'; // Show value for field @@ -619,15 +619,15 @@ if ($id) $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default if (isset($obj->code) && $id != 10) { if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { - $iserasable = 0; - $canbedisabled = 0; - } elseif ($obj->code == 'RECEP') { - $iserasable = 0; - $canbedisabled = 0; - } elseif ($obj->code == 'EF0') { - $iserasable = 0; - $canbedisabled = 0; - } + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'RECEP') { + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'EF0') { + $iserasable = 0; + $canbedisabled = 0; + } } $canbemodified = $iserasable; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d88800016a8..3c0523ac877 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -42,7 +42,7 @@ if (empty($conf->accounting->enabled)) { accessforbidden(); } if (!$user->rights->accounting->bind->write) - accessforbidden(); + accessforbidden(); // search & action GETPOST $action = GETPOST('action', 'aZ09'); @@ -100,14 +100,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref = ''; - $search_label = ''; - $search_desc = ''; + $search_ref = ''; + $search_label = ''; + $search_desc = ''; $search_vat = ''; - $search_onsell = ''; - $search_onpurchase = ''; - $search_current_account = ''; - $search_current_account_valid = '-1'; + $search_onsell = ''; + $search_onpurchase = ''; + $search_current_account = ''; + $search_current_account_valid = '-1'; } // Sales or Purchase mode ? @@ -117,8 +117,8 @@ if ($action == 'update') { $accounting_product_modes = array( 'ACCOUNTANCY_SELL', - 'ACCOUNTANCY_SELL_INTRA', - 'ACCOUNTANCY_SELL_EXPORT', + 'ACCOUNTANCY_SELL_INTRA', + 'ACCOUNTANCY_SELL_EXPORT', 'ACCOUNTANCY_BUY', 'ACCOUNTANCY_BUY_INTRA', 'ACCOUNTANCY_BUY_EXPORT' @@ -172,22 +172,22 @@ if ($action == 'update') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; - } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; + } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; + } $sql .= " WHERE rowid = ".((int) $productid); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $ok++; - $db->commit(); + $ok++; + $db->commit(); } else { - $ko++; - $db->rollback(); + $ko++; + $db->rollback(); } } @@ -253,7 +253,7 @@ $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; @@ -271,9 +271,9 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); @@ -283,17 +283,17 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); + } } else { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); + } } if ($search_current_account_valid == 'withoutvalidaccount') { @@ -301,7 +301,7 @@ if ($search_current_account_valid == 'withoutvalidaccount') } if ($search_current_account_valid == 'withvalidaccount') { - $sql .= " AND aa.account_number IS NOT NULL"; + $sql .= " AND aa.account_number IS NOT NULL"; } // Add search filter like if (strlen(trim($search_ref))) { @@ -324,13 +324,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -342,32 +342,32 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); - if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); - if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); + if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); + if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat); - if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); - if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); - if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); + if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); + if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); + if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); + print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; print ''.$langs->trans("InitAccountancyDesc").'
'; print '
'; - // Select mode + // Select mode print ''; print ''; print ''; @@ -377,13 +377,13 @@ if ($result) print "\n"; if ($mysoc->isInEEC()) { - print ''; - print '\n"; + print ''; + print '\n"; } - print ''; - print '\n"; + print ''; + print '\n"; print ''; print '\n"; if ($mysoc->isInEEC()) @@ -405,8 +405,8 @@ if ($result) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $buttonsave = ''; - //print '
'.$buttonsave.'
'; + $buttonsave = ''; + //print '
'.$buttonsave.'
'; $texte = $langs->trans("ListOfProductsServices"); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); @@ -444,22 +444,22 @@ if ($result) print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); // On sell / On purchase - if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_intra"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_export"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_intra"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_export"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_buy"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount = "p.accountancy_code_buy_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { @@ -475,8 +475,8 @@ if ($result) $product_static = new Product($db); $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) + { $obj = $db->fetch_object($result); // Ref produit as link @@ -494,12 +494,12 @@ if ($result) $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_intra; + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_export; - } else { + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_export; + } else { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } @@ -560,11 +560,11 @@ if ($result) if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { - // TODO ADJUST DESCRIPTION SIZE - // print ''; - // TODO: we should set a user defined value to adjust user square / wide screen size - $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + print ''; } // VAT @@ -581,30 +581,30 @@ if ($result) // Current accounting account print ''; // New account to set $defaultvalue = ''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - // Accounting account buy + // Accounting account buy print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - // Accounting account sell intra (In EEC) - print ''; - } else { - // Accounting account sell export (Out of EEC) - print ''; - } + // Accounting account sell intra (In EEC) + print ''; + } else { + // Accounting account sell export (Out of EEC) + print ''; + } // Checkbox select print ''; + print ''; } // Action column print '\n"; + print "\n"; if (!$i) $totalarray['nbfield']++; } @@ -1065,9 +1065,9 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; + print '
'; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7c6d6719235..45e8c6aee70 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -138,7 +138,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 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 { @@ -172,55 +172,55 @@ if (empty($reshook)) if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte=' . urlencode($search_label_account); + $param .= '&search_label_compte='.urlencode($search_label_account); } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode($search_mvt_num); } if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + $param .= '&search_doc_ref='.urlencode($search_doc_ref); } if (!empty($search_label_operation)) { $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation=' . urlencode($search_label_operation); + $param .= '&search_label_operation='.urlencode($search_label_operation); } if (!empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . urlencode($search_direction); + $param .= '&search_direction='.urlencode($search_direction); } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + $param .= '&search_ledger_code='.urlencode($search_ledger_code); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . urlencode($search_debit); + $param .= '&search_debit='.urlencode($search_debit); } if (!empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . urlencode($search_credit); + $param .= '&search_credit='.urlencode($search_credit); } if (!empty($search_lettering_code)) { $filter['t.lettering_code'] = $search_lettering_code; @@ -426,7 +426,7 @@ print ''; // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { @@ -446,19 +446,19 @@ if (!empty($arrayfields['t.piece_num']['checked'])) } // Ref document if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; + print ''; } // Label operation if (!empty($arrayfields['t.label_operation']['checked'])) { - print ''; + print ''; } // Debit if (!empty($arrayfields['t.debit']['checked'])) { - print ''; + print ''; } // Credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; } // Lettering code if (!empty($arrayfields['t.lettering_code']['checked'])) @@ -534,7 +534,7 @@ while ($i < min($num, $limit)) $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; - if ($balance > 0 ) + if ($balance > 0) { print '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; if (!$i) $totalarray['nbfield']++; } @@ -680,7 +680,7 @@ while ($i < min($num, $limit)) // Amount credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['val']['totalcredit'] += $line->credit; @@ -733,7 +733,7 @@ print ''; $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; -if ($balance > 0 ) +if ($balance > 0) { print ''; + print ''; + print ''; } print ''; } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 1a37bb1019b..90f3d4c04ef 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -50,7 +50,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (!$cancel) { - if ($codeventil < 0) $codeventil = 0; + if ($codeventil < 0) $codeventil = 0; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql .= " SET fk_code_ventilation = ".$codeventil; @@ -60,12 +60,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - if ($backtopage) - { - header("Location: ".$backtopage); - exit(); - } + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + if ($backtopage) + { + header("Location: ".$backtopage); + exit(); + } } } else { header("Location: ./lines.php"); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 80ed833b828..20010cc8f5c 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -45,14 +45,14 @@ $hookmanager->initHooks(array('accountancyindex')); if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { - require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone = GETPOST('areacode', 'aZ09'); - $userid = GETPOST('userid', 'int'); - $boxorder = GETPOST('boxorder', 'aZ09'); - $boxorder .= GETPOST('boxcombo', 'aZ09'); + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); - if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } @@ -64,11 +64,11 @@ llxHeader('', $langs->trans("AccountancyArea")); if ($conf->accounting->enabled) { - $step = 0; + $step = 0; - $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. + $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; if (!$helpisexpanded) @@ -92,9 +92,9 @@ if ($conf->accounting->enabled) print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); - print '
'; // hideobject is to start hidden - print "
\n"; - print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; + print '
'; // hideobject is to start hidden + print "
\n"; + print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; print "
\n"; print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; @@ -132,9 +132,9 @@ if ($conf->accounting->enabled) if (!empty($conf->tax->enabled)) { $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); + print "
\n"; } /*if (! empty($conf->salaries->enabled)) { @@ -146,9 +146,9 @@ if ($conf->accounting->enabled) }*/ if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); + print "
\n"; } /* if (! empty($conf->loan->enabled)) @@ -177,7 +177,7 @@ if ($conf->accounting->enabled) print '
'; - // Step A - E + // Step A - E print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); @@ -199,7 +199,7 @@ if ($conf->accounting->enabled) { $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."\n"; - print "
\n"; + print "
\n"; } $step++; @@ -214,36 +214,36 @@ if ($conf->accounting->enabled) print '
'; - print '
'; + print '
'; - print '
'; + print '
'; - /* + /* * Show boxes */ - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= $resultboxes['boxlista']; + $boxlist .= $resultboxes['boxlista']; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= $resultboxes['boxlistb']; + $boxlist .= $resultboxes['boxlistb']; - $boxlist .= '
'; - $boxlist .= "\n"; + $boxlist .= '
'; + $boxlist .= "\n"; - $boxlist .= '
'; + $boxlist .= '
'; - print $boxlist; + print $boxlist; - print '
'; + print '
'; } else { - print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); + print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); print ''.$langs->trans("Module10Desc")."
\n"; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 29777316a64..baafcfe5e87 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -394,9 +394,9 @@ if ($result) { $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word - $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word - $tabpay[$obj->rowid]["account_various"] = $account_various; - $tabtp[$obj->rowid][$account_subledger] += $obj->amount; + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word + $tabpay[$obj->rowid]["account_various"] = $account_various; + $tabtp[$obj->rowid][$account_subledger] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; @@ -668,7 +668,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = $k; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; $accountingaccount->fetch(null, $bookkeeping->numero_compte, true); @@ -954,8 +954,8 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; @@ -991,11 +991,11 @@ if (empty($action) || $action == 'view') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print ''; if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' - || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print ''; + || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print ''.$langs->trans("WriteBookKeeping").''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index bf8275cee1c..26e2b4cdf77 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -110,11 +110,11 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { // Already in bookkeeping or not if ($in_bookkeeping == 'already') { - $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; + $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; } if ($in_bookkeeping == 'notyet') { - $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; + $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; } $sql .= " ORDER BY er.date_debut"; @@ -370,8 +370,8 @@ if ($action == 'writebookkeeping') { if ($error >= 10) { - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); - break; // Break in the foreach + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach } } } @@ -433,48 +433,48 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print "\n"; foreach ($taber as $key => $val) { - $date = dol_print_date($val["date"], 'day'); + $date = dol_print_date($val["date"], 'day'); - $userstatic->id = $tabuser[$key]['id']; - $userstatic->name = $tabuser[$key]['name']; + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; - // Fees - foreach ($tabht[$key] as $k => $mt) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); - if ($mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'; - print "\n"; - } - } - // VAT - foreach ($tabtva[$key] as $k => $mt) { - if ($mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'; - print "\n"; - } - } + // Fees + foreach ($tabht[$key] as $k => $mt) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); + if ($mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; + print "\n"; + } + } + // VAT + foreach ($tabtva[$key] as $k => $mt) { + if ($mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; + print "\n"; + } + } - // Third party - foreach ($tabttc[$key] as $k => $mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($userstatic->name).'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'; - } - print "\n"; + // Third party + foreach ($tabttc[$key] as $k => $mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($userstatic->name).'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'; + } + print "\n"; } } @@ -489,8 +489,8 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8e409b497b5..a656643be57 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -719,8 +719,8 @@ if (empty($action) || $action == 'view') { } $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 589bad72749..debe1fa8cb0 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -130,7 +130,7 @@ if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'notyet') { $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; - // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account + // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } $sql .= " ORDER BY f.datef"; //print $sql; @@ -658,8 +658,8 @@ if (empty($action) || $action == 'view') { } $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index d6b289a76c8..cf13302d866 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -54,7 +54,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (!$cancel) { - if ($codeventil < 0) $codeventil = 0; + if ($codeventil < 0) $codeventil = 0; $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql .= " SET fk_code_ventilation = ".$codeventil; @@ -64,12 +64,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - if ($backtopage) - { - header("Location: ".$backtopage); - exit(); - } + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + if ($backtopage) + { + header("Location: ".$backtopage); + exit(); + } } } else { header("Location: ./lines.php"); diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 17d5f51d6eb..51577218eb9 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -50,27 +50,27 @@ $action = GETPOST('action', 'aZ09'); // if ($action == 'updateall') { - $db->begin(); - $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; - $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); - // Use vat for invoice creation - if ($conf->facture->enabled) { - $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - } - } - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { - setEventMessages('ErrorFailedToSaveDate', null, 'errors'); - $db->rollback(); - } else { - setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); - $db->commit(); - } + $db->begin(); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); + // Use vat for invoice creation + if ($conf->facture->enabled) { + $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + } + } + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } else { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } } // Action to update or add a constant @@ -99,18 +99,18 @@ if ($action == 'update' || $action == 'add') { // Action to enable of a submodule of the adherent module if ($action == 'set') { - $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); - if ($result < 0) { - print $db->error(); - } + $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); + if ($result < 0) { + print $db->error(); + } } // Action to disable a submodule of the adherent module if ($action == 'unset') { - $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); - if ($result < 0) { - print $db->error(); - } + $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); + if ($result < 0) { + print $db->error(); + } } @@ -169,7 +169,7 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty( print ''; print "\n"; diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index ae4f1989114..a391770fdd5 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -95,7 +95,7 @@ if ($action == 'create') { print '

'; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -107,7 +107,7 @@ 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'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 330568c20bf..d0cdb098bae 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -54,22 +54,22 @@ if ($action == 'update') { $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE'); - $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); - if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); - else { - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); - } + $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); + if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); + else { + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); + } - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -97,8 +97,8 @@ print ''; print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); if ($conf->use_javascript_ajax) { - print "\n".''."\n"; + print ''."\n"; } diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 3af330f0066..2e74fdde9be 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -65,8 +65,8 @@ $result = $object->fetch($id); if ($result > 0) { $object->fetch_thirdparty(); - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } @@ -79,17 +79,17 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; - $search_agenda_label = ''; - } + $search_agenda_label = ''; + } } @@ -136,31 +136,31 @@ if ($object->id > 0) { print dol_get_fiche_end(); - //print '
'; - //print '
'; + //print '
'; + //print '
'; $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); - } + if (!empty($conf->agenda->enabled)) { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + print '
'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } } // End of page diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index aa9797959a7..46c4b07b57c 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsAdherentCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -54,52 +54,52 @@ abstract class ActionsAdherentCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - //$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + //$ret = $this->getInstanceDao(); - /*if (is_object($this->object) && method_exists($this->object,'fetch')) + /*if (is_object($this->object) && method_exists($this->object,'fetch')) { if (! empty($id)) $this->object->fetch($id); } else {*/ - $object = new Adherent($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Adherent($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') { - if ($conf->use_javascript_ajax) { + if ($action == 'create' || $action == 'edit') { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; - if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; + if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Physical or Moral - $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); - $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); - } + // Physical or Moral + $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); + $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') { - // Emailing - if (!empty($conf->mailing->enabled)) { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Dolibarr user - if ($this->object->user_id) { + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); + $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; - $this->object->lastname = $_POST["lastname"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->email = $_POST["email"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->lastname = $_POST["lastname"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->email = $_POST["email"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_object($resql); + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; - } else { - dol_print_error($this->db); - } - } - } + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; + } else { + dol_print_error($this->db); + } + } + } } diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index db2473c55d9..43d6622f8c9 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -31,21 +31,21 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.cl class ActionsAdherentCardDefault extends ActionsAdherentCardCommon { /** - * Constructor - * - * @param DoliDB $db Handler acces data base - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) + * Constructor + * + * @param DoliDB $db Handler acces data base + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) */ public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -77,47 +77,47 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = member_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = member_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); - } else { + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->adherent->supprimer) { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,11 +129,11 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { - // phpcs:enable + // phpcs:enable global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); + $this->list_datas = array(); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 8789b2fcb34..539e174681f 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -118,21 +118,21 @@ if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['acti control->tpl['showend']; if (empty($user->socid)) { - echo '
'; + echo '
'; - if ($user->rights->adherent->creer) { - echo ''.$langs->trans('Modify').''; - } + if ($user->rights->adherent->creer) { + echo ''.$langs->trans('Modify').''; + } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { - echo ''.$langs->trans("CreateDolibarrLogin").''; - } + if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + echo ''.$langs->trans("CreateDolibarrLogin").''; + } - if ($user->rights->adherent->supprimer) { - echo ''.$langs->trans('Delete').''; - } + if ($user->rights->adherent->supprimer) { + echo ''.$langs->trans('Delete').''; + } - echo '

'; + echo '

'; } echo $this->control->tpl['actionstodo']; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 4bffb8bc0db..096a0195668 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -218,7 +218,7 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; - if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) + if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) { $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 958750178f1..b62f58117a2 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -56,163 +56,163 @@ $extrafields->fetch_name_optionals_label($object->table_element); */ if ($mode == 'cardlogin' && empty($foruserlogin)) { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); } if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { - $arrayofmembers = array(); + $arrayofmembers = array(); - // request taking into account member with up to date subscriptions - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; - $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; - $sql .= " t.libelle as type,"; - $sql .= " c.code as country_code, c.label as country"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; - $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; - $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; - if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; - $sql .= " ORDER BY d.rowid ASC"; + // request taking into account member with up to date subscriptions + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; + $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; + $sql .= " t.libelle as type,"; + $sql .= " c.code as country_code, c.label as country"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; + $sql .= " ORDER BY d.rowid ASC"; - dol_syslog("Search members", LOG_DEBUG); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + dol_syslog("Search members", LOG_DEBUG); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - if ($objp->country == '-') $objp->country = ''; + if ($objp->country == '-') $objp->country = ''; - $adherentstatic->id = $objp->rowid; - $adherentstatic->lastname = $objp->lastname; - $adherentstatic->firstname = $objp->firstname; + $adherentstatic->id = $objp->rowid; + $adherentstatic->lastname = $objp->lastname; + $adherentstatic->firstname = $objp->firstname; - // Format extrafield so they can be parsed in function complete_substitutions_array - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $adherentstatic->array_options = array(); - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $tmpkey = 'options_'.$key; - if (!empty($objp->$tmpkey)) { - $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; - } - //if (!empty($objp->$key)) - // $objp->array_options[$tmpkey] = $objp->$key; - //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; - } - } + // Format extrafield so they can be parsed in function complete_substitutions_array + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $adherentstatic->array_options = array(); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $tmpkey = 'options_'.$key; + if (!empty($objp->$tmpkey)) { + $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; + } + //if (!empty($objp->$key)) + // $objp->array_options[$tmpkey] = $objp->$key; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + } + } - // List of values to scan for a replacement - $substitutionarray = array( - '__ID__'=>$objp->rowid, - '__LOGIN__'=>$objp->login, - '__FIRSTNAME__'=>$objp->firstname, - '__LASTNAME__'=>$objp->lastname, - '__FULLNAME__'=>$adherentstatic->getFullName($langs), - '__COMPANY__'=>$objp->company, - '__ADDRESS__'=>$objp->address, - '__ZIP__'=>$objp->zip, - '__TOWN__'=>$objp->town, - '__COUNTRY__'=>$objp->country, - '__COUNTRY_CODE__'=>$objp->country_code, - '__EMAIL__'=>$objp->email, - '__BIRTH__'=>dol_print_date($objp->birth, 'day'), - '__TYPE__'=>$objp->type, - '__YEAR__'=>$year, - '__MONTH__'=>$month, - '__DAY__'=>$day, - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" - ); - complete_substitutions_array($substitutionarray, $langs, $adherentstatic); + // List of values to scan for a replacement + $substitutionarray = array( + '__ID__'=>$objp->rowid, + '__LOGIN__'=>$objp->login, + '__FIRSTNAME__'=>$objp->firstname, + '__LASTNAME__'=>$objp->lastname, + '__FULLNAME__'=>$adherentstatic->getFullName($langs), + '__COMPANY__'=>$objp->company, + '__ADDRESS__'=>$objp->address, + '__ZIP__'=>$objp->zip, + '__TOWN__'=>$objp->town, + '__COUNTRY__'=>$objp->country, + '__COUNTRY_CODE__'=>$objp->country_code, + '__EMAIL__'=>$objp->email, + '__BIRTH__'=>dol_print_date($objp->birth, 'day'), + '__TYPE__'=>$objp->type, + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" + ); + complete_substitutions_array($substitutionarray, $langs, $adherentstatic); - // For business cards - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + // For business cards + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); - if (is_numeric($foruserid) || $foruserlogin) { - $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; - if ($nb <= 0) $nb = 1; // Protection to avoid empty page + if (is_numeric($foruserid) || $foruserlogin) { + $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; + if ($nb <= 0) $nb = 1; // Protection to avoid empty page - for ($j = 0; $j < $nb; $j++) { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } else { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } + for ($j = 0; $j < $nb; $j++) { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } else { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } - // For labels - if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; - $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); - $textheader = ''; - $textfooter = ''; - $textright = ''; + // For labels + if ($mode == 'label') { + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; + $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader = ''; + $textfooter = ''; + $textright = ''; - $arrayofmembers[] = array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); - } + $arrayofmembers[] = array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } - $i++; - } + $i++; + } - // Build and output PDF - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($model) || $model == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); - } - if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); - } elseif ($mode == 'label') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($modellabel) || $modellabel == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); - } - if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); - } + // Build and output PDF + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($model) || $model == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); + } + if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); + } elseif ($mode == 'label') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($modellabel) || $modellabel == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + } + if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); + } - if ($result <= 0) { - dol_print_error('', $result); - } - } else { - dol_print_error($db); - } + if ($result <= 0) { + dol_print_error('', $result); + } + } else { + dol_print_error($db); + } - if (!$mesg) { - $db->close(); - exit; - } + if (!$mesg) { + $db->close(); + exit; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index d86a9e21d8c..62d0e03e27e 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -32,18 +32,18 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class AdherentStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $memberid; - public $socid; - public $userid; + public $memberid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** @@ -51,15 +51,15 @@ class AdherentStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $userid Id user for filter + * @param int $userid Id user for filter */ public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Subscription($this->db); @@ -74,16 +74,16 @@ class AdherentStats extends Stats if ($this->memberid) { $this->where .= " AND m.rowid = ".$this->memberid; } - //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } /** * Return the number of proposition by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of nb each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of nb each month */ public function getNbByMonth($year, $format = 0) { @@ -95,7 +95,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByMonth($year, $sql, $format); } @@ -103,7 +103,7 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by year * - * @return array Array of nb each year + * @return array Array of nb each year */ public function getNbByYear() { @@ -114,7 +114,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -122,9 +122,9 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of amount each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of amount each month */ public function getAmountByMonth($year, $format = 0) { @@ -136,7 +136,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAmountByMonth($year, $sql, $format); } @@ -144,8 +144,8 @@ class AdherentStats extends Stats /** * Return average amount each month * - * @param int $year Year - * @return array Array of average each month + * @param int $year Year + * @return array Array of average each month */ public function getAverageByMonth($year) { @@ -157,7 +157,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -177,7 +177,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 0e611ff80da..bf57d723589 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -94,17 +94,17 @@ class Members extends DolibarrApi */ public function getByThirdparty($thirdparty) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -127,23 +127,23 @@ class Members extends DolibarrApi */ public function getByThirdpartyEmail($email) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'thirdparty not found'); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -166,23 +166,23 @@ class Members extends DolibarrApi */ public function getByThirdpartyBarcode($barcode) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', $barcode); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'thirdparty not found'); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index d5adbb0bc5b..031a7d2b468 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -27,219 +27,219 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class Subscriptions extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'fk_adherent', - 'dateh', - 'datef', - 'amount', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'fk_adherent', + 'dateh', + 'datef', + 'amount', + ); - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + } - /** - * Get properties of a subscription object - * - * Return an array with subscription informations - * - * @param int $id ID of subscription - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + /** + * Get properties of a subscription object + * + * Return an array with subscription informations + * + * @param int $id ID of subscription + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - return $this->_cleanObjectDatas($subscription); - } + return $this->_cleanObjectDatas($subscription); + } - /** - * List subscriptions - * - * Get a list of subscriptions - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" - * @return array Array of subscription objects - * - * @throws RestException - */ - public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List subscriptions + * + * Get a list of subscriptions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" + * @return array Array of subscription objects + * + * @throws RestException + */ + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; - $sql .= ' WHERE 1 = 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 = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; + $sql .= ' WHERE 1 = 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 .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $i = 0; - $num = $this->db->num_rows($result); - while ($i < min($limit, $num)) { - $obj = $this->db->fetch_object($result); - $subscription = new Subscription($this->db); - if ($subscription->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($subscription); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No Subscription found'); - } + $result = $this->db->query($sql); + if ($result) { + $i = 0; + $num = $this->db->num_rows($result); + while ($i < min($limit, $num)) { + $obj = $this->db->fetch_object($result); + $subscription = new Subscription($this->db); + if ($subscription->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($subscription); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Subscription found'); + } - return $obj_ret; - } + return $obj_ret; + } - /** - * Create subscription object - * - * @param array $request_data Request data - * @return int ID of subscription - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create subscription object + * + * @param array $request_data Request data + * @return int ID of subscription + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - $subscription = new Subscription($this->db); - foreach ($request_data as $field => $value) { - $subscription->$field = $value; - } - if ($subscription->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); - } - return $subscription->id; - } + $subscription = new Subscription($this->db); + foreach ($request_data as $field => $value) { + $subscription->$field = $value; + } + if ($subscription->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); + } + return $subscription->id; + } - /** - * Update subscription - * - * @param int $id ID of subscription to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } + /** + * Update subscription + * + * @param int $id ID of subscription to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $subscription->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $subscription->$field = $value; + } - if ($subscription->update(DolibarrApiAccess::$user) > 0) { - return $this->get($id); - } else { - throw new RestException(500, $subscription->error); - } - } + if ($subscription->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $subscription->error); + } + } - /** - * Delete subscription - * - * @param int $id ID of subscription to delete - * @return array - */ - public function delete($id) - { - // The right to delete a subscription comes with the right to create one. - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + /** + * Delete subscription + * + * @param int $id ID of subscription to delete + * @return array + */ + public function delete($id) + { + // The right to delete a subscription comes with the right to create one. + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - if (!$subscription->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting subscription'); - } + if (!$subscription->delete(DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when deleting subscription'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'subscription deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'subscription deleted' + ) + ); + } - /** - * Validate fields before creating an object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $subscription = array(); - foreach (Subscriptions::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $subscription[$field] = $data[$field]; - } - return $subscription; - } + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $subscription = array(); + foreach (Subscriptions::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $subscription[$field] = $data[$field]; + } + return $subscription; + } } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5a75fdbae2e..1e6356ee6e4 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -32,435 +32,435 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Subscription extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'subscription'; + /** + * @var string ID to identify managed object + */ + public $element = 'subscription'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'subscription'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'subscription'; - /** - * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table - */ - public $ismultientitymanaged = 'fk_adherent@adherent'; + /** + * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 'fk_adherent@adherent'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + /** + * Date modification record (tms) + * + * @var integer + */ + public $datem; - /** - * Subscription start date (date subscription) - * - * @var integer - */ - public $dateh; + /** + * Subscription start date (date subscription) + * + * @var integer + */ + public $dateh; - /** - * Subscription end date - * - * @var integer - */ - public $datef; + /** + * Subscription end date + * + * @var integer + */ + public $datef; - /** - * @var int ID - */ - public $fk_type; - public $fk_adherent; + /** + * @var int ID + */ + public $fk_type; + public $fk_adherent; - public $amount; + public $amount; - /** - * @var int ID - */ - public $fk_bank; + /** + * @var int ID + */ + public $fk_bank; - public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), - 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), - 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), - 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), - 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), - 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - ); + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), + 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + ); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Function who permitted cretaion of the subscription - * - * @param User $user User that create - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id subscription created if OK - */ - public function create($user, $notrigger = false) - { - global $langs; + /** + * Function who permitted cretaion of the subscription + * + * @param User $user User that create + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id subscription created if OK + */ + public function create($user, $notrigger = false) + { + global $langs; - $error = 0; + $error = 0; - $now = dol_now(); + $now = dol_now(); - // Check parameters - if ($this->datef <= $this->dateh) { - $this->error = $langs->trans("ErrorBadValueForDate"); - return -1; - } - if (empty($this->datec)) $this->datec = $now; + // Check parameters + if ($this->datef <= $this->dateh) { + $this->error = $langs->trans("ErrorBadValueForDate"); + return -1; + } + if (empty($this->datec)) $this->datec = $now; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); - if ($this->fk_type == null) { // If type not defined, we use the type of member - $type = $member->typeid; - } else { - $type = $this->fk_type; - } - $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->dateh)."',"; - $sql .= " '".$this->db->idate($this->datef)."',"; - $sql .= " ".$this->amount.","; - $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; + if ($this->fk_type == null) { // If type not defined, we use the type of member + $type = $member->typeid; + } else { + $type = $this->fk_type; + } + $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->dateh)."',"; + $sql .= " '".$this->db->idate($this->datef)."',"; + $sql .= " ".$this->amount.","; + $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror(); + } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - $this->fk_type = $type; - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->fk_type = $type; + } - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) { + $this->context = array('member'=>$member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Method to load a subscription - * - * @param int $rowid Id subscription - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid) - { - $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; - $sql .= " tms,"; - $sql .= " dateadh as dateh,"; - $sql .= " datef,"; - $sql .= " subscription, note, fk_bank"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql .= " WHERE rowid=".$rowid; + /** + * Method to load a subscription + * + * @param int $rowid Id subscription + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid) + { + $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; + $sql .= " tms,"; + $sql .= " dateadh as dateh,"; + $sql .= " datef,"; + $sql .= " subscription, note, fk_bank"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE rowid=".$rowid; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->tms); - $this->dateh = $this->db->jdate($obj->dateh); - $this->datef = $this->db->jdate($obj->datef); - $this->amount = $obj->subscription; - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->tms); + $this->dateh = $this->db->jdate($obj->dateh); + $this->datef = $this->db->jdate($obj->datef); + $this->amount = $obj->subscription; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + return 1; + } else { + return 0; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Update subscription - * - * @param User $user User who updated - * @param int $notrigger 0=Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - $error = 0; + /** + * Update subscription + * + * @param User $user User who updated + * @param int $notrigger 0=Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; - $sql .= " fk_adherent = ".$this->fk_adherent.","; - $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; - $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_adherent = ".$this->fk_adherent.","; + $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; + $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; + $sql .= " datef='".$this->db->idate($this->datef)."',"; + $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } + if (!$error && !$notrigger) { + $this->context = array('member'=>$member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Delete a subscription - * - * @param User $user User that delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function delete($user, $notrigger = false) - { - $error = 0; + /** + * Delete a subscription + * + * @param User $user User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function delete($user, $notrigger = false) + { + $error = 0; - // It subscription is linked to a bank transaction, we get it - if ($this->fk_bank > 0) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline = new AccountLine($this->db); - $result = $accountline->fetch($this->fk_bank); - } + // It subscription is linked to a bank transaction, we get it + if ($this->fk_bank > 0) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline = new AccountLine($this->db); + $result = $accountline->fetch($this->fk_bank); + } - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->affected_rows($resql); - if ($num) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->affected_rows($resql); + if ($num) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) $result = $accountline->delete($user); // Return false if refused because line is conciliated - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->error = $accountline->error; - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->db->commit(); - return 0; - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } - } + if ($result > 0) { + $this->db->commit(); + return 1; + } else { + $this->error = $accountline->error; + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->db->commit(); + return 0; + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $notooltip 1=Disable tooltip - * @param string $option Page for link ('', 'nolink', ...) - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $notooltip 1=Disable tooltip + * @param string $option Page for link ('', 'nolink', ...) + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) + { + global $langs; - $result = ''; + $result = ''; - $langs->load("members"); - $label = $langs->trans("ShowSubscription").': '.$this->ref; + $langs->load("members"); + $label = $langs->trans("ShowSubscription").': '.$this->ref; - $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; + $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $picto = 'payment'; + $picto = 'payment'; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du statut d'une adhesion - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label - */ - public function getLibStatut($mode = 0) - { - return ''; - } + /** + * Retourne le libelle du statut d'une adhesion + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Id status - * @return string Label - */ - public function LibStatut($status) - { - // phpcs:enable - global $langs; - $langs->load("members"); - return ''; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Id status + * @return string Label + */ + public function LibStatut($status) + { + // phpcs:enable + global $langs; + $langs->load("members"); + return ''; + } - /** - * Load information of the subscription object - * - * @param int $id Id subscription - * @return void - */ - public function info($id) - { - $sql = 'SELECT c.rowid, c.datec,'; - $sql .= ' c.tms as datem'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql .= ' WHERE c.rowid = '.$id; + /** + * Load information of the subscription object + * + * @param int $id Id subscription + * @return void + */ + public function info($id) + { + $sql = 'SELECT c.rowid, c.datec,'; + $sql .= ' c.tms as datem'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index cb6384cfb63..f9c14b91ac3 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -86,7 +86,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Mi llxHeader("", $title, $helpurl); if ($id > 0) { - $result = $membert->fetch($object->typeid); + $result = $membert->fetch($object->typeid); if ($result > 0) { // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -95,47 +95,47 @@ if ($id > 0) { $totalsize += $file['size']; } - if (!empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print '
'.$langs->trans('Options').''.$langs->trans('Description').'
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); - print "
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); + print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); - print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); + print "
'.$langs->trans('OptionModeProductBuy').''.$langs->trans('OptionModeProductBuyDesc')."
' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).'' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print length_accountg($obj->accountancy_code_buy); - if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy); + if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - print length_accountg($obj->accountancy_code_buy_intra); - if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - print length_accountg($obj->accountancy_code_buy_export); - if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print length_accountg($obj->accountancy_code_sell); - if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print length_accountg($obj->accountancy_code_sell_intra); - if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy_intra); + if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print length_accountg($obj->accountancy_code_buy_export); + if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print length_accountg($obj->accountancy_code_sell); + if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print length_accountg($obj->accountancy_code_sell_intra); + if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } else { - print length_accountg($obj->accountancy_code_sell_export); - if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } + print length_accountg($obj->accountancy_code_sell_export); + if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; @@ -643,25 +643,25 @@ if ($result) print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_intra); - //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_export); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_intra); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_export); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index c3e225e5399..a930ed12852 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -274,11 +274,11 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; - $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; $sql .= " GROUP BY t.numero_compte"; @@ -292,12 +292,12 @@ if ($action != 'export_csv') foreach ($object->lines as $line) { - $accountingaccountstatic->fetch(null, $line->numero_compte, true); - if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); - } else { - $accounting_account = length_accountg($line->numero_compte); - } + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } $link = ''; $total_debit += $line->debit; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ef9ebe3f9b9..c2a478c79ec 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -114,12 +114,12 @@ if ($action == "confirm_update") { $object->credit = $credit; if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -175,13 +175,13 @@ if ($action == "confirm_update") { $object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -245,7 +245,7 @@ if ($action == "confirm_update") { $object->journal_label = $journal_label; $object->fk_doc = 0; $object->fk_docdet = 0; - $object->montant = 0; // deprecated + $object->montant = 0; // deprecated $object->amount = 0; $result = $object->createStd($user, 0, $mode); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d89d0dca60c..6d663edcf4e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -151,7 +151,7 @@ $arrayfields = array( 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -176,145 +176,145 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - 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_mvt_num = ''; - $search_doc_type = ''; - $search_doc_ref = ''; - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_accountancy_aux_code = ''; - $search_accountancy_aux_code_start = ''; - $search_accountancy_aux_code_end = ''; - $search_mvt_label = ''; - $search_direction = ''; - $search_ledger_code = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_date_creation_start = ''; - $search_date_creation_end = ''; - $search_date_modification_start = ''; - $search_date_modification_end = ''; - $search_date_export_start = ''; - $search_date_export_end = ''; - $search_debit = ''; - $search_credit = ''; - $search_lettering_code = ''; + 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_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_creation_start = ''; + $search_date_creation_end = ''; + $search_date_modification_start = ''; + $search_date_modification_end = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; $search_not_reconciled = ''; - } + } - // Must be after the remove filter action, before the export. - $param = ''; - $filter = array(); - if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $tmp = dol_getdate($search_date_start); - $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $tmp = dol_getdate($search_date_end); - $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $tmp = dol_getdate($search_doc_date); - $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_type)) { - $filter['t.doc_type'] = $search_doc_type; - $param .= '&search_doc_type='.urlencode($search_doc_type); - } - if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); - } - if (!empty($search_accountancy_code)) { - $filter['t.numero_compte'] = $search_accountancy_code; - $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); - } - if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); - } - if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); - } - if (!empty($search_accountancy_aux_code)) { - $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); - } - if (!empty($search_accountancy_aux_code_start)) { - $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; - $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); - } - if (!empty($search_accountancy_aux_code_end)) { - $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; - $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); - } - if (!empty($search_mvt_label)) { - $filter['t.label_operation'] = $search_mvt_label; - $param .= '&search_mvt_label='.urlencode($search_mvt_label); - } - if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); - } - if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); - } - if (!empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); - } - if (!empty($search_date_creation_start)) { - $filter['t.date_creation>='] = $search_date_creation_start; - $tmp = dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_creation_end)) { - $filter['t.date_creation<='] = $search_date_creation_end; - $tmp = dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_start)) { - $filter['t.tms>='] = $search_date_modification_start; - $tmp = dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_end)) { - $filter['t.tms<='] = $search_date_modification_end; - $tmp = dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_start)) { - $filter['t.date_export>='] = $search_date_export_start; - $tmp = dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_end)) { - $filter['t.date_export<='] = $search_date_export_end; - $tmp = dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); - } - if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); - } - if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); - } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $tmp = dol_getdate($search_date_start); + $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $tmp = dol_getdate($search_date_end); + $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $tmp = dol_getdate($search_doc_date); + $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $param .= '&search_doc_type='.urlencode($search_doc_type); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } + if (!empty($search_accountancy_code)) { + $filter['t.numero_compte'] = $search_accountancy_code; + $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + } + if (!empty($search_accountancy_aux_code)) { + $filter['t.subledger_account'] = $search_accountancy_aux_code; + $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); + } + if (!empty($search_accountancy_aux_code_start)) { + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; + $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); + } + if (!empty($search_accountancy_aux_code_end)) { + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; + $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); + } + if (!empty($search_mvt_label)) { + $filter['t.label_operation'] = $search_mvt_label; + $param .= '&search_mvt_label='.urlencode($search_mvt_label); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction='.urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code='.urlencode($search_ledger_code); + } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num='.urlencode($search_mvt_num); + } + if (!empty($search_date_creation_start)) { + $filter['t.date_creation>='] = $search_date_creation_start; + $tmp = dol_getdate($search_date_creation_start); + $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_creation_end)) { + $filter['t.date_creation<='] = $search_date_creation_end; + $tmp = dol_getdate($search_date_creation_end); + $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_start)) { + $filter['t.tms>='] = $search_date_modification_start; + $tmp = dol_getdate($search_date_modification_start); + $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_end)) { + $filter['t.tms<='] = $search_date_modification_end; + $tmp = dol_getdate($search_date_modification_end); + $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $tmp = dol_getdate($search_date_export_start); + $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $tmp = dol_getdate($search_date_export_end); + $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit='.urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit='.urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); @@ -475,48 +475,48 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { setEventMessages($object->error, $object->errors, 'errors'); } else { - // Export files + // Export files $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines, $formatexportset); - if (!empty($accountancyexport->errors)) - { - setEventMessages('', $accountancyexport->errors, 'errors'); - } else { - // Specify as export : update field date_export - $error = 0; - $db->begin(); + if (!empty($accountancyexport->errors)) + { + setEventMessages('', $accountancyexport->errors, 'errors'); + } else { + // Specify as export : update field date_export + $error = 0; + $db->begin(); - if (is_array($object->lines)) - { - foreach ($object->lines as $movement) - { - $now = dol_now(); + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { + $now = dol_now(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET date_export = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET date_export = '".$db->idate($now)."'"; + $sql .= " WHERE rowid = ".$movement->id; - dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - $error++; - break; - } - } - } + dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + $error++; + break; + } + } + } - if (!$error) - { - $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } else { - $error++; - $db->rollback(); - setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); - } - } + if (!$error) + { + $db->commit(); + // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); + } else { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + } + } exit; } } @@ -629,9 +629,9 @@ else $buttonLabel = $langs->trans("ExportList"); // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; @@ -791,14 +791,14 @@ if (!empty($arrayfields['t.tms']['checked'])) // Date export if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; + print '
'; + print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print '
'; @@ -854,7 +854,7 @@ while ($i < min($num, $limit)) $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated + $line->montant = $obj->amount; // deprecated $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; @@ -893,65 +893,65 @@ while ($i < min($num, $limit)) // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { - if ($line->doc_type == 'customer_invoice') - { - $langs->loadLangs(array('bills')); + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $objectstatic = new Facture($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'facture'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'supplier_invoice') - { - $langs->loadLangs(array('bills')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $objectstatic = new FactureFournisseur($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'invoice_supplier'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } elseif ($line->doc_type == 'expense_report') - { - $langs->loadLangs(array('trips')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $objectstatic = new ExpenseReport($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'expensereport'; + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } else { - // Other type - } + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } - print ''; + print ''; - print ''; - // Picto + Ref - print '
'; + print ''; + // Picto + Ref + print '
'; - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') - { - print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - print $documentlink; - } else { - print $line->doc_ref; - } - print '
'; + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; - print "
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); @@ -665,7 +665,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['t.label_operation']['checked'])) { // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
' . ($line->credit ? price($line->credit) : '') . ''.($line->credit ? price($line->credit) : '').'
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 8e6387d4608..e831e21f814 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -195,17 +195,17 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB if ($resql) { $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -244,13 +244,13 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; $tmp = ''; - while ($obj = $db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) { if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); @@ -265,20 +265,20 @@ if ($resql) { print ''; // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; - if (empty($obj->lettering_code)) { - print ''; - print ''."\n"; - } else { - print ''; - print ''; - } + if (empty($obj->lettering_code)) { + print ''; + print ''."\n"; + } else { + print ''; + print ''; + } print "\n"; } @@ -299,9 +299,9 @@ if ($resql) { print "
'.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''.$obj->lettering_code.''; + print img_edit(); + print ''.$obj->lettering_code.'
"; - print '
'."\n"; - print $letteringbutton; - print '
'; + print '
'."\n"; + print $letteringbutton; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index afdf5f902f7..16aa51beded 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -193,17 +193,17 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -242,7 +242,7 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; @@ -261,21 +261,21 @@ if ($resql) { print ''; print ''; - // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + // Journal + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; if (empty($obj->lettering_code) && empty($obj->date_validated)) { print ''; - print ''."\n"; + print ''."\n"; } else { - print ''; - print ''; - } + print ''; + print ''; + } print "\n"; } @@ -296,9 +296,9 @@ if ($resql) { print "
'.price($obj->credit).''.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''; + print img_edit(); + print ''.$obj->lettering_code.''.$obj->lettering_code.'
"; - print '
'."\n"; + print '
'."\n"; print $letteringbutton; - print '
'; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index c7f7f8cf68c..eb43348f1ea 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; */ class AccountancyCategory // extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error string @@ -63,9 +63,9 @@ class AccountancyCategory // extends CommonObject public $rowid; /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string Accountancy code @@ -73,11 +73,11 @@ class AccountancyCategory // extends CommonObject public $code; /** - * @var string Accountancy Category label - */ - public $label; + * @var string Accountancy Category label + */ + public $label; - /** + /** * @var string Accountancy range account */ public $range_account; @@ -381,8 +381,8 @@ class AccountancyCategory // extends CommonObject * @param int $id Id * @return int <0 if KO, 0 if not found, >0 if OK */ - public function display($id) - { + public function display($id) + { global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; @@ -408,7 +408,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -417,8 +417,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getCptBK($id) - { + public function getCptBK($id) + { global $conf; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; @@ -457,7 +457,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -466,41 +466,41 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getAccountsWithNoCategory($id) - { - global $conf; + public function getAccountsWithNoCategory($id) + { + global $conf; - $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " GROUP BY aa.account_number, aa.label"; - $sql .= " ORDER BY aa.account_number, aa.label"; + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " GROUP BY aa.account_number, aa.label"; + $sql .= " ORDER BY aa.account_number, aa.label"; - $this->lines_CptBk = array(); + $this->lines_CptBk = array(); - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $this->lines_cptbk[] = $obj; - } - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $this->lines_cptbk[] = $obj; + } + } - return $num; - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + return $num; + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } /** * Function to add an accounting account in an accounting category @@ -510,8 +510,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function updateAccAcc($id_cat, $cpts = array()) - { + public function updateAccAcc($id_cat, $cpts = array()) + { global $conf; $error = 0; @@ -523,7 +523,7 @@ class AccountancyCategory // extends CommonObject $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -539,13 +539,13 @@ class AccountancyCategory // extends CommonObject $accountincptsadded = array(); while ($obj = $this->db->fetch_object($resql)) { - $account_number_formated = length_accountg($obj->account_number); - if (!empty($accountincptsadded[$account_number_formated])) continue; + $account_number_formated = length_accountg($obj->account_number); + if (!empty($accountincptsadded[$account_number_formated])) continue; - if (array_key_exists($account_number_formated, $cpts)) + if (array_key_exists($account_number_formated, $cpts)) { - $accountincptsadded[$account_number_formated] = 1; - // We found an account number that is in list $cpts of account to add + $accountincptsadded[$account_number_formated] = 1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; $sql .= " SET fk_accounting_category=".$id_cat; $sql .= " WHERE rowid=".$obj->rowid; @@ -572,7 +572,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -581,8 +581,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function deleteCptCat($cpt_id) - { + public function deleteCptCat($cpt_id) + { $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; @@ -598,7 +598,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); @@ -606,12 +606,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return -1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account @@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, - 'bc' => $obj->sens + 'bc' => $obj->sens ); $i++; } diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 0204602438f..845c300c952 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -55,7 +55,7 @@ class AccountancyExport public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_WINFIC = 70; public static $EXPORT_TYPE_OPENCONCERTO = 100; - public static $EXPORT_TYPE_LDCOMPTA = 110; + public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_FEC = 1000; @@ -111,7 +111,7 @@ class AccountancyExport self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), + self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), @@ -144,9 +144,9 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -201,22 +201,22 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -254,7 +254,7 @@ class AccountancyExport $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; - global $db; // The tpl file use $db + global $db; // The tpl file use $db include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; @@ -289,21 +289,21 @@ class AccountancyExport case self::$EXPORT_TYPE_AGIRIS : $this->exportAgiris($TData); break; - case self::$EXPORT_TYPE_OPENCONCERTO : - $this->exportOpenConcerto($TData); - break; + case self::$EXPORT_TYPE_OPENCONCERTO : + $this->exportOpenConcerto($TData); + break; case self::$EXPORT_TYPE_SAGE50_SWISS : $this->exportSAGE50SWISS($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; @@ -599,7 +599,7 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { @@ -659,10 +659,10 @@ class AccountancyExport print $date.$separator; print $line->code_journal.$separator; if (empty($line->subledger_account)) { - print $line->numero_compte.$separator; - } else { - print $line->subledger_account.$separator; - } + print $line->numero_compte.$separator; + } else { + print $line->subledger_account.$separator; + } //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; @@ -714,36 +714,36 @@ class AccountancyExport } } - /** - * Export format : OpenConcerto - * - * @param array $objectLines data - * @return void - */ - public function exportOpenConcerto($objectLines) - { + /** + * Export format : OpenConcerto + * + * @param array $objectLines data + * @return void + */ + public function exportOpenConcerto($objectLines) + { - $separator = ';'; - $end_line = "\n"; + $separator = ';'; + $end_line = "\n"; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date.$separator; - print $line->code_journal.$separator; - if (empty($line->subledger_account)) { - print length_accountg($line->numero_compte).$separator; - } else { - print length_accounta($line->subledger_account).$separator; - } - print $line->doc_ref.$separator; - print $line->label_operation.$separator; - print price($line->debit).$separator; - print price($line->credit).$separator; + print $date.$separator; + print $line->code_journal.$separator; + if (empty($line->subledger_account)) { + print length_accountg($line->numero_compte).$separator; + } else { + print length_accounta($line->subledger_account).$separator; + } + print $line->doc_ref.$separator; + print $line->label_operation.$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; - print $end_line; - } - } + print $end_line; + } + } /** * Export format : Configurable CSV @@ -822,25 +822,25 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_document . $separator; + print $date_document.$separator; // FEC:CompteNum print $line->numero_compte.$separator; // FEC:CompteLib - print dol_string_unaccent($line->label_compte) . $separator; + print dol_string_unaccent($line->label_compte).$separator; // FEC:CompAuxNum print $line->subledger_account.$separator; // FEC:CompAuxLib - print dol_string_unaccent($line->subledger_label) . $separator; + print dol_string_unaccent($line->subledger_label).$separator; // FEC:PieceRef print $line->doc_ref.$separator; // FEC:PieceDate - print dol_string_unaccent($date_creation) . $separator; + print dol_string_unaccent($date_creation).$separator; // FEC:EcritureLib print $line->label_operation.$separator; @@ -858,7 +858,7 @@ class AccountancyExport print $line->date_lettering.$separator; // FEC:ValidDate - print $date_validation . $separator; + print $date_validation.$separator; // FEC:Montantdevise print $line->multicurrency_amount.$separator; @@ -870,152 +870,152 @@ class AccountancyExport } } - /** - * Export format : SAGE50SWISS - * - * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 - * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf - * - * @param array $objectLines data - * - * @return void - */ - public function exportSAGE50SWISS($objectLines) - { - // SAGE50SWISS - $this->separator = ','; - $this->end_line = "\r\n"; + /** + * Export format : SAGE50SWISS + * + * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 + * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf + * + * @param array $objectLines data + * + * @return void + */ + public function exportSAGE50SWISS($objectLines) + { + // SAGE50SWISS + $this->separator = ','; + $this->end_line = "\r\n"; - // Print header line - print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; - print $this->end_line; - $thisPieceNum = ""; - $thisPieceAccountNr = ""; - $aSize = count($objectLines); - foreach ($objectLines as $aIndex=>$line) + // Print header line + print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; + print $this->end_line; + $thisPieceNum = ""; + $thisPieceAccountNr = ""; + $aSize = count($objectLines); + foreach ($objectLines as $aIndex=>$line) { - $sammelBuchung = false; - if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 1 < $aSize - && $objectLines[$aIndex + 1]->piece_num == $line->piece_num - && $aIndex - 1 < $aSize - && $objectLines[$aIndex - 1]->piece_num == $line->piece_num - ) - { - $sammelBuchung = true; - } + $sammelBuchung = false; + if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 1 < $aSize + && $objectLines[$aIndex + 1]->piece_num == $line->piece_num + && $aIndex - 1 < $aSize + && $objectLines[$aIndex - 1]->piece_num == $line->piece_num + ) + { + $sammelBuchung = true; + } - //Blg - print $line->piece_num.$this->separator; + //Blg + print $line->piece_num.$this->separator; - // Datum - $date = dol_print_date($line->doc_date, '%d.%m.%Y'); - print $date.$this->separator; + // Datum + $date = dol_print_date($line->doc_date, '%d.%m.%Y'); + print $date.$this->separator; - // Kto - print length_accountg($line->numero_compte).$this->separator; - // S/H - if ($line->sens == 'D') - { - print 'S'.$this->separator; - } else { - print 'H'.$this->separator; - } - //Grp - print self::trunc($line->code_journal, 1).$this->separator; - // GKto - if (empty($line->code_tiers)) - { - if ($line->piece_num == $thisPieceNum) - { - print length_accounta($thisPieceAccountNr).$this->separator; - } else { - print "div".$this->separator; - } - } else { - print length_accounta($line->code_tiers).$this->separator; - } - //SId - print $this->separator; - //SIdx - print "0".$this->separator; - //KIdx - print "0".$this->separator; - //BTyp - print "0".$this->separator; + // Kto + print length_accountg($line->numero_compte).$this->separator; + // S/H + if ($line->sens == 'D') + { + print 'S'.$this->separator; + } else { + print 'H'.$this->separator; + } + //Grp + print self::trunc($line->code_journal, 1).$this->separator; + // GKto + if (empty($line->code_tiers)) + { + if ($line->piece_num == $thisPieceNum) + { + print length_accounta($thisPieceAccountNr).$this->separator; + } else { + print "div".$this->separator; + } + } else { + print length_accounta($line->code_tiers).$this->separator; + } + //SId + print $this->separator; + //SIdx + print "0".$this->separator; + //KIdx + print "0".$this->separator; + //BTyp + print "0".$this->separator; - //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung - if ($sammelBuchung) - { - print "2".$this->separator; - } else { - print "1".$this->separator; - } - // Code - print '""'.$this->separator; - // Netto - if ($line->montant >= 0) - { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } - // Steuer - print "0.00".$this->separator; - // FW-Betrag - print "0.00".$this->separator; - // Tx1 - $line1 = self::toAnsi($line->label_compte, 29); - if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) - { - $line1 = ""; - } - $line2 = self::toAnsi($line->doc_ref, 29); - if (strlen($line1) == 0) - { - $line1 = $line2; - $line2 = ""; - } - if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) - { - $line1 = $line1.' / '.$line2; - $line2 = ""; - } + //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung + if ($sammelBuchung) + { + print "2".$this->separator; + } else { + print "1".$this->separator; + } + // Code + print '""'.$this->separator; + // Netto + if ($line->montant >= 0) + { + print $line->montant.$this->separator; + } else { + print ($line->montant * -1).$this->separator; + } + // Steuer + print "0.00".$this->separator; + // FW-Betrag + print "0.00".$this->separator; + // Tx1 + $line1 = self::toAnsi($line->label_compte, 29); + if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) + { + $line1 = ""; + } + $line2 = self::toAnsi($line->doc_ref, 29); + if (strlen($line1) == 0) + { + $line1 = $line2; + $line2 = ""; + } + if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) + { + $line1 = $line1.' / '.$line2; + $line2 = ""; + } - print '"'.self::toAnsi($line1).'"'.$this->separator; - // Tx2 - print '"'.self::toAnsi($line2).'"'.$this->separator; - //PkKey - print "0".$this->separator; - //OpId - print $this->separator; + print '"'.self::toAnsi($line1).'"'.$this->separator; + // Tx2 + print '"'.self::toAnsi($line2).'"'.$this->separator; + //PkKey + print "0".$this->separator; + //OpId + print $this->separator; - // Flag - print "0"; + // Flag + print "0"; - print $this->end_line; + print $this->end_line; - if ($line->piece_num !== $thisPieceNum) - { - $thisPieceNum = $line->piece_num; - $thisPieceAccountNr = $line->numero_compte; - } - } - } + if ($line->piece_num !== $thisPieceNum) + { + $thisPieceNum = $line->piece_num; + $thisPieceAccountNr = $line->numero_compte; + } + } + } - /** - * Export format : LD Compta version 9 - * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf - * - * @param array $objectLines data - * - * @return void - */ + /** + * Export format : LD Compta version 9 + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf + * + * @param array $objectLines data + * + * @return void + */ public function exportLDCompta($objectLines) { @@ -1168,23 +1168,23 @@ class AccountancyExport { $soc = $this->db->fetch_object($resql); - $address = array('', '', ''); - if (strpos($soc->address, "\n") !== false) { - $address = explode("\n", $soc->address); - if (is_array($address) && count($address) > 0) { - foreach ($address as $key=>$data) { - $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); - $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); - } - } - } else { - $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); - $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); - $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); - } + $address = array('', '', ''); + if (strpos($soc->address, "\n") !== false) { + $address = explode("\n", $soc->address); + if (is_array($address) && count($address) > 0) { + foreach ($address as $key=>$data) { + $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); + $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); + } + } + } else { + $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); + $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); + $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); + } $type_enregistrement = 'C'; - //TYPE + //TYPE print $type_enregistrement.$separator; //NOCL print $soc->code_client.$separator; @@ -1193,15 +1193,15 @@ class AccountancyExport //LIBI print $separator; //TITR - print $separator; + print $separator; //RSSO print $soc->nom.$separator; //CAD1 - print $address[0].$separator; + print $address[0].$separator; //CAD2 - print $address[1].$separator; + print $address[1].$separator; //CAD3 - print $address[2].$separator; + print $address[2].$separator; //COPO print $soc->zip.$separator; //BUDI @@ -1223,7 +1223,7 @@ class AccountancyExport //COMM print $separator; //SIRE - print str_replace(" ", "", $soc->siret).$separator; + print str_replace(" ", "", $soc->siret).$separator; //RIBP print $separator; //DOBQ @@ -1486,15 +1486,15 @@ class AccountancyExport * * @param string $str Original string to encode and optionaly truncate * @param integer $size Truncate string after $size characters - * @return string String encoded in Windows-1251 charset + * @return string String encoded in Windows-1251 charset */ public static function toAnsi($str, $size = -1) - { + { $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); - if ($retVal >= 0 && $size >= 0) - { - $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); - } - return $retVal; + if ($retVal >= 0 && $size >= 0) + { + $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); + } + return $retVal; } } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index c2f3468016c..193a03f1726 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -28,10 +28,10 @@ */ class AccountancySystem { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,13 +44,13 @@ class AccountancySystem public $rowid; /** - * @var int ID - */ + * @var int ID + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; /** @@ -59,18 +59,18 @@ class AccountancySystem public $numero; /** - * @var string Accountancy System label - */ - public $label; + * @var string Accountancy System label + */ + public $label; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var string account parent - */ + /** + * @var string account parent + */ public $account_parent; /** @@ -78,10 +78,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - public function __construct($db) - { + public function __construct($db) + { $this->db = $db; - } + } /** @@ -93,42 +93,42 @@ class AccountancySystem */ public function fetch($rowid = 0, $ref = '') { - global $conf; + global $conf; - if ($rowid > 0 || $ref) - { - $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; - $sql .= " WHERE"; - if ($rowid) { - $sql .= " a.rowid = ".((int) $rowid); - } elseif ($ref) { - $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; - } + if ($rowid > 0 || $ref) + { + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " a.rowid = ".((int) $rowid); + } elseif ($ref) { + $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; + } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); - if ($obj) { - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->pcg_version = $obj->pcg_version; - $this->ref = $obj->pcg_version; - $this->label = $obj->label; - $this->active = $obj->active; + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->pcg_version = $obj->pcg_version; + $this->ref = $obj->pcg_version; + $this->label = $obj->label; + $this->active = $obj->active; - return $this->id; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = "Error ".$this->db->lasterror(); - } - } - return -1; + return $this->id; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); + } + } + return -1; } @@ -138,8 +138,8 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - public function create($user) - { + public function create($user) + { $now = dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; @@ -165,6 +165,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index e7a65ceec97..ebf397c2dfd 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -74,35 +74,35 @@ class AccountingAccount extends CommonObject public $rowid; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var string pcg version - */ + * @var string pcg version + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var int ID parent account - */ + /** + * @var int ID parent account + */ public $account_parent; - /** - * @var int ID category account - */ + /** + * @var int ID category account + */ public $account_category; /** @@ -110,10 +110,10 @@ class AccountingAccount extends CommonObject */ public $status; - /** - * @var string Label of account - */ - public $label; + /** + * @var string Label of account + */ + public $label; /** * @var string Label short of account @@ -121,19 +121,19 @@ class AccountingAccount extends CommonObject public $labelshort; /** - * @var int ID - */ - public $fk_user_author; + * @var int ID + */ + public $fk_user_author; - /** - * @var int ID - */ - public $fk_user_modif; + /** + * @var int ID + */ + public $fk_user_modif; /** * @var int active (duplicate with status) */ - public $active; + public $active; /** * @var int reconcilable @@ -145,13 +145,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { + public function __construct($db) + { global $conf; $this->db = $db; $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -162,7 +162,7 @@ class AccountingAccount extends CommonObject * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') { global $conf; @@ -182,7 +182,7 @@ class AccountingAccount extends CommonObject $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; } if (!empty($limittoachartaccount)) { - $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; + $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -229,8 +229,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; $now = dol_now(); @@ -318,7 +318,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -366,8 +366,8 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function checkUsage() - { + public function checkUsage() + { global $langs; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; @@ -400,8 +400,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) - { + public function delete($user, $notrigger = 0) + { $error = 0; $result = $this->checkUsage(); @@ -436,9 +436,9 @@ class AccountingAccount extends CommonObject } else { return -1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -446,12 +446,12 @@ class AccountingAccount extends CommonObject * @param int $nourl 1=Disable url * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @param string $option 'ledger', 'journals', 'accountcard' * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -524,7 +524,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; return $result; - } + } /** * Information on record @@ -532,8 +532,8 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - public function info($id) - { + public function info($id) + { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; $sql .= ' WHERE a.rowid = '.$id; @@ -568,18 +568,18 @@ class AccountingAccount extends CommonObject * Deactivate an account (for status active or status reconcilable) * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function accountDeactivate($id, $mode = 0) - { + public function accountDeactivate($id, $mode = 0) + { $result = $this->checkUsage(); $fieldtouse = 'active'; - if ($mode == 1) - { + if ($mode == 1) + { $fieldtouse = 'reconcilable'; - } + } if ($result > 0) { $this->db->begin(); @@ -604,26 +604,26 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_activate($id, $mode = 0) - { - // phpcs:enable + public function account_activate($id, $mode = 0) + { + // phpcs:enable $this->db->begin(); - if ($mode == 0) - { - $fieldtouse = 'active'; - } elseif ($mode == 1) - { - $fieldtouse = 'reconcilable'; - } + if ($mode == 0) + { + $fieldtouse = 'active'; + } elseif ($mode == 1) + { + $fieldtouse = 'reconcilable'; + } $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; $sql .= "SET ".$fieldtouse." = '1'"; @@ -631,15 +631,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } /** @@ -653,7 +653,7 @@ class AccountingAccount extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -663,7 +663,7 @@ class AccountingAccount extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("users")); diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 882eee71769..c002abf2a89 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -56,29 +56,29 @@ class AccountingJournal extends CommonObject */ public $rowid; - /** - * @var string Accounting journal code - */ + /** + * @var string Accounting journal code + */ public $code; /** - * @var string Accounting Journal label - */ - public $label; + * @var string Accounting Journal label + */ + public $label; - /** - * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new - */ - public $nature; + /** + * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + */ + public $nature; - /** - * @var int is active or not - */ + /** + * @var int is active or not + */ public $active; - /** - * @var array array of lines - */ + /** + * @var array array of lines + */ public $lines; /** @@ -86,10 +86,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { - $this->db = $db; - } + public function __construct($db) + { + $this->db = $db; + } /** * Load an object from database @@ -155,8 +155,8 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter @@ -284,7 +284,7 @@ class AccountingJournal extends CommonObject return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -294,7 +294,7 @@ class AccountingJournal extends CommonObject */ public function LibType($nature, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("accountancy")); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 808ccfba0ef..1013ad1b6ce 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -63,24 +63,24 @@ $year_current = $year_start; if ($action == 'validate') { - $now = dol_now(); + $now = dol_now(); - // Update database - $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '".$db->idate($now)."'"; - $sql .= ' WHERE b.date_validated IS NULL'; + // Update database + $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '".$db->idate($now)."'"; + $sql .= ' WHERE b.date_validated IS NULL'; - dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql1) { - $error++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database + dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql1) { + $error++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database } @@ -135,8 +135,8 @@ if ($resql) { while ($row = $db->fetch_row($resql)) { for ($i = 1; $i <= 12; $i++) { print '
'.$row[$i].'

'; - print ''; - print '
'.$row[13].''; print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { - print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; + print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; } print '
'; $linkback = ''.$langs->trans("BackToList").''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - // Number of Attached Files + // Number of Attached Files print ''; //Total Size Of Attached Files @@ -157,7 +157,7 @@ if ($id > 0) { dol_print_error($db); } } else { - $langs->load("errors"); + $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index aa7564007a6..fc93f828f6c 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -125,29 +125,29 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo // Search contact/address - if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { - $listofsearchfields['search_member'] = array('text'=>'Member'); - } + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { + $listofsearchfields['search_member'] = array('text'=>'Member'); + } - if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$object); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'; - $i = 0; - foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
:
'; - print ''; - print ''; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print '
'; + print '
'; + print '
'; + } } @@ -158,53 +158,53 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel if ($conf->use_javascript_ajax) { print '
'; print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$langs->trans("Statistics").'
'; + print '
'.$langs->trans("Statistics").'
'; - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); - $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); - $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); - $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SommeA + $SommeB + $SommeC + $SommeD; - $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + $total = 0; + $dataval = array(); + $i = 0; + foreach ($AdherentType as $key => $adhtype) { + $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); + $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); + $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); + $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $i++; + } + $total = $SommeA + $SommeB + $SommeC + $SommeD; + $dataseries = array(); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '
'; - print '
'; + print '
'.$langs->trans("Total").''; + print $SommeA + $SommeB + $SommeC + $SommeD; + print '
'; + print '
'; } print '
'; @@ -223,17 +223,17 @@ $sql .= " AND d.rowid = c.fk_adherent"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - $year = dol_print_date($db->jdate($objp->dateh), "%Y"); - $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; - $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; - $tot += $objp->subscription; - $numb += 1; - $i++; - } + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + $year = dol_print_date($db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } } print '
'; @@ -258,12 +258,12 @@ foreach ($Total as $key=>$value) { break; } print ''; - print "$key"; - print "".$Number[$key].""; - print "".price($value).""; - print "".price(price2num($value / $Number[$key], 'MT')).""; - print "\n"; - $i++; + print "$key"; + print "".$Number[$key].""; + print "".price($value).""; + print "".price(price2num($value / $Number[$key], 'MT')).""; + print "\n"; + $i++; } // Total diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 14d886b6cc4..6be535b6e3b 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09'); // Protection $socid = 0; if ($user->socid > 0) { - $socid = $user->socid; + $socid = $user->socid; } $object = new Adherent($db); @@ -165,24 +165,24 @@ if ($result > 0) { $search = "(".$object->_load_ldap_dn($info, 2).")"; if (empty($dn)) { - $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; + $langs->load("errors"); + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; } else { - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } + } $ldap->unbind(); $ldap->close(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 05100582ec2..c9aaa856d22 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -204,30 +204,30 @@ if (empty($reshook)) { // Close if ($massaction == 'close' && $user->rights->adherent->creer) { - $tmpmember = new Adherent($db); - $error = 0; - $nbclose = 0; + $tmpmember = new Adherent($db); + $error = 0; + $nbclose = 0; - $db->begin(); + $db->begin(); - foreach ($toselect as $idtoclose) { - $tmpmember->fetch($idtoclose); - $result = $tmpmember->resiliate($user); + foreach ($toselect as $idtoclose) { + $tmpmember->fetch($idtoclose); + $result = $tmpmember->resiliate($user); - if ($result < 0 && !count($tmpmember->errors)) { - setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); - } else { - if ($result > 0) $nbclose++; - } - } + if ($result < 0 && !count($tmpmember->errors)) { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } else { + if ($result > 0) $nbclose++; + } + } - if (!$error) { - setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); + if (!$error) { + setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + $db->commit(); + } else { + $db->rollback(); + } } // Mass actions @@ -409,7 +409,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print '
'; @@ -560,7 +560,7 @@ if (!empty($arrayfields['d.email']['checked'])) { // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; - $selectarray=array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); print ''; } diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 1ce2da4751b..e611eb3bbcf 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -40,8 +40,8 @@ $result = restrictedArea($user, 'adherent', $id); $object = new Adherent($db); $result = $object->fetch($id); if ($result > 0) { - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } $permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php @@ -75,44 +75,44 @@ if ($id) { dol_banner_tab($object, 'id', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - print "
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$member); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
"; + print ""; - print '
'; + print '
'; - $cssclass = 'titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + $cssclass = 'titlefield'; + $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index cd0f90d27c6..73c32c59684 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -34,8 +34,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -69,7 +69,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut != -1"; // Not draft +$sql .= " AND d.statut != -1"; // Not draft $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; @@ -100,7 +100,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) +$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 7d05678263a..c24cf1fdef4 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -35,8 +35,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -68,129 +68,129 @@ print load_fiche_titre($title, '', 'object_group'); dol_mkdir($dir); if ($mode) { - // Define sql - if ($mode == 'memberbycountry') { - $label = $langs->trans("Country"); - $tab = 'statscountry'; + // Define sql + if ($mode == 'memberbycountry') { + $label = $langs->trans("Country"); + $tab = 'statscountry'; - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code"; - //print $sql; - } + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code"; + //print $sql; + } if ($mode == 'memberbystate') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("State"); - $tab = 'statsstate'; - - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, c.nom"; - //print $sql; - } - if ($mode == 'memberbyregion') { // $label = $langs->trans("Country"); - $label2 = $langs->trans("Region"); //département - $tab = 'statsregion'; //onglet + $label2 = $langs->trans("State"); + $tab = 'statsstate'; - $data = array(); //tableau de donnée - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, r.nom"; //+ - //print $sql; - } - if ($mode == 'memberbytown') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("Town"); - $tab = 'statstown'; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, c.nom"; + //print $sql; + } + if ($mode == 'memberbyregion') { // + $label = $langs->trans("Country"); + $label2 = $langs->trans("Region"); //département + $tab = 'statsregion'; //onglet - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code, d.town"; - //print $sql; - } + $data = array(); //tableau de donnée + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, r.nom"; //+ + //print $sql; + } + if ($mode == 'memberbytown') { + $label = $langs->trans("Country"); + $label2 = $langs->trans("Town"); + $tab = 'statstown'; - $langsen = new Translate('', $conf); - $langsen->setDefaultLang('en_US'); - $langsen->load("dict"); - //print $langsen->trans("Country"."FI");exit; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code, d.town"; + //print $sql; + } - // Define $data array - dol_syslog("Count member", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($mode == 'memberbycountry') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + $langsen = new Translate('', $conf); + $langsen->setDefaultLang('en_US'); + $langsen->load("dict"); + //print $langsen->trans("Country"."FI");exit; + + // Define $data array + dol_syslog("Count member", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($mode == 'memberbycountry') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbyregion') { //+ + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbyregion') { //+ $data[] = array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbystate') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbystate') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbytown') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbytown') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'nb'=>$obj->nb, + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } - $i++; - } - $db->free($resql); - } else { - dol_print_error($db); - } + $i++; + } + $db->free($resql); + } else { + dol_print_error($db); + } } @@ -201,101 +201,101 @@ print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title if ($mode && !count($data)) { - print $langs->trans("NoValidatedMemberYet").'
'; - print '
'; + print $langs->trans("NoValidatedMemberYet").'
'; + print '
'; } else { - if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; - elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; - elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ - else { - print ''.$langs->trans("MembersStatisticsDesc").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByCountries").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByState").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByTown").'
'; - print '
'; //+ + if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; + elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; + elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; + elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ + else { + print ''.$langs->trans("MembersStatisticsDesc").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByCountries").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByState").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByTown").'
'; + print '
'; //+ print ''.$langs->trans("MembersStatisticsByRegion").'
'; //+ - } - print '
'; + } + print '
'; } // Show graphics if (count($arrayjs) && $mode == 'memberbycountry') { - $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - if (is_readable($color_file)) include_once $color_file; + $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + if (is_readable($color_file)) include_once $color_file; - // Assume we've already included the proper headers so just call our script inline - // More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR - print "\n\n"; + print "\tvar options = {};\n"; + print "\toptions['dataMode'] = 'regions';\n"; + print "\toptions['showZoomOut'] = false;\n"; + //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n"; + print "\toptions['width'] = ".$graphwidth.";\n"; + print "\toptions['height'] = ".$graphheight.";\n"; + print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n"; + print "\tvar container = document.getElementById('".$mode."');\n"; + print "\tvar geomap = new google.visualization.GeoMap(container);\n"; + print "\tgeomap.draw(data, options);\n"; + print "};\n"; + print "\n"; - // print the div tag that will contain the map - print '
'."\n"; - print '
'; + // print the div tag that will contain the map + print '
'."\n"; + print '
'; } if ($mode) { - // Print array + // Print array print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; - foreach ($data as $val) { - $year = $val['year']; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; - } + foreach ($data as $val) { + $year = $val['year']; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; + } - print '
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; - print '
'; + print ''; + print '
'; } diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 472a93cfce7..6ac4e3dd78a 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -36,8 +36,8 @@ $socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -79,24 +79,24 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfSubscriptions")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NbOfSubscriptions")); + $px1->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfSubscriptions")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NbOfSubscriptions")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -110,24 +110,24 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfSubscriptions")); + $px2->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfSubscriptions")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } @@ -171,31 +171,31 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while ($oldyear > $year + 1) { // If we have empty year - $oldyear--; - print ''; - print ''; - //print ''; - print $oldyear; - //print ''; - print ''; - print '0'; - print '0'; - print '0'; - print ''; - } - print ''; - print ''; - //print ''; - print $year; - //print ''; - print ''; - print ''.$val['nb'].''; - print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''; - $oldyear = $year; + $year = $val['year']; + while ($oldyear > $year + 1) { // If we have empty year + $oldyear--; + print ''; + print ''; + //print ''; + print $oldyear; + //print ''; + print ''; + print '0'; + print '0'; + print '0'; + print ''; + } + print ''; + print ''; + //print ''; + print $year; + //print ''; + print ''; + print ''.$val['nb'].''; + print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''; + $oldyear = $year; } print ''; @@ -208,9 +208,9 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); } print '
'; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index ca88854d27e..748ac19814c 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -550,100 +550,100 @@ if ($rowid > 0) { } print ''; - print "\n"; + print "\n"; print "
\n"; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - /* + /* * Action buttons */ - // Button to create a new subscription if member no draft neither resiliated - if ($user->rights->adherent->cotisation->creer) { - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - print '
'; + // Button to create a new subscription if member no draft neither resiliated + if ($user->rights->adherent->cotisation->creer) { + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + print '
'; - if ($object->statut > 0) print '"; - else print ''; + if ($object->statut > 0) print '"; + else print ''; - print '
'; - } - } + print '
'; + } + } - /* + /* * List of subscriptions */ - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; - $sql .= " c.rowid as crowid, c.subscription,"; - $sql .= " c.datec, c.fk_type as cfk_type,"; - $sql .= " c.dateadh as dateh,"; - $sql .= " c.datef,"; - $sql .= " c.fk_bank,"; - $sql .= " b.rowid as bid,"; - $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; + $sql .= " c.rowid as crowid, c.subscription,"; + $sql .= " c.datec, c.fk_type as cfk_type,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef,"; + $sql .= " c.fk_bank,"; + $sql .= " b.rowid as bid,"; + $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; $sql .= $db->order($sortfield, $sortorder); - $result = $db->query($sql); - if ($result) { - $subscriptionstatic = new Subscription($db); + $result = $db->query($sql); + if ($result) { + $subscriptionstatic = new Subscription($db); - $num = $db->num_rows($result); + $num = $db->num_rows($result); - print ''."\n"; + print '
'."\n"; - print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print "\n"; + print ''; + print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($conf->banque->enabled)) { + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + print "\n"; - $accountstatic = new Account($db); - $adh = new Adherent($db); - $adht = new AdherentType($db); + $accountstatic = new Account($db); + $adh = new Adherent($db); + $adht = new AdherentType($db); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - $adh->id = $objp->rowid; - $adh->typeid = $objp->type; + $adh->id = $objp->rowid; + $adh->typeid = $objp->type; - $subscriptionstatic->ref = $objp->crowid; - $subscriptionstatic->id = $objp->crowid; + $subscriptionstatic->ref = $objp->crowid; + $subscriptionstatic->id = $objp->crowid; - $typeid = $objp->cfk_type; - if ($typeid > 0) { - $adht->fetch($typeid); - } + $typeid = $objp->cfk_type; + if ($typeid > 0) { + $adht->fetch($typeid); + } - print ''; - print ''; - print '\n"; - print ''; - print '\n"; - print '\n"; - print ''; + print ''; + print ''; + print '\n"; + print ''; + print '\n"; + print '\n"; + print ''; if (!empty($conf->banque->enabled)) { print ''; + print '
'; + } + print ''; - // Bank account - print '\n"; + // Bank account + print '\n"; - // Payment mode - print '\n"; + // Payment mode + print '\n"; - // Date of payment - print '\n"; + // Date of payment + print '\n"; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - } - } + print ''; + print ''; + } + } - print ''; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).'
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).''; if ($objp->bid) { @@ -921,123 +921,123 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - print '
'.$langs->trans("FinancialAccount").''; - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); - print "
'.$langs->trans("FinancialAccount").''; + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); - print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + print "
'.$langs->trans("DatePayment").''; - print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); - print "
'.$langs->trans("DatePayment").''; + print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); + print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
'.$langs->trans("SendAcknowledgementByMail").''; - if (!$object->email) { - print $langs->trans("NoEMail"); - } else { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); + print '
'.$langs->trans("SendAcknowledgementByMail").''; + if (!$object->email) { + print $langs->trans("NoEMail"); + } else { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); - // Send subscription email - $subject = ''; - $msg = ''; + // Send subscription email + $subject = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; - $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; - if ($subjecttosend) { - $helpcontent .= $subjecttosend."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - $helpcontent .= "
"; - $helpcontent .= ''.$langs->trans("MailText").':
'; - if ($texttosend) { - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); - } - print '
'; + $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; + $helpcontent = ''; + $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + $helpcontent .= "
"; + $helpcontent .= ''.$langs->trans("MailText").':
'; + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); + } + print ''; + print ''; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print ''; + print ''; - print "\n\n\n"; - } + print "\n\n\n"; + } - //print ''; - //print ''; + //print ''; + //print ''; } else { - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); } // End of page diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 9b5efa214b9..92e495ad93b 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -110,22 +110,22 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // 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')) { // All tests are required to be compatible with all browsers + // Purge search criteria + 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_type = ""; - $search_ref = ""; - $search_lastname = ""; - $search_firstname = ""; - $search_login = ""; - $search_note = ""; - $search_amount = ""; - $search_account = ""; - $toselect = ''; - $search_array_options = array(); - } + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_login = ""; + $search_note = ""; + $search_amount = ""; + $search_account = ""; + $toselect = ''; + $search_array_options = array(); + } } @@ -153,8 +153,8 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = e $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; if (isset($date_select) && $date_select != '') { - $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; - $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; + $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; + $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; } if ($search_ref) { if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")"; @@ -181,13 +181,13 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($resql); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($resql); + else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; - $offset = 0; - } + $offset = 0; + } } // Add limit $sql .= $db->plimit($limit + 1, $offset); @@ -241,7 +241,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->cotisation->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } print '
'; @@ -409,8 +409,8 @@ while ($i < min($num, $limit)) { $adherent->typeid = $obj->type; $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); - $adht = new AdherentType($db); - $adht->fetch($typeid); + $adht = new AdherentType($db); + $adht->fetch($typeid); print ''; @@ -419,14 +419,14 @@ while ($i < min($num, $limit)) { print ''.$subscription->getNomUrl(1).''; if (!$i) $totalarray['nbfield']++; } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Lastname diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 136c1dab8f4..0414bf20a14 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -33,12 +33,12 @@ $langs->load("members"); $total = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - echo ''; - echo ''.$langs->trans("Subscription").''; - echo ''.$objectlink->getNomUrl(1).''; - echo ''; - echo ''.dol_print_date($objectlink->dateh, 'day').''; - echo ''; + echo ''; + echo ''.$langs->trans("Subscription").''; + echo ''.$objectlink->getNomUrl(1).''; + echo ''; + echo ''.dol_print_date($objectlink->dateh, 'day').''; + echo ''; if ($user->rights->adherent->lire) { $total = $total + $objectlink->amount; echo price($objectlink->amount); @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - echo ''; + echo ''; } echo "\n"; diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index d8deebba9ba..1d37f337a78 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -123,7 +123,7 @@ print dol_get_fiche_end(); print '
'; if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { - print ''.$langs->trans("ForceSynchronize").''; + print ''.$langs->trans("ForceSynchronize").''; } print "
\n"; @@ -146,27 +146,27 @@ print ''; $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result > 0) { - $info = $object->_load_ldap_info(); - $dn = $object->_load_ldap_dn($info, 1); - $search = "(".$object->_load_ldap_dn($info, 2).")"; + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); + $search = "(".$object->_load_ldap_dn($info, 2).")"; - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } - $ldap->unbind(); - $ldap->close(); + $ldap->unbind(); + $ldap->close(); } else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 6cf349270e8..3aafef6f216 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -154,9 +154,9 @@ $titre = $langs->trans("MemberType".$object->type); // Calculate $cnt_trans $cnt_trans = 0; if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $cnt_trans++; - } + foreach ($object->multilangs as $key => $value) { + $cnt_trans++; + } } @@ -179,10 +179,10 @@ print dol_get_fiche_end(); print "\n
\n"; if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - if ($cnt_trans > 0) print ''.$langs->trans("Update").''; - } + if ($user->rights->produit->creer || $user->rights->service->creer) { + print ''.$langs->trans("Add").''; + if ($cnt_trans > 0) print ''.$langs->trans("Update").''; + } } print "\n
\n"; @@ -262,7 +262,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print ''; print ''; print ''; print '\n"; + } + } + closedir($handle); + } + } + } + print '
'.$langs->trans('Language').''; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 6f2a274aed9..1bf1f5c01ce 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -66,7 +66,7 @@ $v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX"); -$country = $adherent->country_code ? $adherent->country : '' ; +$country = $adherent->country_code ? $adherent->country : ''; $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); @@ -79,9 +79,9 @@ $v->setTitle($adherent->poste); if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + if (!$adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + if (!$adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); // when company e-mail is empty, use only adherent e-mail if (empty(trim($company->email))) @@ -124,7 +124,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 0cd9dd52648..1f4236df666 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda')); @@ -86,9 +86,9 @@ if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') | if ($action == "save" && empty($cancel)) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); foreach ($triggers as $trigger) { @@ -102,13 +102,13 @@ if ($action == "save" && empty($cancel)) } if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - $db->commit(); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - $db->rollback(); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + $db->commit(); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + $db->rollback(); + } } diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 0c46e84dff6..36c7bc3edf8 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index c743ed06e55..3cf0d49b960 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -54,9 +54,9 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', ' if ($actionsave) { - $db->begin(); + $db->begin(); - $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); + $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); $i = 1; $errorsaved = 0; @@ -103,14 +103,14 @@ if ($actionsave) $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; } - if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a31c4ed1dbe..c390796a55b 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda', 'users')); @@ -80,49 +80,49 @@ if ($action == 'set') $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -135,7 +135,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -194,115 +194,115 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); + print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - print ''."\n"; + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''."\n"; - clearstatcache(); + clearstatcache(); - foreach ($dirmodels as $reldir) - { - $dir = dol_buildpath($reldir."core/modules/action/doc"); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/action/doc"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new ActionComm($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new ActionComm($db)); - print ''."\n"; - print "\n"; - print "\n"; + print ''."\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - print ''; - print ''; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print ''; - print "\n"; - } - } - closedir($handle); - } - } - } - print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) - print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) + print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=action">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=action">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; + print "

'; } print ''; @@ -343,13 +343,13 @@ print ''."\n"; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; - print ''."\n"; - print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; - print ' '."\n"; - print ''."\n"; - $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); - print ''."\n"; + print ''; + print ''."\n"; + print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; + print ' '."\n"; + print ''."\n"; + $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); + print ''."\n"; } // AGENDA_DEFAULT_FILTER_TYPE @@ -359,8 +359,8 @@ print ' '."\n"; print ''."\n"; $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { - // We use an option here because it adds bugs when used on agenda page "peruser" and "list" - $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); + // We use an option here because it adds bugs when used on agenda page "peruser" and "list" + $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect); print ''."\n"; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 51a9d4f327b..e34536e648a 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -73,49 +73,49 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -128,7 +128,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -200,31 +200,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2) // AGENDA REMINDER BROWSER if ($conf->global->MAIN_FEATURES_LEVEL == 2) { - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - print ''."\n"; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - print ''."\n"; + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + print ''."\n"; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + print ''."\n"; - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - } + if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + } - print ''."\n"; - } + print ''."\n"; + } } print ''; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index fd80a545aa5..61116a0f18f 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -41,23 +41,23 @@ $actionsave = GETPOST('save', 'alpha'); // Sauvegardes parametres if ($actionsave) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); - if ($i >= 4) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("SaveFailed"), null, 'errors'); - } + if ($i >= 4) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("SaveFailed"), null, 'errors'); + } } @@ -163,7 +163,7 @@ $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentit $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); $message .= '
'; $urlical = ''; -$urlical .=$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; +$urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); $message .= '
'; $urlrss = ''; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 7ad9e1d0f23..aff2b90d897 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -81,9 +81,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -103,10 +103,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 529e3289a31..0e7a23ae679 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -44,11 +44,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setbarcodeproducton') { - $barcodenumberingmodule = GETPOST('value', 'alpha'); + $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodeproductoff') { @@ -76,45 +76,45 @@ if ($action == 'setcoder') $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); if ($res > 0) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'updateengine') { - $sql = "SELECT rowid, coder"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, coder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if (GETPOST('coder'.$obj->rowid, 'alpha')) - { - $coder = GETPOST('coder'.$obj->rowid, 'alpha'); - $code_id = $obj->rowid; + if (GETPOST('coder'.$obj->rowid, 'alpha')) + { + $coder = GETPOST('coder'.$obj->rowid, 'alpha'); + $code_id = $obj->rowid; - $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; - $sqlp .= " SET coder = '".$db->escape($coder)."'"; - $sqlp .= " WHERE rowid = ".((int) $code_id); - $sqlp .= " AND entity = ".$conf->entity; + $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; + $sqlp .= " SET coder = '".$db->escape($coder)."'"; + $sqlp .= " WHERE rowid = ".((int) $code_id); + $sqlp .= " AND entity = ".$conf->entity; - $upsql = $db->query($sqlp); - if (!$upsql) dol_print_error($db); - } + $upsql = $db->query($sqlp); + if (!$upsql) dol_print_error($db); + } - $i++; - } - } + $i++; + } + } } @@ -142,11 +142,11 @@ $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_pa foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $handle = @opendir($newdir); if (is_resource($handle)) @@ -190,9 +190,9 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } print ''; @@ -236,11 +236,11 @@ if ($resql) foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir, 0); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $result = @include_once $newdir.$obj->coder.'.modules.php'; if ($result) break; @@ -254,7 +254,7 @@ if ($resql) if ($module->encodingIsSupported($obj->encoding)) { // Build barcode on disk (not used, this is done to make debug easier) - $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); + $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); // Generate on the fly and output barcode with generator $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); //print $url; @@ -282,8 +282,8 @@ print "
\n"; if (empty($conf->use_javascript_ajax)) { - print '
'; - print '
'; + print '
'; + print ''; } print "
"; @@ -371,48 +371,48 @@ if ($conf->product->enabled) $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) + { + $file = substr($file, 0, dol_strlen($file) - 4); - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCode = new $file(); + $modBarCode = new $file(); - print ''; - print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; - print $modBarCode->info($langs); - print ''; - print ''.$modBarCode->getExample($langs)."\n"; + print ''; + print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''; + print ''.$modBarCode->getExample($langs)."\n"; - if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - $s = $modBarCode->getToolTip($langs, null, -1); - print $form->textwithpicto('', $s, 1); - print ''; - print "\n"; - } - } - closedir($handle); - } + if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") + { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print ''; + print "\n"; + } + } + closedir($handle); + } } print "\n"; } diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index 8ae26587ebd..f2022229305 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 5fa7b78ca8b..566d6b845e8 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -33,7 +33,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); -if (! in_array('clicktodial', $conf->modules)) { +if (!in_array('clicktodial', $conf->modules)) { accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name"))); } @@ -44,15 +44,15 @@ if (! in_array('clicktodial', $conf->modules)) { if ($action == 'setvalue' && $user->admin) { - $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); - if ($result1 >= 0 && $result2 >= 0) - { + if ($result1 >= 0 && $result2 >= 0) + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -125,7 +125,7 @@ if (!empty($conf->global->CLICKTODIAL_URL)) if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest'); print '
'; - print ''; + print ''; print $langs->trans("LinkToTestClickToDial", $user->login).' : '; print ''; print ''; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index faf38f44b16..a647d096037 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -40,14 +40,14 @@ $action = GETPOST('action', 'aZ09'); // Other parameters ACCOUNTING_* $list = array( - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'ACCOUNTING_ACCOUNT_SUPPLIER' + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER' ); /* @@ -58,52 +58,52 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { - $error = 0; + $error = 0; - $accounting_modes = array( - 'RECETTES-DEPENSES', - 'CREANCES-DETTES' - ); + $accounting_modes = array( + 'RECETTES-DEPENSES', + 'CREANCES-DETTES' + ); - $accounting_mode = GETPOST('accounting_mode', 'alpha'); + $accounting_mode = GETPOST('accounting_mode', 'alpha'); - if (in_array($accounting_mode, $accounting_modes)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (in_array($accounting_mode, $accounting_modes)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } - $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); - if (!empty($report_include_varpay)) - if ($report_include_varpay == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_varpay == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; + $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); + if (!empty($report_include_varpay)) + if ($report_include_varpay == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_varpay == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; - $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); - if (!empty($report_include_loan)) - if ($report_include_loan == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_loan == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; + $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); + if (!empty($report_include_loan)) + if ($report_include_loan == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_loan == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 4aacdb3cfc2..baf5fae0b34 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -155,7 +155,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); // Add logic to show/hide buttons if ($conf->use_javascript_ajax) { - ?> + ?> '; - form_constantes($constantes, 2); + form_constantes($constantes, 2); - print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print '
'; + print ''; } else { - print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=img_$langs->trans("Activate") - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); + $link = ''; + //$link.=img_$langs->trans("Activate") + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestUnSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestUnSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; } // End of page diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index cc81c78255d..87796f43997 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -67,18 +67,18 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && !$cancel) { - if (! $error && ! GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { + if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors'); $action = 'edit'; } - if (! $error && ! isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { + if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { $error++; setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors'); $action = 'edit'; } - if (! $error) { + if (!$error) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); @@ -188,13 +188,13 @@ if ($action == 'edit') jQuery("#smtp_server_mess").show(); jQuery("#smtp_port_mess").show();'; } else { - print ' + print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide();'; - } - print ' + } + print ' } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') { @@ -266,7 +266,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); }); })'; - print ''."\n"; + print ''."\n"; } print '
'; @@ -409,8 +409,8 @@ if ($action == 'edit') print ''; } - // TLS - print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + // TLS + print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) @@ -453,20 +453,20 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - // DKIM Domain - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''; + // DKIM Domain + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; + print ''; - // DKIM Selector - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''; + // DKIM Selector + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; + print ''; - // DKIM PRIVATE KEY - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''; - print ''; + // DKIM PRIVATE KEY + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; + print ''; + print ''; print ''; @@ -635,20 +635,20 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - // Domain - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - print ''; + // Domain + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print ''; - // Selector - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - print ''; + // Selector + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print ''; - // PRIVATE KEY - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - print ''; + // PRIVATE KEY + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print ''; } print ''; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index a464c0fca8e..6a42e14bff6 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity); @@ -382,22 +382,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print ''; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } else { - print dol_get_fiche_head($head, 'common_emailing', '', -1); + print dol_get_fiche_head($head, 'common_emailing', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -478,10 +478,10 @@ if ($action == 'edit') print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -491,12 +491,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -527,8 +527,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -556,7 +556,7 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print dol_get_fiche_head(''); @@ -592,7 +592,7 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 8cbd9675160..c7a86766a32 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -274,7 +274,7 @@ if (empty($reshook)) if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif ($keycode == 'fk_user') { - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " ".((int) $user->id); } else { $sql .= " ".((int) GETPOST($keycode, 'fk_user')); @@ -333,7 +333,7 @@ if (empty($reshook)) if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif ($keycode == 'fk_user') { - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " ".((int) $user->id); } else { $sql .= " ".((int) GETPOST($keycode, 'fk_user')); @@ -350,7 +350,7 @@ if (empty($reshook)) } $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " AND fk_user = ".$user->id; } //print $sql;exit; @@ -371,7 +371,7 @@ if (empty($reshook)) $rowidcol = "rowid"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid); - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " AND fk_user = ".$user->id; } dol_syslog("delete", LOG_DEBUG); @@ -493,7 +493,7 @@ if ($action == 'view') { if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); $align="center"; } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); $align = "center"; } if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; } @@ -795,13 +795,13 @@ if ($resql) print "\n"; } else { - if ($obj->module) { - $tempmodulekey = $obj->module; - if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { - $i++; - continue; - } - } + if ($obj->module) { + $tempmodulekey = $obj->module; + if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + $i++; + continue; + } + } $keyforobj = 'type_template'; if (!in_array($obj->$keyforobj, array_keys($elementList))) { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index e0a42ee3a2d..dda9d0c01a8 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity); @@ -359,22 +359,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } else { - print dol_get_fiche_head($head, 'common_ticket', '', -1); + print dol_get_fiche_head($head, 'common_ticket', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -444,10 +444,10 @@ if ($action == 'edit') print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -457,12 +457,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -493,8 +493,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -522,7 +522,7 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print dol_get_fiche_head(''); @@ -558,7 +558,7 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f81a80794d3..f55a2a74874 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -38,8 +38,8 @@ $dirsmartphone = array(); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); foreach ($dirmenus as $dirmenu) { - $dirstandard[] = $dirmenu.'standard'; - $dirsmartphone[] = $dirmenu.'smartphone'; + $dirstandard[] = $dirmenu.'standard'; + $dirsmartphone[] = $dirmenu.'smartphone'; } $action = GETPOST('action', 'aZ09'); @@ -244,13 +244,13 @@ if ($action == 'delete') $result = $db->query($sql); $obj = $db->fetch_object($result); - print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); + print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); } $newcardbutton = ''; if ($user->admin) { - $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); } print '
'; @@ -297,7 +297,7 @@ if ($conf->use_javascript_ajax) //il faut d'abord declarer un element racine de l'arbre - $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); //puis tous les elements enfants @@ -337,16 +337,16 @@ if ($conf->use_javascript_ajax) $data[] = array( 'rowid'=>$menu['rowid'], - 'module'=>$menu['module'], + 'module'=>$menu['module'], 'fk_menu'=>$menu['fk_menu'], 'title'=>$titre, - 'mainmenu'=>$menu['mainmenu'], + 'mainmenu'=>$menu['mainmenu'], 'leftmenu'=>$menu['leftmenu'], 'fk_mainmenu'=>$menu['fk_mainmenu'], 'fk_leftmenu'=>$menu['fk_leftmenu'], - 'position'=>$menu['position'], + 'position'=>$menu['position'], 'entry'=>$entry, - 'buttons'=>$buttons + 'buttons'=>$buttons ); $i++; } @@ -369,36 +369,36 @@ if ($conf->use_javascript_ajax) // Process remaining records (records that are not linked to root by any path) - $remainingdata = array(); + $remainingdata = array(); foreach ($data as $datar) { - if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; - $remainingdata[] = $datar; + if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; + $remainingdata[] = $datar; } if (count($remainingdata)) { - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("NotTopTreeMenuPersonalized").'
'.$langs->trans("NotTopTreeMenuPersonalized").'
'; - foreach ($remainingdata as $datar) - { - $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); - //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; - tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); - } + print '
'; + foreach ($remainingdata as $datar) + { + $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; + tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); + } - print '
'; + print ''; } print '
'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 9aec5ef0c29..78b4d10b0c0 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -91,106 +91,106 @@ foreach ($modulesdir as $dir) while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - if (!empty($modNameLoaded[$modName])) - { - $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; - setEventMessages($mesg, null, 'warnings'); - dol_syslog($mesg, LOG_ERR); + if ($modName) + { + if (!empty($modNameLoaded[$modName])) + { + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + setEventMessages($mesg, null, 'warnings'); + dol_syslog($mesg, LOG_ERR); continue; - } + } - try { - $res = include_once $dir.$file; - if (class_exists($modName)) + try { + $res = include_once $dir.$file; + if (class_exists($modName)) { try { - $objMod = new $modName($db); + $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') - { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); - } + if (!$objMod->numero > 0 && $modName != 'modUser') + { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + } $j = $objMod->numero; - $modulequalified = 1; + $modulequalified = 1; - // We discard modules according to features level (PS: if module is activated we always show it) - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; - // We discard modules according to property disabled - //if (! empty($objMod->hidden)) $modulequalified=0; + // We discard modules according to property disabled + //if (! empty($objMod->hidden)) $modulequalified=0; - if ($modulequalified > 0) - { - $publisher = dol_escape_htmltag($objMod->getPublisher()); - $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) - { - if ($publisher) - { - $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; - } else { - $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); - } - } - ksort($arrayofnatures); - } + if ($modulequalified > 0) + { + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); + if ($external) + { + if ($publisher) + { + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; + } else { + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); + } + } + ksort($arrayofnatures); + } - // Define array $categ with categ with at least one qualified module - if ($modulequalified > 0) - { - $modules[$i] = $objMod; - $filename[$i] = $modName; + // Define array $categ with categ with at least one qualified module + if ($modulequalified > 0) + { + $modules[$i] = $objMod; + $filename[$i] = $modName; - // Gives the possibility to the module, to provide his own family info and position of this family - if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { - if (!is_array($familyinfo)) $familyinfo = array(); - $familyinfo = array_merge($familyinfo, $objMod->familyinfo); - $familykey = key($objMod->familyinfo); - } else { - $familykey = $objMod->family; - } + // Gives the possibility to the module, to provide his own family info and position of this family + if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { + if (!is_array($familyinfo)) $familyinfo = array(); + $familyinfo = array_merge($familyinfo, $objMod->familyinfo); + $familykey = key($objMod->familyinfo); + } else { + $familykey = $objMod->family; + } - $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) - { - $moduleposition = '80'; // External modules at end by default - } + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); + if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) + { + $moduleposition = '80'; // External modules at end by default + } - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - $dirmod[$i] = $dir; - //print $i.'-'.$dirmod[$i].'
'; - // Set categ[$i] - $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring] = 1; - $j++; - $i++; - } else dol_syslog("Module ".get_class($objMod)." not qualified"); + $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + $dirmod[$i] = $dir; + //print $i.'-'.$dirmod[$i].'
'; + // Set categ[$i] + $specialstring = 'unknown'; + if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; + if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories + else $categ[$specialstring] = 1; + $j++; + $i++; + } else dol_syslog("Module ".get_class($objMod)." not qualified"); } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } } else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } - } - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } + } + } } closedir($handle); } else { @@ -208,16 +208,16 @@ unset($objMod); $i = 0; foreach ($orders as $tmpkey => $tmpvalue) { - $tmpMod = $modules[$tmpkey]; - if ($tmpMod->numero == $id) - { - $key = $i; - $modName = $filename[$tmpkey]; - $dirofmodule = $dirmod[$tmpkey]; - $objMod = $tmpMod; - break; - } - $i++; + $tmpMod = $modules[$tmpkey]; + if ($tmpMod->numero == $id) + { + $key = $i; + $modName = $filename[$tmpkey]; + $dirofmodule = $dirmod[$tmpkey]; + $objMod = $tmpMod; + break; + } + $i++; } $value = $orders[$key]; $tab = explode('_', $value); @@ -296,7 +296,7 @@ $versiontrans .= $objMod->getVersion(1); $imginfo = "info"; if ($objMod->isCoreOrExternalModule() == 'external') { - $imginfo = "info_black"; + $imginfo = "info_black"; } // Define text of description of module @@ -304,138 +304,138 @@ $text = ''; if ($mode == 'desc') { - if ($moduledesc) $text .= '
'.$moduledesc.'


'; + if ($moduledesc) $text .= '
'.$moduledesc.'


'; - $text .= ''.$langs->trans("Version").': '.$version; + $text .= ''.$langs->trans("Version").': '.$version; - $moduledescriptorfile = get_class($objMod).'.class.php'; - $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; + $moduledescriptorfile = get_class($objMod).'.class.php'; + $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; - $textexternal = ''; - if ($objMod->isCoreOrExternalModule() == 'external') - { - $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); - if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); - $editor_url = $objMod->editor_url; - if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; - if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; - $text .= $textexternal; - $text .= '
'; - } else { - $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; - } + $textexternal = ''; + if ($objMod->isCoreOrExternalModule() == 'external') + { + $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); + if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); + $editor_url = $objMod->editor_url; + if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; + if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; + $text .= $textexternal; + $text .= '
'; + } else { + $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; + } - $moduledesclong = $objMod->getDescLong(); - if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; + $moduledesclong = $objMod->getDescLong(); + if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; } if ($mode == 'feature') { - $text .= '
'.$langs->trans("DependsOn").': '; - if (count($objMod->depends)) $text .= join(',', $objMod->depends); + $text .= '
'.$langs->trans("DependsOn").': '; + if (count($objMod->depends)) $text .= join(',', $objMod->depends); else $text .= $langs->trans("None"); - $text .= '
'.$langs->trans("RequiredBy").': '; + $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby); else $text .= $langs->trans("None"); - $text .= '

'; + $text .= '

'; - $text .= '
'.$langs->trans("AddDataTables").': '; + $text .= '
'.$langs->trans("AddDataTables").': '; $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); - if (count($sqlfiles) > 0) - { - $text .= $langs->trans("Yes").' ('; - $i = 0; - foreach ($sqlfiles as $val) - { - $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); - $i++; - } - $text .= ')'; - } else $text .= $langs->trans("No"); + if (count($sqlfiles) > 0) + { + $text .= $langs->trans("Yes").' ('; + $i = 0; + foreach ($sqlfiles as $val) + { + $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $i++; + } + $text .= ')'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddDictionaries").': '; - if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) - { - $i = 0; - foreach ($objMod->dictionaries['tablib'] as $val) - { - $text .= ($i ? ', ' : '').$val; - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddDictionaries").': '; + if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) + { + $i = 0; + foreach ($objMod->dictionaries['tablib'] as $val) + { + $text .= ($i ? ', ' : '').$val; + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddData").': '; - $filedata = dol_buildpath($moduledir.'/sql/data.sql'); - if (dol_is_file($filedata)) - { - $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddData").': '; + $filedata = dol_buildpath($moduledir.'/sql/data.sql'); + if (dol_is_file($filedata)) + { + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddRemoveTabs").': '; - if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) - { - $i = 0; - foreach ($objMod->tabs as $val) - { - if (is_array($val)) $val = $val['data']; - if (is_string($val)) - { - $tmp = explode(':', $val, 3); - $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; - $i++; - } - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddRemoveTabs").': '; + if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) + { + $i = 0; + foreach ($objMod->tabs as $val) + { + if (is_array($val)) $val = $val['data']; + if (is_string($val)) + { + $tmp = explode(':', $val, 3); + $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; + $i++; + } + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddModels").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddModels").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSubstitutions").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSubstitutions").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSheduledJobs").': '; - if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) - { - $i = 0; - foreach ($objMod->cronjobs as $val) - { - $text .= ($i ? ', ' : '').($val['label']); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSheduledJobs").': '; + if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) + { + $i = 0; + foreach ($objMod->cronjobs as $val) + { + $text .= ($i ? ', ' : '').($val['label']); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddTriggers").': '; - $moreinfoontriggerfile = ''; - if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) - { - $yesno = 'Yes'; - } else { - $yesno = 'No'; - } - require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interfaces = new Interfaces($db); - $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); + $text .= '
'.$langs->trans("AddTriggers").': '; + $moreinfoontriggerfile = ''; + if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) + { + $yesno = 'Yes'; + } else { + $yesno = 'No'; + } + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interfaces = new Interfaces($db); + $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); foreach ($triggers as $triggercursor) { if ($triggercursor['module'] == $moduledir) @@ -445,110 +445,110 @@ if ($mode == 'feature') } } - $text .= $langs->trans($yesno).$moreinfoontriggerfile; + $text .= $langs->trans($yesno).$moreinfoontriggerfile; - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddBoxes").': '; - if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) - { - $i = 0; - foreach ($objMod->boxes as $val) - { - $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddBoxes").': '; + if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) + { + $i = 0; + foreach ($objMod->boxes as $val) + { + $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddHooks").': '; - if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) - { - $i = 0; - foreach ($objMod->module_parts['hooks'] as $key => $val) - { - if ($key === 'entity') continue; + $text .= '
'.$langs->trans("AddHooks").': '; + if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) + { + $i = 0; + foreach ($objMod->module_parts['hooks'] as $key => $val) + { + if ($key === 'entity') continue; - // For special values - if ($key === 'data') - { - if (is_array($val)) - { - foreach ($val as $value) - { - $text .= ($i ? ', ' : '').($value); - $i++; - } + // For special values + if ($key === 'data') + { + if (is_array($val)) + { + foreach ($val as $value) + { + $text .= ($i ? ', ' : '').($value); + $i++; + } - continue; - } - } + continue; + } + } - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddPermissions").': '; - if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) - { - $i = 0; - foreach ($objMod->rights as $val) - { - $text .= ($i ? ', ' : '').($val[1]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddPermissions").': '; + if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) + { + $i = 0; + foreach ($objMod->rights as $val) + { + $text .= ($i ? ', ' : '').($val[1]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddMenus").': '; - if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddMenus").': '; + if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddExportProfiles").': '; - if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) - { - $i = 0; - foreach ($objMod->export_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddExportProfiles").': '; + if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) + { + $i = 0; + foreach ($objMod->export_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddImportProfiles").': '; - if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) - { - $i = 0; - foreach ($objMod->import_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddImportProfiles").': '; + if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) + { + $i = 0; + foreach ($objMod->import_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; + $text .= $langs->trans("DetectionNotPossible"); } if ($mode == 'changelog') { - $changelog = $objMod->getChangeLog(); - if ($changelog) $text .= '
'.$changelog.'
'; - else $text .= '
'.$langs->trans("NotAvailable").'
'; + $changelog = $objMod->getChangeLog(); + if ($changelog) $text .= '
'.$changelog.'
'; + else $text .= '
'.$langs->trans("NotAvailable").'
'; } print $text; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c97ccb182b8..e7b7e2cd59b 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,7 +28,7 @@ * \brief Page to activate/disable all modules */ -if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -404,7 +404,7 @@ foreach ($modulesdir as $dir) $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && ! in_array($familykey, $listOfOfficialModuleGroups)) + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). if (is_numeric($familyposition)) { diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index e81c7f1cf75..2a48713869c 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1973ec95909..962adae93aa 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -34,7 +34,7 @@ $langs->loadLangs(array('admin', 'multicurrency')); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -52,9 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) $value = GETPOST($code, 'alpha'); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -63,9 +63,9 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -132,17 +132,17 @@ if ($action == 'add_currency') } } elseif ($action == 'setapilayer') { - if (GETPOSTISSET('modify_apilayer')) - { - dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); - dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); - //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); - } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); - if ($result > 0) { - setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); - } - } + if (GETPOSTISSET('modify_apilayer')) + { + dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); + dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); + //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); + } else { + $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + if ($result > 0) { + setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); + } + } } @@ -189,10 +189,10 @@ print ''; print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); + print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); } print ''; @@ -201,26 +201,26 @@ print ''; print ''.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); + print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); } print ''; // Online payment with currency on document. This option should be on by default. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); - } - print ''; + print ''; + print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); + } + print ''; } /* TODO uncomment when the functionality will integrated @@ -258,9 +258,9 @@ print '
'; if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; print ''; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index b484e7acea9..13b1b4b3e55 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -61,8 +61,8 @@ if ($action == 'settemplates') $triggername = $reg[1]; $constvalue = GETPOST($key, 'alpha'); $consttype = 'emailtemplate:xxx'; - $tmparray=explode(':', $constvalue); - if (! empty($tmparray[0]) && ! empty($tmparray[1])) { + $tmparray = explode(':', $constvalue); + if (!empty($tmparray[0]) && !empty($tmparray[1])) { $constvalue = $tmparray[0]; $consttype = 'emailtemplate:'.$tmparray[1]; //var_dump($constvalue); @@ -96,19 +96,19 @@ if ($action == 'setvalue' && $user->admin) $db->begin(); $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", GETPOST("email_from", "restricthtml"), 'chaine', 0, '', $conf->entity); - if ($result < 0) $error++; + if ($result < 0) $error++; - if (!$error) - { - $db->commit(); + if (!$error) + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -116,50 +116,50 @@ if ($action == 'setfixednotif' && $user->admin) { $db->begin(); - if (!$error && is_array($_POST)) - { - $reg = array(); - foreach ($_POST as $key => $val) - { - if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; + if (!$error && is_array($_POST)) + { + $reg = array(); + foreach ($_POST as $key => $val) + { + if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; - $newval = ''; - $newkey = ''; + $newval = ''; + $newkey = ''; - $shortkey = preg_replace('/_key$/', '', $key); - //print $shortkey.'
'; + $shortkey = preg_replace('/_key$/', '', $key); + //print $shortkey.'
'; - if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) - { + if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) + { dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity); $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); $newval = GETPOST($shortkey.'_key'); //print $newkey.' - '.$newval.'
'; - } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) - { - // Add a new entry - $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval = GETPOST($shortkey.'_key'); - } + } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) + { + // Add a new entry + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); + } - if ($newkey && $newval) - { + if ($newkey && $newval) + { $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); - } - } - } + } + } + } if (!$error) - { - $db->commit(); + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -318,66 +318,66 @@ print "\n"; foreach ($listofnotifiedevents as $notifiedevent) { - $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; - $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); + $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); // Special cases - if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); - elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); - elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); - elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); + if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); + elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); + elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); + elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + } + // New entry input fields + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; } print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; - $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; + $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - $arrayemail = explode(',', $value); + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $arrayemail = explode(',', $value); $showwarning = 0; foreach ($arrayemail as $keydet => $valuedet) { $valuedet = trim($valuedet); if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++; } - if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); - print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); + if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); + print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
'; - } - // New entry input fields - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); - print '
'; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print ''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - print $langs->trans("AmountHT").' >= '; + print $langs->trans("AmountHT").' >= '; print '
'; - } - // New entry input fields + } + // New entry input fields print $langs->trans("AmountHT").' >= '; print '
'; + print ''; // TODO Add link to show message content - print '
'; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index af352558a71..a71e09fad56 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('admin', 'oauth')); // Security check if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'aZ09'); @@ -49,23 +49,23 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'update') { - $error = 0; + $error = 0; - foreach ($list as $constname) { - $constvalue = GETPOST($constname[1], 'alpha'); - if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - $constvalue = GETPOST($constname[2], 'alpha'); - if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - } + foreach ($list as $constname) { + $constvalue = GETPOST($constname[1], 'alpha'); + if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + $constvalue = GETPOST($constname[2], 'alpha'); + if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -97,46 +97,46 @@ $i = 0; // $list is defined into oauth.lib.php foreach ($list as $key) { - $supported = 0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; - if (!$supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported - $i++; + $i++; - print ''; - // Api Name - $label = $langs->trans($key[0]); - print ''.$label.''; - print ''; - if (!empty($key[3])) print $langs->trans($key[3]); - print ''; - print ''; + print ''; + // Api Name + $label = $langs->trans($key[0]); + print ''.$label.''; + print ''; + if (!empty($key[3])) print $langs->trans($key[3]); + print ''; + print ''; - if ($supported) - { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''; - print ''; - } else { - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''.$langs->trans("FeatureNotYetSupported").''; - print ''; - } + if ($supported) + { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; + print ''; + } else { + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''.$langs->trans("FeatureNotYetSupported").''; + print ''; + } - // Api Id - print ''; - print ''; - print ''; - print ''; + // Api Id + print ''; + print ''; + print ''; + print ''; - // Api Secret - print ''; - print ''; - print ''; - print ''; + // Api Secret + print ''; + print ''; + print ''; + print ''; } print ''."\n"; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 99510f4b7c8..4fb0bbb7452 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -156,7 +156,7 @@ if ($mode == 'setup' && $user->admin) // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // We pass this param list in to 'state' because we need it before and after the redirect. $shortscope = 'userinfo_email,userinfo_profile,cloud_print'; - if (!empty($conf->global->OAUTH_GSUITE)){ + if (!empty($conf->global->OAUTH_GSUITE)) { $shortscope .= ',admin_directory_user'; } //$scope.=',gmail_full'; diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index 9d70fdedff7..7cd803d5e69 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -97,37 +97,37 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') print ''; print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; - print ''; - print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 81d0312ab69..5d5573d4579 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -83,9 +83,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 734d617f564..2f7462a3cf0 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 8edf851f49e..d92704c211b 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -47,23 +47,23 @@ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_pay if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); - $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); + $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskpayment = GETPOST('maskpayment', 'alpha'); + if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'setmod') { - dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'setparams') @@ -72,8 +72,8 @@ if ($action == 'setparams') $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) { @@ -81,7 +81,7 @@ if ($action == 'setparams') } if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -123,105 +123,105 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) - { - $var = !$var; - print ''; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + $var = !$var; + print ''; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; - if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; + if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $payment = new Paiement($db); - $payment->initAsSpecimen(); + $payment = new Paiement($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 363edca6c80..75681ad36c0 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha'); */ if ($cancel) { - $action = ''; + $action = ''; } if ($action == 'update') @@ -78,10 +78,10 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 3677daa38a5..4905f4f2497 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -44,18 +44,18 @@ $entity = $conf->entity; if ($action == 'add') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; - $sql .= " WHERE id = ".GETPOST("pid", 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; + $sql .= " WHERE id = ".GETPOST("pid", 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } if ($action == 'remove') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; - $sql .= " WHERE id = ".GETPOST('pid', 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; + $sql .= " WHERE id = ".GETPOST('pid', 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } @@ -145,81 +145,81 @@ $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $oldmod = ''; + $num = $db->num_rows($result); + $i = 0; + $oldmod = ''; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); - // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it - if (empty($modules[$obj->module])) - { - $i++; - continue; - } + // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it + if (empty($modules[$obj->module])) + { + $i++; + continue; + } - // Save field module_position in database if value is still zero - if (empty($obj->module_position)) - { - if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) - { - // TODO Define familyposition - $family = $modules[$obj->module]->family_position; - $familyposition = 0; - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; - $sqlupdate .= " family_position = ".$familyposition; - $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; - $db->query($sqlupdate); - } - } + // Save field module_position in database if value is still zero + if (empty($obj->module_position)) + { + if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) + { + // TODO Define familyposition + $family = $modules[$obj->module]->family_position; + $familyposition = 0; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; + $sqlupdate .= " family_position = ".$familyposition; + $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; + $db->query($sqlupdate); + } + } - // Check if permission we found is inside a module definition. If not, we discard it. - $found = false; - foreach ($modules[$obj->module]->rights as $key => $val) - { - if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) - { - $found = true; - break; - } - } + // Check if permission we found is inside a module definition. If not, we discard it. + $found = false; + foreach ($modules[$obj->module]->rights as $key => $val) + { + if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) + { + $found = true; + break; + } + } if (!$found) { $i++; continue; } - // Break found, it's a new module to catch + // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) - { - $oldmod = $obj->module; + { + $oldmod = $obj->module; - // Break detected, we get objMod - $objMod = $modules[$obj->module]; - $picto = ($objMod->picto ? $objMod->picto : 'generic'); + // Break detected, we get objMod + $objMod = $modules[$obj->module]; + $picto = ($objMod->picto ? $objMod->picto : 'generic'); - // Show break line - print ''; - print ''; - print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); - print ''; - print ''; - print ' '; - print ' '; - print ' '; - // Permission id - if ($user->admin) print ''; - print ''."\n"; - } + // Show break line + print ''; + print ''; + print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); + print ''; + print ''; + print ' '; + print ' '; + print ' '; + // Permission id + if ($user->admin) print ''; + print ''."\n"; + } - $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); + $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); - print ''; + print ''; - // Picto and label of module - print ''; + // Picto and label of module + print ''; print ''; // Tick @@ -247,15 +247,15 @@ if ($result) } // Permission and tick - print ''.$perm_libelle.''; + print ''.$perm_libelle.''; - // Permission id - if ($user->admin) print ''.$obj->id.''; + // Permission id + if ($user->admin) print ''.$obj->id.''; - print ''."\n"; + print ''."\n"; - $i++; - } + $i++; + } } else dol_print_error($db); print ''; print '
'; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 5123cec7f08..e75a06a78ad 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -76,7 +76,7 @@ if ($action == 'updateMask') { $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -154,25 +154,25 @@ if ($action == 'updateMask') { setEventMessages($langs->trans("Error"), null, 'errors'); } } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set') { // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); + if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { + if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->PROPALE_ADDON_PDF = $value; } @@ -253,13 +253,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->PROPALE_ADDON == "$file") @@ -280,16 +280,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $propal->type = 0; $nextval = $module->getNextValue($mysoc, $propal); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -348,83 +348,83 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/propale".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/propale".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - $var = !$var; - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + $var = !$var; + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->PROPALE_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ""; + if ($conf->global->PROPALE_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = $langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = $langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); @@ -434,28 +434,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -623,11 +623,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->tra $variablename = 'PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index d7287b53019..219643e8303 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -83,9 +83,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index db91aae87a1..d9eae8f064e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -53,51 +53,51 @@ if ($action == 'setgeneraterule') if ($action == 'activate_encrypt') { - $error = 0; + $error = 0; $db->begin(); - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; - $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value + $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - $i = 0; - while ($i < $numrows) - { - $obj = $db->fetch_object($resql); - if (dol_hash($obj->pass)) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; - $sql .= " WHERE rowid=".$obj->rowid; - //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + $i = 0; + while ($i < $numrows) + { + $obj = $db->fetch_object($resql); + if (dol_hash($obj->pass)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; + $sql .= " WHERE rowid=".$obj->rowid; + //print $sql; - $resql2 = $db->query($sql); - if (!$resql2) - { - dol_print_error($db); - $error++; - break; - } + $resql2 = $db->query($sql); + if (!$resql2) + { + dol_print_error($db); + $error++; + break; + } - $i++; - } - } - } else dol_print_error($db); + $i++; + } + } + } else dol_print_error($db); //print $error." ".$sql; - //exit; - if (!$error) + //exit; + if (!$error) { $db->commit(); header("Location: security.php"); - exit; + exit; } else { $db->rollback(); dol_print_error($db, ''); @@ -109,9 +109,9 @@ if ($action == 'activate_encrypt') if ($allow_disable_encryption) { dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); - } + } header("Location: security.php"); - exit; + exit; } if ($action == 'activate_encryptdbpassconf') @@ -119,9 +119,9 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(1); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - // database value not required + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); exit; @@ -133,7 +133,7 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(0); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); @@ -158,24 +158,24 @@ if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'updatepattern') { - $pattern = GETPOST("pattern", "alpha"); - $explodePattern = explode(';', $pattern); + $pattern = GETPOST("pattern", "alpha"); + $explodePattern = explode(';', $pattern); - $patternInError = false; - if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { - $patternInError = true; - } + $patternInError = false; + if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { + $patternInError = true; + } - if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { - $patternInError = true; - } + if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { + $patternInError = true; + } - if (!$patternInError) { - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - header("Location: security.php"); - exit; - } + if (!$patternInError) { + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + header("Location: security.php"); + exit; + } } @@ -214,20 +214,20 @@ $handle = opendir($dir); $i = 1; if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) - { - // Charging the numbering class - $classname = $reg[1]; - require_once $dir.'/'.$file; + while (($file = readdir($handle)) !== false) + { + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) + { + // Charging the numbering class + $classname = $reg[1]; + require_once $dir.'/'.$file; - $obj = new $classname($db, $conf, $langs, $user); - $arrayhandler[$obj->id] = $obj; - $i++; - } - } - closedir($handle); + $obj = new $classname($db, $conf, $langs, $user); + $arrayhandler[$obj->id] = $obj; + $i++; + } + } + closedir($handle); } asort($arrayhandler); @@ -241,33 +241,33 @@ print ''; foreach ($arrayhandler as $key => $module) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) { - print ''; - print ucfirst($key); - print "\n"; - print $module->getDescription().'
'; - print $langs->trans("MinLength").': '.$module->length; - print ''; + print ''; + print ucfirst($key); + print "\n"; + print $module->getDescription().'
'; + print $langs->trans("MinLength").': '.$module->length; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->USER_PASSWORD_GENERATED == $key) - { - print img_picto('', 'tick'); - } else { - print ''.$langs->trans("Activate").''; - } - print "\n"; + print ''; + if ($conf->global->USER_PASSWORD_GENERATED == $key) + { + print img_picto('', 'tick'); + } else { + print ''.$langs->trans("Activate").''; + } + print "\n"; } } print ''; @@ -493,14 +493,14 @@ print '
'; if (GETPOST('info', 'int') > 0) { - if (function_exists('password_hash')) - { - print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; - } else { - print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; - } - print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; - print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; + } else { + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; } print '
'; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 2e4f1f05229..5f063dbe2a2 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -121,8 +121,8 @@ if (function_exists("imagecreatefrompng")) } } } else { - $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); - print $desc; + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; } print ''; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index e09304a4921..e34d2ab9b7a 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -86,32 +86,32 @@ if ($action == 'send' && !$_POST['cancel']) if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); - $action = 'test'; - $error++; + $action = 'test'; + $error++; + } + if (empty($body)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); + $action = 'test'; + $error++; } - if (empty($body)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); - $action = 'test'; - $error++; - } if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); - $action = 'test'; + $action = 'test'; $error++; } if (empty($sendto) || !str_replace('+', '', $sendto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); - $action = 'test'; + $action = 'test'; $error++; } if (!$error) { // Make substitutions into message - complete_substitutions_array($substitutionarrayfortest, $langs); - $body = make_substitutions($body, $substitutionarrayfortest); + complete_substitutions_array($substitutionarrayfortest, $langs); + $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; @@ -180,7 +180,7 @@ if ($action == 'edit') print ''.$langs->trans("MAIN_SMS_SENDMODE").''; if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); else print ''.$langs->trans("None").''; - print ''; + print ''; // From print ''.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''; @@ -259,9 +259,9 @@ if ($action == 'edit') if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } else { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } print '
'; @@ -298,9 +298,9 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - $formsms->fromtype = 'user'; - $formsms->fromid = $user->id; - $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); + $formsms->fromtype = 'user'; + $formsms->fromid = $user->id; + $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); $formsms->withfromreadonly = 0; $formsms->withsubstit = 0; $formsms->withfrom = 1; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index faf8897126f..0ab3a91432b 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -43,26 +43,26 @@ $action = GETPOST('action', 'aZ09'); */ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } @@ -96,15 +96,15 @@ print '
'; $arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); foreach ($arrayofsocialnetworks as $snkey => $snlabel) { - $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if ($conf->use_javascript_ajax) { - $link = ajax_constantonoff($consttocheck); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); - } + $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); + if ($conf->use_javascript_ajax) { + $link = ajax_constantonoff($consttocheck); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); + } - print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; } diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index fe98d4bfe9e..2fa111578a9 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -55,48 +55,48 @@ if ($action == 'update' || $action == 'add') $consttypearray = GETPOST("consttype", 'array'); $constnotearray = GETPOST("constnote", 'array'); - // Action mise a jour ou ajout d'une constante - if ($action == 'update' || $action == 'add') - { - foreach ($constnamearray as $key => $val) - { - $constname = dol_escape_htmltag($constnamearray[$key]); - $constvalue = dol_escape_htmltag($constvaluearray[$key]); - $consttype = dol_escape_htmltag($consttypearray[$key]); - $constnote = dol_escape_htmltag($constnotearray[$key]); + // Action mise a jour ou ajout d'une constante + if ($action == 'update' || $action == 'add') + { + foreach ($constnamearray as $key => $val) + { + $constname = dol_escape_htmltag($constnamearray[$key]); + $constvalue = dol_escape_htmltag($constvaluearray[$key]); + $consttype = dol_escape_htmltag($consttypearray[$key]); + $constnote = dol_escape_htmltag($constnotearray[$key]); - $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); + $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); - if (!$res > 0) $error++; - } + if (!$res > 0) $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } // Action activation d'un sous module du module adherent if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } // Action desactivation d'un sous module du module adherent if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } @@ -128,39 +128,39 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); - //$link=img_picto($langs->trans("Active"),'tick').' '; - $link = ''; - //$link.=$langs->trans("Disable"); - $link .= img_picto($langs->trans("Activated"), 'switch_on'); - $link .= ''; - // Edition des varibales globales - $constantes = array( - 'ADHERENT_SPIP_SERVEUR', - 'ADHERENT_SPIP_DB', - 'ADHERENT_SPIP_USER', - 'ADHERENT_SPIP_PASS' + //$link=img_picto($langs->trans("Active"),'tick').' '; + $link = ''; + //$link.=$langs->trans("Disable"); + $link .= img_picto($langs->trans("Activated"), 'switch_on'); + $link .= ''; + // Edition des varibales globales + $constantes = array( + 'ADHERENT_SPIP_SERVEUR', + 'ADHERENT_SPIP_DB', + 'ADHERENT_SPIP_USER', + 'ADHERENT_SPIP_PASS' ); - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); print '
'; form_constantes($constantes, 2); - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print ''; + print ''; } else { - print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=$langs->trans("Activate"); - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + $link = ''; + //$link.=$langs->trans("Activate"); + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); - print dol_get_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e833bd543ed..c5a6bc79421 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -93,7 +93,7 @@ if ($action == 'warehouse') { $value = GETPOST('default_warehouse', 'alpha'); $res = dolibarr_set_const($db, "MAIN_DEFAULT_WAREHOUSE", $value, 'chaine', 0, '', $conf->entity); - if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)){ + if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { $res = dolibarr_del_const($db, "MAIN_DEFAULT_WAREHOUSE", $conf->entity); } if (!$res > 0) $error++; @@ -684,7 +684,7 @@ print ''; print ''.$langs->trans("UserDefaultWarehouse").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); + print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER); @@ -692,7 +692,7 @@ if ($conf->use_javascript_ajax) { print "\n"; print "\n"; -if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { +if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print ''; print ''.$langs->trans("UserWarehouseAutoCreate").''; print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index c248a45f9f9..779f7ab472a 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -57,15 +57,15 @@ $specimenthirdparty->initAsSpecimen(); if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -77,44 +77,44 @@ if ($action == 'updateMask') if ($action == 'specimen') // For invoices { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $facture = new FactureFournisseur($db); - $facture->initAsSpecimen(); - $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) + $facture = new FactureFournisseur($db); + $facture->initAsSpecimen(); + $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $facture); + $module = new $classname($db, $facture); - if ($module->write_file($facture, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($facture, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -126,52 +126,52 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); } } // Set default model elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; - } + if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } elseif ($action == 'unsetdoc') { - dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); + dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); } if ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') { - $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -221,79 +221,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_invoice"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.'/'.$file.'.php'; + require_once $dir.'/'.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->isEnabled()) + { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $invoice = new FactureFournisseur($db); - $invoice->initAsSpecimen(); + $invoice = new FactureFournisseur($db); + $invoice->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $invoice); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $invoice); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -318,16 +318,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''."\n"; @@ -347,94 +347,94 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_invoice/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new FactureFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new FactureFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + print ""; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - print ''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "'."\n"; - //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -466,11 +466,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra $variablename = 'SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 1999326c07e..60c2c4da56e 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -58,12 +58,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskvalue = GETPOST('maskorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -73,44 +73,44 @@ if ($action == 'updateMask') } } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -122,7 +122,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); } } @@ -144,64 +144,64 @@ elseif ($action == 'setdoc') } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } elseif ($action == 'set_SUPPLIER_ORDER_OTHER') { - $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED', 'alpha'); $doubleapproval = price2num($doubleapproval); - $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); - // TODO We add/delete permission here until permission can have a condition on a global var - include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; - $newmodule = new modFournisseur($db); + // TODO We add/delete permission here until permission can have a condition on a global var + include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $newmodule = new modFournisseur($db); - if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - // clear default rights array - $newmodule->rights = array(); - // add new right - $r = 0; - $newmodule->rights[$r][0] = 1190; - $newmodule->rights[$r][1] = $langs->trans("Permission1190"); - $newmodule->rights[$r][2] = 'w'; - $newmodule->rights[$r][3] = 0; - $newmodule->rights[$r][4] = 'commande'; - $newmodule->rights[$r][5] = 'approve2'; + if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + { + // clear default rights array + $newmodule->rights = array(); + // add new right + $r = 0; + $newmodule->rights[$r][0] = 1190; + $newmodule->rights[$r][1] = $langs->trans("Permission1190"); + $newmodule->rights[$r][2] = 'w'; + $newmodule->rights[$r][3] = 0; + $newmodule->rights[$r][4] = 'commande'; + $newmodule->rights[$r][5] = 'approve2'; - // Insert - $newmodule->insert_permissions(1); - } else { - // Remove all rights with Permission1190 - $newmodule->delete_permissions(); + // Insert + $newmodule->insert_permissions(1); + } else { + // Remove all rights with Permission1190 + $newmodule->delete_permissions(); - // Add all right without Permission1190 - $newmodule->insert_permissions(1); - } + // Add all right without Permission1190 + $newmodule->insert_permissions(1); + } } // Activate ask for payment bank elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -244,79 +244,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_order/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.$file.'.php'; + require_once $dir.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->isEnabled()) + { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $commande); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $commande); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -339,16 +339,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''."\n"; @@ -368,86 +368,86 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_order/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new CommandeFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new CommandeFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - print ''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -521,11 +521,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans $variablename = 'SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index c0c04eb9430..217b7d7c44a 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -48,21 +48,21 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); - $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); + if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setmod') { - dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } // Activate a model @@ -74,7 +74,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); + if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); } } @@ -96,54 +96,54 @@ elseif ($action == 'setdoc') } } elseif ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $paiementFourn = new PaiementFourn($db); - $paiementFourn->initAsSpecimen(); + $paiementFourn = new PaiementFourn($db); + $paiementFourn->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($paiementFourn, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($paiementFourn, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } elseif ($action == 'setparams') { - $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) - { + { setEventMessages($langs->trans("Error"), null, 'errors'); } if (!$error) - { + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -184,16 +184,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''; @@ -209,104 +209,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_supplier_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_supplier_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) - { - print ''; + print ''; - // Show example of numbering module - print ''."\n"; + // Show example of numbering module + print ''."\n"; - print ''; + print ''; - $payment = new PaiementFourn($db); - $payment->initAsSpecimen(); + $payment = new PaiementFourn($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print '
'; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + print '
'; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; - if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; + if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print '
'; @@ -335,91 +335,91 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_payment/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new PaiementFourn($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new PaiementFourn($db)); - print "\n"; - print ""; - print (empty($module->name) ? $name : $module->name); - print "\n"; - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "\n"; + print ""; + print (empty($module->name) ? $name : $module->name); + print "\n"; + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print ""; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + print ""; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 3e0708660d3..38a6d9e3ff5 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -77,7 +77,7 @@ if ($action == 'specimen') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -139,16 +139,16 @@ if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT') if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Activate a model @@ -160,11 +160,11 @@ if ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); + if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value; } @@ -248,13 +248,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->SUPPLIER_PROPOSAL_ADDON == "$file") @@ -274,16 +274,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $supplier_proposal); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -342,82 +342,82 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/supplier_proposal".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/supplier_proposal".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ""; + if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); @@ -427,28 +427,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -482,11 +482,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $la $variablename = 'SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; @@ -508,23 +508,23 @@ print ''; if ($conf->banque->enabled) { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); - } else { - if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) - { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } else { - print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; - } - } - print ''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; + if (!empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); + } else { + if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) + { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; + } + } + print ''; } else { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; } print ''; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index d84779c7477..ca12e4dfaa4 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 7017bebf61f..97cf92883f9 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -85,9 +85,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -100,9 +100,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -112,10 +112,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 60de87d2d2e..6d84b4a0e2d 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -109,8 +109,8 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity - dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); // Check configuration foreach ($activeModules as $modulename) { @@ -213,7 +213,7 @@ foreach ($syslogModules as $moduleName) print ' '; print $module->getName(); if ($moduleName == 'mod_syslog_syslog') { - if (! $module->isActive()) { + if (!$module->isActive()) { $langs->load("errors"); print $form->textwithpicto('', $langs->trans("ErrorPHPNeedModule", 'SysLog')); } @@ -226,22 +226,22 @@ foreach ($syslogModules as $moduleName) { foreach ($setuparray as $option) { - $tmpoption = $option['constant']; - if (!empty($tmpoption)) - { - if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; - elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; - } else $value = (isset($option['default']) ? $option['default'] : ''); + $tmpoption = $option['constant']; + if (!empty($tmpoption)) + { + if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; + elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; + } else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; if (!empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value)) { - $filelogparam = ' ('; - $filelogparam .= $langs->trans('Download'); - $filelogparam .= $filelog.')'; - print $filelogparam; + $filelogparam = ' ('; + $filelogparam .= $langs->trans('Download'); + $filelogparam .= $filelog.')'; + print $filelogparam; } } } diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index bbac6bdfe0c..460e568501b 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -188,25 +188,25 @@ print '
'; $showpromotemessage = 1; if ($showpromotemessage) { - $tmp = versiondolibarrarray(); - if (is_numeric($tmp[2])) // Not alpha, beta or rc - { - print '
'; - print '
'; + $tmp = versiondolibarrarray(); + if (is_numeric($tmp[2])) // Not alpha, beta or rc + { + print '
'; + print '
'; - if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) - { - print $langs->trans("TitleExampleForMajorRelease").':
'; - print ''; - } else { - print $langs->trans("TitleExampleForMaintenanceRelease").':
'; - print ''; - } - } + if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) + { + print $langs->trans("TitleExampleForMajorRelease").':
'; + print ''; + } else { + print $langs->trans("TitleExampleForMaintenanceRelease").':
'; + print ''; + } + } } // End of page diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 683fc3c4f3a..00020845bde 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -119,7 +119,7 @@ if (!$base) print ''.$obj->Name.''; print ''.$obj->Engine.''; if (isset($obj->Engine) && $obj->Engine == "MyISAM") { - print ''.$langs->trans("Convert").' InnoDb'; + print ''.$langs->trans("Convert").' InnoDb'; } else { print ' '; } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 6b08fc4fe8f..8681efa08ef 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -77,7 +77,7 @@ if (!count($listofvars) && !count($listofstatus)) foreach ($arraylist as $listname) { print '
'; - print '
'; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 41c8dcbd198..24a3f2ca55f 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -48,9 +48,9 @@ $version = '0.0'; if ($action == 'getlastversion') { - $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); - //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content']); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); + //var_dump($result['content']); + $sfurl = simplexml_load_string($result['content']); } @@ -74,43 +74,43 @@ print ''; + } + $out .= '
'.$langs->trans("Parameters").'
'.$langs->trans("CurrentVersion").' ('.$langs->tr // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } if (function_exists('curl_init')) { - $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - print '     -     '; - if ($action == 'getlastversion') - { - if ($sfurl) - { - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { - $title = $sfurl->channel[0]->item[$i]->title; - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) - { - $newversion = $reg[1]; - $newversionarray = explode('.', $newversion); - $versionarray = explode('.', $version); - //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; - } - $i++; - } + $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; + print '     -     '; + if ($action == 'getlastversion') + { + if ($sfurl) + { + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + { + $title = $sfurl->channel[0]->item[$i]->title; + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) + { + $newversion = $reg[1]; + $newversionarray = explode('.', $newversion); + $versionarray = explode('.', $version); + //var_dump($newversionarray);var_dump($versionarray); + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; + } + $i++; + } - // Show version - print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; - } - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; - } + // Show version + print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; + } + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; + } } // Now show link to the changelog @@ -168,7 +168,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S { $shmoparray = dol_listshmop(); - print '
'; + print '
'; print ''; print ''; print ''; @@ -280,8 +280,8 @@ $configfileparameters = array( 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), '?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)', 'dolibarr_main_data_root' => $langs->trans("DataRootServer"), - 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), - 'separator1' => '', + 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), + 'separator1' => '', 'dolibarr_main_db_host' => $langs->trans("DatabaseServer"), 'dolibarr_main_db_port' => $langs->trans("DatabasePort"), 'dolibarr_main_db_name' => $langs->trans("DatabaseName"), @@ -293,7 +293,7 @@ $configfileparameters = array( '?dolibarr_main_db_prefix' => $langs->trans("Prefix"), 'separator2' => '', 'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"), - '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), + '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), 'separator'=> '', '?dolibarr_main_auth_ldap_login_attribute' => 'dolibarr_main_auth_ldap_login_attribute', '?dolibarr_main_auth_ldap_host' => 'dolibarr_main_auth_ldap_host', @@ -349,8 +349,8 @@ foreach ($configfileparameters as $key => $value) if (preg_match('/^\?/', $key) && empty(${$newkey})) { - if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) - continue; // We discard parameters starting with ? + if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) + continue; // We discard parameters starting with ? } if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue; @@ -387,14 +387,14 @@ foreach ($configfileparameters as $key => $value) ++$i; } } elseif ($newkey == 'dolibarr_main_instance_unique_id') { - //print $conf->file->instance_unique_id; - global $dolibarr_main_cookie_cryptkey; - $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey - print $valuetoshow; - if (empty($valuetoshow)) { - print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); - } - print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; + //print $conf->file->instance_unique_id; + global $dolibarr_main_cookie_cryptkey; + $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + print $valuetoshow; + if (empty($valuetoshow)) { + print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); + } + print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; } elseif ($newkey == 'dolibarr_main_prod') { print ${$newkey}; @@ -410,7 +410,7 @@ foreach ($configfileparameters as $key => $value) print img_warning($langs->trans('SwitchThisForABetterSecurity', 0)); } } else { - print ${$newkey}; + print ${$newkey}; } if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; print ""; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index c8878b6b69f..a94a78a9794 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $langs->load("admin"); if (!$user->admin) - accessforbidden(); + accessforbidden(); $error = 0; @@ -57,13 +57,13 @@ print ''."\n"; print '
'.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").'
'.$langs->trans("VersionLastUpgrade") print '
'.$langs->trans("VersionProgram").''.DOL_VERSION; // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } print '
'; @@ -96,24 +96,24 @@ print $langs->trans("MakeIntegrityAnalysisFrom").':
'; print ''."\n"; if (dol_is_file($xmlfile)) { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print '
'; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print '
'; } else { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; - print '
'; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; + print '
'; } print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '; - print '
'; + print ' '.$langs->trans("RemoteSignature").' = '; + print '
'; } else { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; - if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; - print '
'; + print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; + if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; + print '
'; } print '
'; print ''; @@ -122,275 +122,275 @@ print '
'; if (GETPOST('target') == 'local') { - if (dol_is_file($xmlfile)) - { - // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before - if (preg_match('/\.zip$/i', $xmlfile)) { - dol_mkdir($conf->admin->dir_temp); - $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); - $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); - if (empty($result['error'])) { - $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); - } else { - print $langs->trans('FailedToUncompressFile').': '.$xmlfile; - $error++; - } - } - $xml = simplexml_load_file($xmlfile); - } else { - print $langs->trans('XmlNotFound').': '.$xmlfile; - $error++; - } + if (dol_is_file($xmlfile)) + { + // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before + if (preg_match('/\.zip$/i', $xmlfile)) { + dol_mkdir($conf->admin->dir_temp); + $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); + $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); + if (empty($result['error'])) { + $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); + } else { + print $langs->trans('FailedToUncompressFile').': '.$xmlfile; + $error++; + } + } + $xml = simplexml_load_file($xmlfile); + } else { + print $langs->trans('XmlNotFound').': '.$xmlfile; + $error++; + } } if (GETPOST('target') == 'remote') { - $xmlarray = getURLContent($xmlremote); + $xmlarray = getURLContent($xmlremote); - // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') - { - $xmlfile = $xmlarray['content']; - //print "xmlfilestart".$xmlfile."xmlfileend"; - $xml = simplexml_load_string($xmlfile); - } else { - $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; - setEventMessages($errormsg, null, 'errors'); - $error++; - } + // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') + { + $xmlfile = $xmlarray['content']; + //print "xmlfilestart".$xmlfile."xmlfileend"; + $xml = simplexml_load_string($xmlfile); + } else { + $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + setEventMessages($errormsg, null, 'errors'); + $error++; + } } if (!$error && $xml) { - $checksumconcat = array(); - $file_list = array(); - $out = ''; + $checksumconcat = array(); + $file_list = array(); + $out = ''; - // Forced constants - if (is_object($xml->dolibarr_constants[0])) - { - $out .= load_fiche_titre($langs->trans("ForcedConstants")); + // Forced constants + if (is_object($xml->dolibarr_constants[0])) + { + $out .= load_fiche_titre($langs->trans("ForcedConstants")); $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; + $out .= '
#'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; - $i = 0; - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement - { - $constname = $constant['name']; - $constvalue = (string) $constant; - $constvalue = (empty($constvalue) ? '0' : $constvalue); - // Value found - $value = ''; - if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; - $valueforchecksum = (empty($value) ? '0' : $value); + $i = 0; + foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement + { + $constname = $constant['name']; + $constvalue = (string) $constant; + $constvalue = (empty($constvalue) ? '0' : $constvalue); + // Value found + $value = ''; + if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + $valueforchecksum = (empty($value) ? '0' : $value); - $checksumconcat[] = $valueforchecksum; + $checksumconcat[] = $valueforchecksum; - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } - if ($i == 0) - { - $out .= ''; - } - $out .= '
#'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
'.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
'.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
'.$langs->trans("None").'
'; - $out .= '
'; + if ($i == 0) + { + $out .= '
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; - } + $out .= '
'; + } - // Scan htdocs - if (is_object($xml->dolibarr_htdocs_dir[0])) - { - //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; - $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); + // Scan htdocs + if (is_object($xml->dolibarr_htdocs_dir[0])) + { + //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; + $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); - // Defined qualified files (must be same than into generate_filelist_xml.php) - $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; - $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs - $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); + // Defined qualified files (must be same than into generate_filelist_xml.php) + $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); - // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list - // Complete with list of new files - foreach ($scanfiles as $keyfile => $valfile) - { - $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (!in_array($tmprelativefilename, $file_list['insignature'])) - { - $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); - } - } + // Fill file_list with files in signature, new files, modified files + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + // Complete with list of new files + foreach ($scanfiles as $keyfile => $valfile) + { + $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); + if (!in_array($tmprelativefilename, $file_list['insignature'])) + { + $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + } + } - // Files missings - $out .= load_fiche_titre($langs->trans("FilesMissing")); + // Files missings + $out .= load_fiche_titre($langs->trans("FilesMissing")); $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); - if (is_array($tmpfilelist) && count($tmpfilelist)) - { - $i = 0; - foreach ($tmpfilelist as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
'.$i.''.dol_escape_htmltag($file['filename']).''; - if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); + if (is_array($tmpfilelist) && count($tmpfilelist)) + { + $i = 0; + foreach ($tmpfilelist as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
'.$i.''.dol_escape_htmltag($file['filename']).''; + if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; + $out .= '
'; - // Files modified - $out .= load_fiche_titre($langs->trans("FilesModified")); + // Files modified + $out .= load_fiche_titre($langs->trans("FilesModified")); - $totalsize = 0; + $totalsize = 0; $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); - if (is_array($tmpfilelist2) && count($tmpfilelist2)) - { - $i = 0; - foreach ($tmpfilelist2 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; - if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); + if (is_array($tmpfilelist2) && count($tmpfilelist2)) + { + $i = 0; + foreach ($tmpfilelist2 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; + if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; + $out .= '
'; - // Files added - $out .= load_fiche_titre($langs->trans("FilesAdded")); + // Files added + $out .= load_fiche_titre($langs->trans("FilesAdded")); - $totalsize = 0; + $totalsize = 0; $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); - if (is_array($tmpfilelist3) && count($tmpfilelist3)) - { - $i = 0; - foreach ($tmpfilelist3 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']); - if (!preg_match('/^win/i', PHP_OS)) { - $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] - $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); - } - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); + if (is_array($tmpfilelist3) && count($tmpfilelist3)) + { + $i = 0; + foreach ($tmpfilelist3 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']); + if (!preg_match('/^win/i', PHP_OS)) { + $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); + } + $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; + $out .= '
'; - // Show warning - if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) - { - setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); - } - } else { - print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; - $error++; - } + // Show warning + if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) + { + setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); + } + } else { + print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; + $error++; + } - // Scan scripts - /* + // Scan scripts + /* if (is_object($xml->dolibarr_script_dir[0])) { $file_list = array(); @@ -398,44 +398,44 @@ if (!$error && $xml) }*/ - asort($checksumconcat); // Sort list of checksum - //var_dump($checksumconcat); - $checksumget = md5(join(',', $checksumconcat)); - $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); + asort($checksumconcat); // Sort list of checksum + //var_dump($checksumconcat); + $checksumget = md5(join(',', $checksumconcat)); + $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); - /*var_dump(count($file_list['added'])); + /*var_dump(count($file_list['added'])); var_dump($checksumget); var_dump($checksumtoget); var_dump($checksumget == $checksumtoget);*/ - $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); - if ($checksumget == $checksumtoget) - { - if (count($file_list['added'])) - { - $resultcode = 'warning'; - $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; - $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; - } else { - $resultcode = 'ok'; - $resultcomment = 'Success'; - $outcurrentchecksum = ''.$checksumget.''; - } - } else { - $resultcode = 'error'; - $resultcomment = 'Error'; - $outcurrentchecksum = ''.$checksumget.''; - } + $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); + if ($checksumget == $checksumtoget) + { + if (count($file_list['added'])) + { + $resultcode = 'warning'; + $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; + $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; + } else { + $resultcode = 'ok'; + $resultcomment = 'Success'; + $outcurrentchecksum = ''.$checksumget.''; + } + } else { + $resultcode = 'error'; + $resultcomment = 'Error'; + $outcurrentchecksum = ''.$checksumget.''; + } - print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; - print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
'; - print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; + print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; + print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
'; + print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; - print '
'; - print '
'; + print '
'; + print '
'; - // Output detail - print $out; + // Output detail + print $out; } // End of page diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 06003068bb2..2bbe919c72e 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -94,10 +94,10 @@ if ($db->type == 'pgsql') { // Check option standard_conforming_strings is on $paramarray = $db->getServerParametersValues('standard_conforming_strings'); - // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) - // { - // $langs->load("errors"); - // } + // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) + // { + // $langs->load("errors"); + // } } print '
'; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 28dcb6641ef..8347a9a6e4c 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -270,13 +270,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index d9901818c92..80c4556c35a 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -87,7 +87,7 @@ $test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
'; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 9f1766a5d22..11d0dbc49cf 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -275,7 +275,7 @@ function getActivatedExtensions() // For compatibility with LF (Line Feed) if (empty($configLines) || count($configLines) < 2) { - $configLines = explode("\n", $content); + $configLines = explode("\n", $content); } $extensions = array(); @@ -428,5 +428,5 @@ function getResultColumn($name, array $activated, array $loaded, array $function $html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name); $html .= ""; - return $html; + return $html; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 05cf9dd1b8e..cb708090386 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -116,7 +116,7 @@ $test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
'; print '
'; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 50ff514c6a7..121ded4f578 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -50,62 +50,62 @@ $error = 0; if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { - if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); - else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); + if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); } if ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); - if (!empty($topic_interface)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + if (!empty($topic_interface)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); - if (!empty($text_home)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); + if (!empty($text_home)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); - if (!empty($text_help)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($url_interface)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($url_interface)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } $param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity); @@ -115,38 +115,38 @@ if ($action == 'setvar') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } - $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); if (!$res > 0) { - $error++; + $error++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - } + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } } @@ -181,15 +181,15 @@ print dol_get_fiche_end(); $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - // Button off, click to enable - $enabledisablehtml .= ''; - $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml .= ''; + // Button off, click to enable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { - // Button on, click to disable - $enabledisablehtml .= ''; - $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml .= ''; + // Button on, click to disable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print $enabledisablehtml; print ''; @@ -198,37 +198,37 @@ print '

'; if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - if (empty($conf->use_javascript_ajax)) { - print '
'; - print ''; - print ''; - } + if (empty($conf->use_javascript_ajax)) { + print ''; + print ''; + print ''; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print '
'.$langs->trans("Parameters").''; - print ''; - print '
'; + print ''; + print ''; + print ''; + print ''; - // Check if email exists - print ''; - print ''; - print ''; - print ''; + // Check if email exists + print ''; + print ''; + print ''; + print ''; - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Show logo for module print ''; @@ -246,145 +246,145 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; }*/ - // Show logo for company - print ''; - print ''; - print ''; - print ''; + // Show logo for company + print ''; + print ''; + print ''; + print ''; - // Also send to main email address - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - print ''; - print ''; - print ''; - print ''; - } + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } - if (!$conf->use_javascript_ajax) { - print ''; - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } - print '
'.$langs->trans("Parameters").''; + print ''; + print '
'.$langs->trans("TicketsEmailMustExist").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsEmailMustExist").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowModuleLogo") . '
'.$langs->trans("TicketsShowCompanyLogo").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsShowCompanyLogo").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
'; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; - if (!$conf->use_javascript_ajax) { - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + } - // Admin var of module - print load_fiche_titre($langs->trans("TicketParamMail")); + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { - print ''; - print ''; - print "\n"; - } + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } - // Interface topic - $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; - print ''; - print ''; - print ''; + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; - // Texte d'accueil homepage - $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); - print ''; - print ''; + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; - // Texte d'aide à la saisie du message - $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); - print ''; - print ''; + // Texte d'aide à la saisie du message + $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + print ''; + print ''; - // Activate email creation to user - print ''; - print ''; - print ''; - print ''; + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; - // Texte de création d'un ticket - $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); - print ''; - print ''; + // Texte de création d'un ticket + $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + print ''; + print ''; - // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print ''; - print ''; - print ''; + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; // Activate email notification when a new message is added - print ''; + print ''; print ''; // Send notification when a new message is added to a email if a user is not assigned to the ticket - print ''; + print ''; print ''; print '
'.$langs->trans("Parameter").'
'.$langs->trans("Parameter").'
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
'.$langs->trans("TicketsDisableCustomerEmail").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsDisableCustomerEmail").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
'.$langs->trans("TicketNewEmailBodyLabel").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); - print '
'.$langs->trans("TicketNewEmailBodyLabel").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketsPublicNotificationNewMessage") . '
'.$langs->trans("TicketsPublicNotificationNewMessage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED'); @@ -399,9 +399,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
' . $langs->trans("TicketPublicNotificationNewMessageDefaultEmail") . ''; + print '
'.$langs->trans("TicketPublicNotificationNewMessageDefaultEmail").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help'); @@ -410,9 +410,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
'; print '
'; - print '
'; + print '
'; - print ''; + print ''; } // End of page diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 5e990709d19..4128c0d7075 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -243,7 +243,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print ''; print ''; - print ''; + print ''; print ''; print '
'; print ''; @@ -304,7 +304,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
'; print '
'.$langs->trans('ExportStructure').''; - print ''; + print ''; print ''; print '
'; print '
'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 224bbc14b56..91fbb81b90e 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -58,8 +58,8 @@ jQuery(document).ready(function() { jQuery("#postgresql_options").show(); }); }); @@ -97,26 +97,26 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

';
trans("ImportMethod"); ?> + if (in_array($type, array('mysql', 'mysqli'))) + { + ?>
/>
+ } elseif (in_array($type, array('pgsql'))) + { + ?>
/>
+ } else { + print 'No method available with database '.$label; + } + ?>
@@ -128,8 +128,8 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

'; '; - print ''.$langs->trans('RestoreMySQL').''; + print '
'; + print ''.$langs->trans('RestoreMySQL').''; print '
'; // Parameteres execution $command = $db->getPathOfRestore(); @@ -152,46 +152,46 @@ if (in_array($type, array('mysql', 'mysqli'))) print '
'; print ajax_autoselect('restorecommand'); - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { - print '
'.$langs->trans("UnHidePassword").''; - } - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - print '
'; + if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { + print '
'.$langs->trans("UnHidePassword").''; + } + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print ''; } elseif (in_array($type, array('pgsql'))) { - print '
'; - print 'Restore PostgreSQL'; - print '
'; - // Parameteres execution - $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + print '
'; + print 'Restore PostgreSQL'; + print '
'; + // Parameteres execution + $command = $db->getPathOfRestore(); + if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command - $param = " -d ".$dolibarr_main_db_name; - $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; - $param .= " -U ".$dolibarr_main_db_user; - $paramcrypted = $param; - $paramclear = $param; - /*if (! empty($dolibarr_main_db_pass)) + $param = " -d ".$dolibarr_main_db_name; + $param .= " -h ".$dolibarr_main_db_host; + if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; + $param .= " -U ".$dolibarr_main_db_user; + $paramcrypted = $param; + $paramclear = $param; + /*if (! empty($dolibarr_main_db_pass)) { $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); $paramclear.=" -p".$dolibarr_main_db_pass; }*/ - $paramcrypted .= " -W"; - $paramclear .= " -W"; - // With psql: - $paramcrypted .= " -f"; - $paramclear .= " -f"; + $paramcrypted .= " -W"; + $paramclear .= " -W"; + // With psql: + $paramcrypted .= " -f"; + $paramclear .= " -f"; - echo $langs->trans("ImportPostgreSqlDesc"); - print '
'; - print '
'; - print ajax_autoselect('restorecommand'); - //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - print '
'; + echo $langs->trans("ImportPostgreSqlDesc"); + print '
'; + print '
'; + print ajax_autoselect('restorecommand'); + //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print '
'; } print '
'; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 7ab26f6f6e0..0c3679c62fa 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -49,9 +49,9 @@ if (!$user->admin) accessforbidden(); if ($file && !$what) { - //print DOL_URL_ROOT.'/dolibarr_export.php'; + //print DOL_URL_ROOT.'/dolibarr_export.php'; header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); - exit; + exit; } $errormsg = ''; @@ -83,16 +83,16 @@ $_SESSION["commandbackupresult"] = ''; $ExecTimeLimit = 600; if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -122,51 +122,51 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - if (!empty($dolibarr_main_restrict_os_commands)) - { - $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump = basename($cmddump); - if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { - $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); - } - } + if (!empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump = basename($cmddump); + if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); + } + } - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } } // MYSQL NO BIN if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; } // POSTGRESQL if ($what == 'postgresql') { - $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - /* Not required, the command is output on screen but not ran for pgsql + /* Not required, the command is output on screen but not ran for pgsql if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); @@ -178,20 +178,20 @@ if ($what == 'postgresql') } } */ - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } - $what = ''; // Clear to show message to run command + $what = ''; // Clear to show message to run command } @@ -200,20 +200,20 @@ if ($errormsg) setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); $resultstring = ''; - $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; + $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } else { if ($what) { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); - $resultstring = '
'; - $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; - $resultstring .= $langs->trans("YouCanDownloadBackupFile"); - $resultstring .= '
'; + $resultstring = '
'; + $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; + $resultstring .= $langs->trans("YouCanDownloadBackupFile"); + $resultstring .= '
'; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } /*else { diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 28eaa2d9d54..590ff276831 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -59,8 +59,8 @@ $errormsg = ''; if ($action == 'delete') { - $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); - $filepath = $conf->admin->dir_output.'/'.$filerelative; + $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); + $filepath = $conf->admin->dir_output.'/'.$filerelative; $ret = dol_delete_file($filepath, 1); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); @@ -76,16 +76,16 @@ if ($action == 'delete') $ExecTimeLimit = 1800; // 30mn if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -113,54 +113,54 @@ $utils = new Utils($db); if ($compression == 'zip') { $file .= '.zip'; - $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); - if ($ret < 0) - { - if ($ret == -2) { - $langs->load("errors"); - $errormsg = $langs->trans("ErrNoZipEngine"); - } else { - $langs->load("errors"); - $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); - } - } + $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); + if ($ret < 0) + { + if ($ret == -2) { + $langs->load("errors"); + $errormsg = $langs->trans("ErrNoZipEngine"); + } else { + $langs->load("errors"); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); + } + } } elseif (in_array($compression, array('gz', 'bz'))) { $userlogin = ($user->login ? $user->login : 'unknown'); $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method - $file .= '.tar'; - // We also exclude '/temp/' dir and 'documents/admin/documents' - $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); + $file .= '.tar'; + // We also exclude '/temp/' dir and 'documents/admin/documents' + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $langs->load("errors"); - dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); - $errormsg = 'Error tar generation return '.$retval; - } else { - if ($compression == 'gz') - { - $cmd = "gzip -f ".$outputdir."/".$file; - } - if ($compression == 'bz') - { - $cmd = "bzip2 -f ".$outputdir."/".$file; - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $langs->load("errors"); + dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); + $errormsg = 'Error tar generation return '.$retval; + } else { + if ($compression == 'gz') + { + $cmd = "gzip -f ".$outputdir."/".$file; + } + if ($compression == 'bz') + { + $cmd = "bzip2 -f ".$outputdir."/".$file; + } - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $errormsg = 'Error '.$compression.' generation return '.$retval; - unlink($outputdir."/".$file); - } - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $errormsg = 'Error '.$compression.' generation return '.$retval; + unlink($outputdir."/".$file); + } + } } if ($errormsg) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 82111e0716d..00c4bdc36dd 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -76,11 +76,11 @@ $nowarray = dol_getdate($now); if (empty($date_start)) // We define date_start and date_end { - $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); + $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); } if (empty($date_end)) { - $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); + $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); } // Set $date_startmonth... $tmp = dol_getdate($date_start); @@ -104,14 +104,14 @@ $now = dol_now(); // Purge search criteria 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 { - $date_start = -1; - $date_end = -1; - $search_code = ''; - $search_ip = ''; - $search_user = ''; - $search_desc = ''; - $search_ua = ''; - $search_prefix_session = ''; + $date_start = -1; + $date_end = -1; + $search_code = ''; + $search_ip = ''; + $search_user = ''; + $search_desc = ''; + $search_ua = ''; + $search_prefix_session = ''; } // Purge audit events @@ -144,7 +144,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $result = $securityevent->create($user); if ($result > 0) { - $db->commit(); + $db->commit(); dol_syslog($text, LOG_WARNING); } else { $error++; @@ -219,16 +219,16 @@ if ($result) if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); - $langs->load('withdrawals'); - if ($num) - { - $center = ''.$langs->trans("Purge").''; - } + $langs->load('withdrawals'); + if ($num) + { + $center = ''.$langs->trans("Purge").''; + } print '
'; print ''; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); + print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); if ($action == 'purge') { diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index aedc41e0b23..d8e0a0383a2 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -37,8 +37,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -192,7 +192,7 @@ if ($savehandler == 'files') { if (count($listofsessions)) { - print ''.$langs->trans("PurgeSessions").''; + print ''.$langs->trans("PurgeSessions").''; } } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index c41b43b3b48..d450b5aa888 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -48,16 +48,16 @@ if (!empty($conf->syslog->enabled)) */ if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) { - // Increase limit of time. Works only if we are not in safe mode - $ExecTimeLimit = 600; - if (!empty($ExecTimeLimit)) - { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); - } + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit = 600; + if (!empty($ExecTimeLimit)) + { + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); @@ -97,9 +97,9 @@ if (!empty($conf->syslog->enabled)) $filelogparam = $filelog; if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam = ''.$filelog.''; + $filelogparam = ''.$filelog.''; } print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); print '

'; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index a22e585f972..a96ea4e16aa 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -60,7 +60,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -84,24 +84,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } //Set hide closed customer into combox or select elseif ($action == 'sethideinactiveuser') @@ -225,104 +225,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/user".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/user".$valdir); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->USER_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->USER_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index e73e01ccbdf..dd12584b276 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -57,7 +57,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -81,24 +81,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } /* * View @@ -157,104 +157,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->USERGROUP_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->USERGROUP_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a8bcbcf8172..5ee707a8002 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,7 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { +$workflowcodes = array_filter($workflowcodes, function($var) { return $var['enabled']; }); /* diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 22263b8b9ba..835a5485544 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -43,10 +43,10 @@ $langs->load("admin"); // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

'; - print $langs->trans("ToActivateModule"); - exit; + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

'; + print $langs->trans("ToActivateModule"); + exit; } @@ -61,45 +61,45 @@ $listofapis = array(); $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { - /* + /* * Search available module */ - //dol_syslog("Scan directory ".$dir." for API modules"); + //dol_syslog("Scan directory ".$dir." for API modules"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) - { - $modulename = $reg[1]; + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) + { + $modulename = $reg[1]; - // Defined if module is enabled - $enabled = true; - $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); - //if ($part == 'propale') $part='propal'; - if ($module == 'societe') { + // Defined if module is enabled + $enabled = true; + $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); + //if ($part == 'propale') $part='propal'; + if ($module == 'societe') { $obj = 'thirdparty'; } - if ($module == 'categorie') { - $part = 'categories'; + if ($module == 'categorie') { + $part = 'categories'; $obj = 'category'; } - if ($module == 'facture') { - $part = 'compta/facture'; + if ($module == 'facture') { + $part = 'compta/facture'; $obj = 'facture'; } - if ($module == 'ficheinter') { - $obj = 'fichinter'; - $part = 'fichinter'; - $module = 'fichinter'; - } + if ($module == 'ficheinter') { + $obj = 'fichinter'; + $part = 'fichinter'; + $module = 'fichinter'; + } - if (empty($conf->$module->enabled)) $enabled = false; + if (empty($conf->$module->enabled)) $enabled = false; - if ($enabled) { - /* + if ($enabled) { + /* * If exists, load the API class for enable module * * Search files named api_.class.php into /htdocs//class directory @@ -107,25 +107,25 @@ foreach ($modulesdir as $dir) * @todo : take care of externals module! * @todo : use getElementProperties() function ? */ - $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; + $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) - { - $classname = ucwords($reg[1]); - require_once $dir_part.$file_searched; - if (class_exists($classname)) - { - dol_syslog("Found API classname=".$classname." into ".$dir); - $listofapis[] = $classname; - } - } + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) + { + $classname = ucwords($reg[1]); + require_once $dir_part.$file_searched; + if (class_exists($classname)) + { + dol_syslog("Found API classname=".$classname." into ".$dir); + $listofapis[] = $classname; + } + } - /* + /* if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg)) { $classname=$reg[1]; @@ -150,12 +150,12 @@ foreach ($modulesdir as $dir) // //$listofapis[]=array('classname'=>$classname, 'fullpath'=>$file_searched); // } }*/ - } - } - } - } - } - } + } + } + } + } + } + } } //var_dump($listofapis); @@ -188,28 +188,28 @@ $oldclass = ''; print $langs->trans("ListOfAvailableAPIs").':
'; foreach ($listofapis['v1'] as $key => $val) { - if ($key == 'login') continue; - if ($key == 'index') continue; + if ($key == 'login') continue; + if ($key == 'index') continue; - if ($key) - { - foreach ($val as $method => $val2) - { - $newclass = $val2['className']; + if ($key) + { + foreach ($val as $method => $val2) + { + $newclass = $val2['className']; - if (preg_match('/restler/i', $newclass)) continue; + if (preg_match('/restler/i', $newclass)) continue; - if ($oldclass != $newclass) - { - print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; - $oldclass = $newclass; - } - //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; - $url = $urlwithroot.'/api/index.php/'.$key; - $url .= '?api_key=token'; - print img_picto('', 'globe').' '.$method.' '.$url."
\n"; - } - } + if ($oldclass != $newclass) + { + print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; + $oldclass = $newclass; + } + //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; + $url = $urlwithroot.'/api/index.php/'.$key; + $url .= '?api_key=token'; + print img_picto('', 'globe').' '.$method.' '.$url."
\n"; + } + } } print '
'; diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index a7eab61211d..18cbff2ca61 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -64,11 +64,11 @@ if ($action == 'setproductionmode') } } - if (!$error) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } + if (!$error) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } else { dol_print_error($db); } @@ -112,13 +112,13 @@ print ''.$langs->trans("ApiProductionMode").''; $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?false:true); if ($production_mode) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } print ' '; print ''; @@ -157,10 +157,10 @@ print '
'; print ''.$langs->trans("ApiExporerIs").':
'; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { - $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print img_picto('', 'globe').' '.$url."
\n"; + $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; + print img_picto('', 'globe').' '.$url."
\n"; } else { - print $langs->trans("NotAvailableWithThisDistribution"); + print $langs->trans("NotAvailableWithThisDistribution"); } llxFooter(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 895a0e2dc60..5834324fa2b 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -30,54 +30,54 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class DolibarrApi { - /** - * @var DoliDb $db Database object - */ - protected $db; + /** + * @var DoliDb $db Database object + */ + protected $db; - /** - * @var Restler $r Restler object - */ - public $r; + /** + * @var Restler $r Restler object + */ + public $r; - /** - * Constructor - * - * @param DoliDb $db Database handler - * @param string $cachedir Cache dir - * @param boolean $refreshCache Update cache - */ - public function __construct($db, $cachedir = '', $refreshCache = false) - { - global $conf, $dolibarr_main_url_root; + /** + * Constructor + * + * @param DoliDb $db Database handler + * @param string $cachedir Cache dir + * @param boolean $refreshCache Update cache + */ + public function __construct($db, $cachedir = '', $refreshCache = false) + { + global $conf, $dolibarr_main_url_root; - if (empty($cachedir)) $cachedir = $conf->api->dir_temp; - Defaults::$cacheDirectory = $cachedir; + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; + Defaults::$cacheDirectory = $cachedir; - $this->db = $db; - $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); - $this->r = new Restler($production_mode, $refreshCache); + $this->db = $db; + $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); + $this->r = new Restler($production_mode, $refreshCache); - $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 + $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 - $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); - $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url + $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); + $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url - $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); - $this->r->setAPIVersion(1); - //$this->r->setSupportedFormats('json'); - //$this->r->setSupportedFormats('jsonFormat'); - } + $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); + $this->r->setAPIVersion(1); + //$this->r->setSupportedFormats('json'); + //$this->r->setSupportedFormats('jsonFormat'); + } - /** - * Executed method when API is called without parameter - * - * Display a short message an return a http code 200 - * - * @return array - */ - /* Disabled, most APIs does not share same signature for method index + /** + * Executed method when API is called without parameter + * + * Display a short message an return a http code 200 + * + * @return array + */ + /* Disabled, most APIs does not share same signature for method index function index() { return array( @@ -88,148 +88,148 @@ class DolibarrApi ); }*/ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Object $object Object to clean - * @return Object Object with cleaned properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - // Remove $db object property for object - unset($object->db); - unset($object->isextrafieldmanaged); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + // Remove $db object property for object + unset($object->db); + unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); unset($object->table_rowid); - // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses - unset($object->linkedObjects); + // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses + unset($object->linkedObjects); - unset($object->fields); - unset($object->oldline); + unset($object->fields); + unset($object->oldline); - unset($object->error); - unset($object->errors); + unset($object->error); + unset($object->errors); - unset($object->ref_previous); - unset($object->ref_next); - unset($object->ref_int); + unset($object->ref_previous); + unset($object->ref_next); + unset($object->ref_int); - unset($object->projet); // Should be fk_project - unset($object->project); // Should be fk_project - unset($object->author); // Should be fk_user_author - unset($object->timespent_old_duration); - unset($object->timespent_id); - unset($object->timespent_duration); - unset($object->timespent_date); - unset($object->timespent_datehour); - unset($object->timespent_withhour); - unset($object->timespent_fk_user); - unset($object->timespent_note); - unset($object->fk_delivery_address); + unset($object->projet); // Should be fk_project + unset($object->project); // Should be fk_project + unset($object->author); // Should be fk_user_author + unset($object->timespent_old_duration); + unset($object->timespent_id); + unset($object->timespent_duration); + unset($object->timespent_date); + unset($object->timespent_datehour); + unset($object->timespent_withhour); + unset($object->timespent_fk_user); + unset($object->timespent_note); + unset($object->fk_delivery_address); - unset($object->statuts); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts_long); - unset($object->labelStatus); - unset($object->labelStatusShort); + unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts_long); + unset($object->labelStatus); + unset($object->labelStatusShort); - unset($object->stats_propale); - unset($object->stats_commande); - unset($object->stats_contrat); - unset($object->stats_facture); - unset($object->stats_commande_fournisseur); - unset($object->stats_reception); - unset($object->stats_mrptoconsume); - unset($object->stats_mrptoproduce); + unset($object->stats_propale); + unset($object->stats_commande); + unset($object->stats_contrat); + unset($object->stats_facture); + unset($object->stats_commande_fournisseur); + unset($object->stats_reception); + unset($object->stats_mrptoconsume); + unset($object->stats_mrptoproduce); - unset($object->element); - unset($object->fk_element); - unset($object->table_element); - unset($object->table_element_line); - unset($object->class_element_line); - unset($object->picto); + unset($object->element); + unset($object->fk_element); + unset($object->table_element); + unset($object->table_element_line); + unset($object->class_element_line); + unset($object->picto); - unset($object->fieldsforcombobox); + unset($object->fieldsforcombobox); - unset($object->skip_update_total); - unset($object->context); - unset($object->next_prev_filter); + unset($object->skip_update_total); + unset($object->context); + unset($object->next_prev_filter); - unset($object->region); - unset($object->region_code); + unset($object->region); + unset($object->region_code); - unset($object->libelle_statut); - unset($object->libelle_paiement); + unset($object->libelle_statut); + unset($object->libelle_paiement); - if ($object->table_element != 'ticket') { - unset($object->comments); - } + if ($object->table_element != 'ticket') { + unset($object->comments); + } - // Remove the $oldcopy property because it is not supported by the JSON - // encoder. The following error is generated when trying to serialize - // it: "Error encoding/decoding JSON: Type is not supported" - // Note: Event if this property was correctly handled by the JSON - // encoder, it should be ignored because keeping it would let the API - // have a very strange behavior: calling PUT and then GET on the same - // resource would give different results: - // PUT /objects/{id} -> returns object with oldcopy = previous version of the object - // GET /objects/{id} -> returns object with oldcopy empty - unset($object->oldcopy); + // Remove the $oldcopy property because it is not supported by the JSON + // encoder. The following error is generated when trying to serialize + // it: "Error encoding/decoding JSON: Type is not supported" + // Note: Event if this property was correctly handled by the JSON + // encoder, it should be ignored because keeping it would let the API + // have a very strange behavior: calling PUT and then GET on the same + // resource would give different results: + // PUT /objects/{id} -> returns object with oldcopy = previous version of the object + // GET /objects/{id} -> returns object with oldcopy empty + unset($object->oldcopy); - // If object has lines, remove $db property - if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { - $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) - { - $this->_cleanObjectDatas($object->lines[$i]); + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) + { + $this->_cleanObjectDatas($object->lines[$i]); - unset($object->lines[$i]->contact); - unset($object->lines[$i]->contact_id); - unset($object->lines[$i]->country); - unset($object->lines[$i]->country_id); - unset($object->lines[$i]->country_code); - unset($object->lines[$i]->mode_reglement_id); - unset($object->lines[$i]->mode_reglement_code); - unset($object->lines[$i]->mode_reglement); - unset($object->lines[$i]->cond_reglement_id); - unset($object->lines[$i]->cond_reglement_code); - unset($object->lines[$i]->cond_reglement); - unset($object->lines[$i]->fk_delivery_address); - unset($object->lines[$i]->fk_projet); - unset($object->lines[$i]->fk_project); - unset($object->lines[$i]->thirdparty); - unset($object->lines[$i]->user); - unset($object->lines[$i]->model_pdf); - unset($object->lines[$i]->modelpdf); - unset($object->lines[$i]->note_public); - unset($object->lines[$i]->note_private); - unset($object->lines[$i]->fk_incoterms); - unset($object->lines[$i]->label_incoterms); - unset($object->lines[$i]->location_incoterms); - unset($object->lines[$i]->name); - unset($object->lines[$i]->lastname); - unset($object->lines[$i]->firstname); - unset($object->lines[$i]->civility_id); - unset($object->lines[$i]->fk_multicurrency); - unset($object->lines[$i]->multicurrency_code); - unset($object->lines[$i]->shipping_method_id); - } - } + unset($object->lines[$i]->contact); + unset($object->lines[$i]->contact_id); + unset($object->lines[$i]->country); + unset($object->lines[$i]->country_id); + unset($object->lines[$i]->country_code); + unset($object->lines[$i]->mode_reglement_id); + unset($object->lines[$i]->mode_reglement_code); + unset($object->lines[$i]->mode_reglement); + unset($object->lines[$i]->cond_reglement_id); + unset($object->lines[$i]->cond_reglement_code); + unset($object->lines[$i]->cond_reglement); + unset($object->lines[$i]->fk_delivery_address); + unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); + unset($object->lines[$i]->thirdparty); + unset($object->lines[$i]->user); + unset($object->lines[$i]->model_pdf); + unset($object->lines[$i]->modelpdf); + unset($object->lines[$i]->note_public); + unset($object->lines[$i]->note_private); + unset($object->lines[$i]->fk_incoterms); + unset($object->lines[$i]->label_incoterms); + unset($object->lines[$i]->location_incoterms); + unset($object->lines[$i]->name); + unset($object->lines[$i]->lastname); + unset($object->lines[$i]->firstname); + unset($object->lines[$i]->civility_id); + unset($object->lines[$i]->fk_multicurrency); + unset($object->lines[$i]->multicurrency_code); + unset($object->lines[$i]->shipping_method_id); + } + } - if (!empty($object->thirdparty) && is_object($object->thirdparty)) - { - $this->_cleanObjectDatas($object->thirdparty); - } + if (!empty($object->thirdparty) && is_object($object->thirdparty)) + { + $this->_cleanObjectDatas($object->thirdparty); + } return $object; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Check user access to a resource * @@ -241,12 +241,12 @@ class DolibarrApi * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @return bool + * @return bool * @throws RestException */ - protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') - { - // phpcs:enable + protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + { + // phpcs:enable // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { @@ -261,9 +261,9 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return if a $sqlfilters parameter is valid * @@ -272,30 +272,30 @@ class DolibarrApi */ protected function _checkFilters($sqlfilters) { - // phpcs:enable - //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); - $tmp = $sqlfilters; - $ok = 0; - $i = 0; $nb = strlen($tmp); - $counter = 0; - while ($i < $nb) - { - if ($tmp[$i] == '(') $counter++; - if ($tmp[$i] == ')') $counter--; - if ($counter < 0) - { - $error = "Bad sqlfilters=".$sqlfilters; - dol_syslog($error, LOG_WARNING); - return false; - } - $i++; - } - return true; + // phpcs:enable + //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); + $tmp = $sqlfilters; + $ok = 0; + $i = 0; $nb = strlen($tmp); + $counter = 0; + while ($i < $nb) + { + if ($tmp[$i] == '(') $counter++; + if ($tmp[$i] == ')') $counter--; + if ($counter < 0) + { + $error = "Bad sqlfilters=".$sqlfilters; + dol_syslog($error, LOG_WARNING); + return false; + } + $i++; + } + return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Function to forge a SQL criteria * @@ -304,22 +304,22 @@ class DolibarrApi */ protected static function _forge_criteria_callback($matches) { - // phpcs:enable - global $db; + // phpcs:enable + global $db; - //dol_syslog("Convert matches ".$matches[1]); - if (empty($matches[1])) return ''; - $tmp = explode(':', $matches[1]); - if (count($tmp) < 3) return ''; + //dol_syslog("Convert matches ".$matches[1]); + if (empty($matches[1])) return ''; + $tmp = explode(':', $matches[1]); + if (count($tmp) < 3) return ''; - $tmpescaped = $tmp[2]; - $regbis = array(); - if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) - { - $tmpescaped = "'".$db->escape($regbis[1])."'"; - } else { - $tmpescaped = $db->escape($tmpescaped); - } - return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + $tmpescaped = $tmp[2]; + $regbis = array(); + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) + { + $tmpescaped = "'".$db->escape($regbis[1])."'"; + } else { + $tmpescaped = $db->escape($tmpescaped); + } + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; } } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 84f7bf303e7..6f6e1a2fb6c 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -18,7 +18,7 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { +call_user_func(function() { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; @@ -52,7 +52,7 @@ class DolibarrApiAccess implements iAuthenticate /** * @var string $role user role */ - public static $role = 'user'; + public static $role = 'user'; /** * @var User $user Loggued user @@ -69,7 +69,7 @@ class DolibarrApiAccess implements iAuthenticate $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Check access * @@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate */ public function __isAllowed() { - // phpcs:enable + // phpcs:enable global $conf, $db; $login = ''; @@ -97,17 +97,17 @@ class DolibarrApiAccess implements iAuthenticate $api_key = ''; if (isset($_GET['api_key'])) // For backward compatibility { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['DOLAPIKEY']; // With GET method + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['DOLAPIKEY']; // With GET method } if (isset($_SERVER['HTTP_DOLAPIKEY'])) // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY { - $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) } if ($api_key) @@ -149,7 +149,7 @@ class DolibarrApiAccess implements iAuthenticate if (!$login) { - throw new RestException(503, 'Error when searching login user from api key'); + throw new RestException(503, 'Error when searching login user from api key'); } $fuser = new User($this->db); $result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity) @@ -161,49 +161,49 @@ class DolibarrApiAccess implements iAuthenticate if ($fuser->socid) { static::$role = 'external'; - } + } if ($fuser->admin) { static::$role = 'admin'; - } - } else { - throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); + } + } else { + throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); } - $userClass::setCacheIdentifier(static::$role); - Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; - $requirefortest = static::$requires; - if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); - return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; + $userClass::setCacheIdentifier(static::$role); + Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; + $requirefortest = static::$requires; + if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); + return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * @return string string to be used with WWW-Authenticate header */ - public function __getWWWAuthenticateString() - { - // phpcs:enable - return ''; - } + public function __getWWWAuthenticateString() + { + // phpcs:enable + return ''; + } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ - public static function verifyAccess(array $m) - { - $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) - ? $m['class']['DolibarrApiAccess']['properties']['requires'] - : false; + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ + public static function verifyAccess(array $m) + { + $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) + ? $m['class']['DolibarrApiAccess']['properties']['requires'] + : false; - return $requires - ? static::$role == 'admin' || in_array(static::$role, (array) $requires) - : true; - } + return $requires + ? static::$role == 'admin' || in_array(static::$role, (array) $requires) + : true; + } } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index fa570caed77..5fff08b80ab 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -409,7 +409,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); } - elseif ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -419,9 +419,9 @@ class Documents extends DolibarrApi $object = new Product($this->db); $result = $object->fetch($id, $ref); - if ($result==0) { + if ($result == 0) { throw new RestException(404, 'Product not found'); - } elseif ($result<0) { + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); } @@ -515,7 +515,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @return string + * @return string * * @throws RestException 400 * @throws RestException 401 @@ -633,7 +633,7 @@ class Documents extends DolibarrApi if ($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); @@ -682,7 +682,7 @@ class Documents extends DolibarrApi if (dol_mkdir($upload_dir) < 0) // needed by products { - throw new RestException(500, 'Error while trying to create directory.'); + throw new RestException(500, 'Error while trying to create directory.'); } $destfile = $upload_dir.'/'.$original_file; @@ -735,63 +735,63 @@ class Documents extends DolibarrApi */ public function delete($modulepart, $original_file) { - global $conf, $langs; + global $conf, $langs; - if (empty($modulepart)) { - throw new RestException(400, 'bad value for parameter modulepart'); - } - if (empty($original_file)) { - throw new RestException(400, 'bad value for parameter original_file'); - } + if (empty($modulepart)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + if (empty($original_file)) { + throw new RestException(400, 'bad value for parameter original_file'); + } - //--- Finds and returns the document - $entity = $conf->entity; + //--- Finds and returns the document + $entity = $conf->entity; - // Special cases that need to use get_exdir to get real dir of object - // If future, all object should use this to define path of documents. - /* + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* $tmpreldir = ''; if ($modulepart == 'supplier_invoice') { $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); } $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ - $relativefile = $original_file; + $relativefile = $original_file; - $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; - $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); + $accessallowed = $check_access['accessallowed']; + $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { - throw new RestException(401); - } - if (!$accessallowed) { - throw new RestException(401); - } + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { + throw new RestException(401); + } + if (!$accessallowed) { + throw new RestException(401); + } - $filename = basename($original_file); - $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset + $filename = basename($original_file); + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (!file_exists($original_file_osencoded)) - { - dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); - throw new RestException(404, 'File not found'); - } + if (!file_exists($original_file_osencoded)) + { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); + throw new RestException(404, 'File not found'); + } - if (@unlink($original_file_osencoded)) { - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Document deleted' - ) - ); - } + if (@unlink($original_file_osencoded)) { + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Document deleted' + ) + ); + } - throw new RestException(401); + throw new RestException(401); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -799,9 +799,9 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - private function _validate_file($data) - { - // phpcs:enable + private function _validate_file($data) + { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 8627808a679..cb2fdd54d66 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -26,14 +26,14 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class Login { - /** - * Constructor of the class - */ - public function __construct() - { - global $db; - $this->db = $db; - } + /** + * Constructor of the class + */ + public function __construct() + { + global $db; + $this->db = $db; + } /** * Login @@ -46,21 +46,21 @@ class Login * @param string $password User password * @param string $entity Entity (when multicompany module is used). '' means 1=first company. * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) - * @return array Response status and user token - * + * @return array Response status and user token + * * @throws RestException 403 * @throws RestException 500 * * @url GET / * @url POST / */ - public function index($login, $password, $entity = '', $reset = 0) - { - global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + public function index($login, $password, $entity = '', $reset = 0) + { + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // TODO Remove the API login. The token must be generated from backoffice only. + // TODO Remove the API login. The token must be generated from backoffice only. - // Authentication mode + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'dolibarr'; // Authentication mode: forceuser @@ -108,22 +108,22 @@ class Login throw new RestException(403, 'User need write permission on itself to reset its API token'); } - // Generate token for user - $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); + // Generate token for user + $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); - // We store API token into database - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET api_key = '".$this->db->escape($token)."'"; - $sql .= " WHERE login = '".$this->db->escape($login)."'"; + // We store API token into database + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET api_key = '".$this->db->escape($token)."'"; + $sql .= " WHERE login = '".$this->db->escape($login)."'"; - dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log - $result = $this->db->query($sql); - if (!$result) - { - throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); - } + dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log + $result = $this->db->query($sql); + if (!$result) + { + throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); + } } else { - $token = $tmpuser->api_key; + $token = $tmpuser->api_key; } //return token @@ -131,9 +131,9 @@ class Login 'success' => array( 'code' => 200, 'token' => $token, - 'entity' => $tmpuser->entity, - 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') + 'entity' => $tmpuser->entity, + 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 45c69e318e0..6c80e838f0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -26,21 +26,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ class Status { - /** - * Get status (Dolibarr version) - * - * @return array - */ - public function index() - { - global $conf; + /** + * Get status (Dolibarr version) + * + * @return array + */ + public function index() + { + global $conf; - return array( - 'success' => array( - 'code' => 200, - 'dolibarr_version' => DOL_VERSION, - 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), - ), - ); - } + return array( + 'success' => array( + 'code' => 200, + 'dolibarr_version' => DOL_VERSION, + 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), + ), + ); + } } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 1ae504f523a..f605ff11d85 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -45,7 +45,7 @@ if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { +call_user_func(function() { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; @@ -69,22 +69,22 @@ if (!empty($conf->global->MAIN_NGINX_FIX)) // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

'; - print $langs->trans("ToActivateModule"); - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

'; + print $langs->trans("ToActivateModule"); + //session_destroy(); + exit(0); } // Test if explorer is not disabled if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningAPIExplorerDisabled").'.

'; - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningAPIExplorerDisabled").'.

'; + //session_destroy(); + exit(0); } @@ -114,7 +114,7 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - $refreshcache = true; + $refreshcache = true; } $api = new DolibarrApi($db, '', $refreshcache); @@ -150,104 +150,104 @@ if (!empty($conf->global->API_RESTRICT_ON_IP)) // Call Explorer file for all APIs definitions (this part is slow) if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - // Scan all API files to load them + // Scan all API files to load them - $listofapis = array(); + $listofapis = array(); - $modulesdir = dolGetModulesDirs(); - foreach ($modulesdir as $dir) - { - // Search available module - dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); + $modulesdir = dolGetModulesDirs(); + foreach ($modulesdir as $dir) + { + // Search available module + dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $regmod = array(); - if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) - { - $module = strtolower($regmod[1]); - $moduledirforclass = getModuleDirForApiClass($module); - $modulenameforenabled = $module; - if ($module == 'propale') { $modulenameforenabled = 'propal'; } - if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } - if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $regmod = array(); + if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) + { + $module = strtolower($regmod[1]); + $moduledirforclass = getModuleDirForApiClass($module); + $modulenameforenabled = $module; + if ($module == 'propale') { $modulenameforenabled = 'propal'; } + if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } + if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } - dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); + dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); - // Defined if module is enabled - $enabled = true; - if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; + // Defined if module is enabled + $enabled = true; + if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; - if ($enabled) - { - // If exists, load the API class for enable module - // Search files named api_.class.php into /htdocs//class directory - // @todo : use getElementProperties() function ? - $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); + if ($enabled) + { + // If exists, load the API class for enable module + // Search files named api_.class.php into /htdocs//class directory + // @todo : use getElementProperties() function ? + $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if ($file_searched == 'api_access.class.php') continue; + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if ($file_searched == 'api_access.class.php') continue; - $regapi = array(); - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) - { - $classname = ucwords($regapi[1]); - $classname = str_replace('_', '', $classname); - require_once $dir_part.$file_searched; - if (class_exists($classname.'Api')) - { - //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname.'Api')] = $classname.'Api'; - } elseif (class_exists($classname)) - { - //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname)] = $classname; - } else { - dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); - } - } - } - } - } - } - } - } - } + $regapi = array(); + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) + { + $classname = ucwords($regapi[1]); + $classname = str_replace('_', '', $classname); + require_once $dir_part.$file_searched; + if (class_exists($classname.'Api')) + { + //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname.'Api')] = $classname.'Api'; + } elseif (class_exists($classname)) + { + //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname)] = $classname; + } else { + dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + } + } + } + } + } + } + } + } + } - // Sort the classes before adding them to Restler. - // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. - asort($listofapis); - foreach ($listofapis as $apiname => $classname) - { - $api->r->addAPIClass($classname, $apiname); - } - //var_dump($api->r); + // Sort the classes before adding them to Restler. + // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. + asort($listofapis); + foreach ($listofapis as $apiname => $classname) + { + $api->r->addAPIClass($classname, $apiname); + } + //var_dump($api->r); } // Call one APIs or one definition of an API $regbis = array(); if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { - $moduleobject = $reg[1]; - if ($moduleobject == 'explorer') // If we call page to explore details of a service - { - $moduleobject = $regbis[2]; - } + $moduleobject = $reg[1]; + if ($moduleobject == 'explorer') // If we call page to explore details of a service + { + $moduleobject = $regbis[2]; + } - $moduleobject = strtolower($moduleobject); - $moduledirforclass = getModuleDirForApiClass($moduleobject); + $moduleobject = strtolower($moduleobject); + $moduledirforclass = getModuleDirForApiClass($moduleobject); - // Load a dedicated API file - dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); + // Load a dedicated API file + dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); - $tmpmodule = $moduleobject; + $tmpmodule = $moduleobject; if ($tmpmodule != 'api') $tmpmodule = preg_replace('/api$/i', '', $tmpmodule); $classfile = str_replace('_', '', $tmpmodule); @@ -274,7 +274,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && if ($dir_part_file) $res = include_once $dir_part_file; if (!$res) { - dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); + dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); print 'API not found (failed to include API file)'; header('HTTP/1.1 501 API not found (failed to include API file)'); //session_destroy(); diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index 25d7df8e1a7..e17d421437d 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -91,7 +91,7 @@ if ($action == 'create') print "
"; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -104,7 +104,7 @@ 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'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index db2407a9376..5af5f3d7591 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -87,7 +87,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -100,8 +100,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; @@ -164,7 +164,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -173,7 +173,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -299,7 +299,7 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * @@ -307,7 +307,7 @@ class AssetType extends CommonObject */ public function liste_array() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $assettypes = array(); @@ -424,8 +424,8 @@ class AssetType extends CommonObject * * @return void */ - public function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -440,15 +440,15 @@ class AssetType extends CommonObject $this->asset = array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - public function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index 87aaeb6d46f..7a3660e350e 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -35,8 +35,8 @@ $notfound = $langs->trans("Unknown"); // Security check if (empty($conf->clicktodial->enabled)) { - print "Error: Module Click to dial is not enabled.\n"; - exit; + print "Error: Module Click to dial is not enabled.\n"; + exit; } // Check parameters diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index ecc7c4fee6c..0a9ac82ce23 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -44,10 +44,10 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); */ function llxHeader() { - print ''."\n"; - print ''."\n"; - print 'Asterisk redirection from Dolibarr...'."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print 'Asterisk redirection from Dolibarr...'."\n"; + print ''."\n"; } /** @@ -58,7 +58,7 @@ function llxHeader() */ function llxFooter() { - print "\n".''."\n"; + print "\n".''."\n"; } require_once '../main.inc.php'; @@ -69,8 +69,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Security check if (empty($conf->clicktodial->enabled)) { - accessforbidden(); - exit; + accessforbidden(); + exit; } @@ -146,46 +146,46 @@ $number = strtolower($called); $pos = strpos($number, "local"); if (!empty($number)) { - if ($pos === false) - { - $errno = 0; - $errstr = 0; - $strCallerId = "Dolibarr call $found <".strtolower($number).">"; - $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); - if (!$oSocket) - { - print ''."\n"; - $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; - print $txt; - dol_syslog($txt, LOG_ERR); - $txt = $errstr." (".$errno.")
\n"; - print $txt; - dol_syslog($txt, LOG_ERR); - print ''."\n"; - } else { - $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; - dol_syslog($txt); - print ''."\n"; - print ''; - fputs($oSocket, "Action: login\r\n"); - fputs($oSocket, "Events: off\r\n"); - fputs($oSocket, "Username: $login\r\n"); - fputs($oSocket, "Secret: $password\r\n\r\n"); - fputs($oSocket, "Action: originate\r\n"); - fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); - fputs($oSocket, "WaitTime: $strWaitTime\r\n"); - fputs($oSocket, "CallerId: $strCallerId\r\n"); - fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); - fputs($oSocket, "Context: $strContext\r\n"); - fputs($oSocket, "Priority: $strPriority\r\n\r\n"); - fputs($oSocket, "Action: Logoff\r\n\r\n"); - sleep(2); - fclose($oSocket); - print ''."\n"; - } - } + if ($pos === false) + { + $errno = 0; + $errstr = 0; + $strCallerId = "Dolibarr call $found <".strtolower($number).">"; + $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); + if (!$oSocket) + { + print ''."\n"; + $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; + print $txt; + dol_syslog($txt, LOG_ERR); + $txt = $errstr." (".$errno.")
\n"; + print $txt; + dol_syslog($txt, LOG_ERR); + print ''."\n"; + } else { + $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; + dol_syslog($txt); + print ''."\n"; + print ''; + fputs($oSocket, "Action: login\r\n"); + fputs($oSocket, "Events: off\r\n"); + fputs($oSocket, "Username: $login\r\n"); + fputs($oSocket, "Secret: $password\r\n\r\n"); + fputs($oSocket, "Action: originate\r\n"); + fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); + fputs($oSocket, "WaitTime: $strWaitTime\r\n"); + fputs($oSocket, "CallerId: $strCallerId\r\n"); + fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); + fputs($oSocket, "Context: $strContext\r\n"); + fputs($oSocket, "Priority: $strPriority\r\n\r\n"); + fputs($oSocket, "Action: Logoff\r\n\r\n"); + sleep(2); + fclose($oSocket); + print ''."\n"; + } + } } else { - print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; + print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; } // End of page diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index dabd05bf745..8a513034a4a 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -148,7 +148,7 @@ if ($action == 'builddoc') $module = new $classname($db); if ($generator != 'tcpdfbarcode') { - // May be phpbarcode + // May be phpbarcode $template = 'standardlabel'; $is2d = false; if ($module->encodingIsSupported($encoding)) @@ -178,19 +178,19 @@ if ($action == 'builddoc') { // List of values to scan for a replacement $substitutionarray = array( - '%LOGIN%' => $user->login, - '%COMPANY%' => $mysoc->name, - '%ADDRESS%' => $mysoc->address, - '%ZIP%' => $mysoc->zip, - '%TOWN%' => $mysoc->town, - '%COUNTRY%' => $mysoc->country, - '%COUNTRY_CODE%' => $mysoc->country_code, - '%EMAIL%' => $mysoc->email, - '%YEAR%' => $year, - '%MONTH%' => $month, - '%DAY%' => $day, - '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, - '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", ); complete_substitutions_array($substitutionarray, $langs); @@ -291,8 +291,8 @@ print '
'.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; - print '
'; - print '
'; - $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); - print '   '; - print '
'; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print '
'; + print '
'; + $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); + print '   '; + print '
'; } if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; - print '
'; - print '
'; - print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); - print '   '; - print '
'; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print '
'; + print '
'; + print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); + print '   '; + print '
'; } print '
'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 0a77c6ddf3b..67c6c394815 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -559,7 +559,7 @@ jQuery(document).ready(function () { if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { - ?> + ?> '; - } else { - $html = ' + } else { + $html = ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - } + } - return $html; + return $html; } diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 30ccc6cdd75..b8d0949a1f0 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('bookmarks', 'other')); // Security check if (!$user->rights->bookmark->lire) { - restrictedArea($user, 'bookmarks'); + restrictedArea($user, 'bookmarks'); } $id = GETPOST("id", 'int'); @@ -219,11 +219,11 @@ if ($id > 0 && !preg_match('/^add/i', $action)) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); - print '
'; + print '
'; - print '
'; + print '
'; print ''; print ''; // Force warehouse (this is not a default value) print ''; @@ -174,11 +174,11 @@ if (!empty($conf->stock->enabled)) // Use Dolibarr Receipt Printer if (!empty($conf->receiptprinter->enabled)) { - print '\n"; + print '\n"; } print '
'; diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 5fab4496f6e..7f19b1bd21e 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -28,217 +28,217 @@ */ class Bookmark extends CommonObject { - /** + /** * @var string ID to identify managed object */ public $element = 'bookmark'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'bookmark'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'bookmark'; - /** + /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int */ - public $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'bookmark'; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var int ID - */ - public $id; + /** + * @var int ID + */ + public $id; - /** + /** * @var int User ID */ public $fk_user; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - public $url; + public $url; - public $target; // 0=replace, 1=new window + public $target; // 0=replace, 1=new window - public $title; + public $title; - public $position; + public $position; - public $favicon; + public $favicon; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Directs the bookmark - * - * @param int $id Bookmark Id Loader - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $conf; + /** + * Directs the bookmark + * + * @param int $id Bookmark Id Loader + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $conf; - $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; - $sql .= " title, position, favicon"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; - $sql .= " AND entity = ".$conf->entity; + $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; + $sql .= " title, position, favicon"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; + $sql .= " AND entity = ".$conf->entity; dol_syslog("Bookmark::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_user = $obj->fk_user; - $this->datec = $this->db->jdate($obj->datec); - $this->url = $obj->url; - $this->target = $obj->target; - $this->title = $obj->title; - $this->position = $obj->position; - $this->favicon = $obj->favicon; + $this->fk_user = $obj->fk_user; + $this->datec = $this->db->jdate($obj->datec); + $this->url = $obj->url; + $this->target = $obj->target; + $this->title = $obj->title; + $this->position = $obj->position; + $this->favicon = $obj->favicon; - $this->db->free($resql); - return $this->id; - } else { - dol_print_error($this->db); - return -1; - } - } + $this->db->free($resql); + return $this->id; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Insert bookmark into database - * - * @return int <0 si ko, rowid du bookmark cree si ok - */ - public function create() - { - global $conf; + /** + * Insert bookmark into database + * + * @return int <0 si ko, rowid du bookmark cree si ok + */ + public function create() + { + global $conf; - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; $now = dol_now(); - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; - $sql .= ",title,favicon,position"; - $sql .= ",entity"; - $sql .= ") VALUES ("; - $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; - $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; - $sql .= ", ".$this->db->escape($conf->entity); - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; + $sql .= ",title,favicon,position"; + $sql .= ",entity"; + $sql .= ") VALUES ("; + $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; + $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; + $sql .= ", ".$this->db->escape($conf->entity); + $sql .= ")"; - dol_syslog("Bookmark::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); - if ($id > 0) - { - $this->id = $id; - $this->db->commit(); - return $id; - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -1; - } - } + dol_syslog("Bookmark::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); + if ($id > 0) + { + $this->id = $id; + $this->db->commit(); + return $id; + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -1; + } + } - /** - * Update bookmark record - * - * @return int <0 if KO, > if OK - */ - public function update() - { - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + /** + * Update bookmark record + * + * @return int <0 if KO, > if OK + */ + public function update() + { + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; - $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); - $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; - $sql .= " ,url = '".$this->db->escape($this->url)."'"; - $sql .= " ,target = '".$this->db->escape($this->target)."'"; - $sql .= " ,title = '".$this->db->escape($this->title)."'"; - $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; - $sql .= " ,position = '".$this->db->escape($this->position)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; + $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); + $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; + $sql .= " ,url = '".$this->db->escape($this->url)."'"; + $sql .= " ,target = '".$this->db->escape($this->target)."'"; + $sql .= " ,title = '".$this->db->escape($this->title)."'"; + $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; + $sql .= " ,position = '".$this->db->escape($this->position)."'"; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog("Bookmark::update", LOG_DEBUG); - if ($this->db->query($sql)) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::update", LOG_DEBUG); + if ($this->db->query($sql)) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Removes the bookmark - * - * @param int $id Id removed bookmark - * @return int <0 si ko, >0 si ok - */ - public function remove($id) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; + /** + * Removes the bookmark + * + * @param int $id Id removed bookmark + * @return int <0 si ko, >0 si ok + */ + public function remove($id) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; - dol_syslog("Bookmark::remove", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::remove", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Function used to replace a thirdparty id with another one. @@ -265,7 +265,7 @@ class Bookmark extends CommonObject */ public function getLibStatut($mode) { - return ''; + return ''; } /** diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index dfd6e99a9ea..93d287ac501 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -65,13 +65,13 @@ if (GETPOST('action', 'alpha') == 'set') if (!$res > 0) $error++; if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -146,13 +146,13 @@ if (!empty($conf->stock->enabled)) print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); } else { - if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); - } - print $langs->trans("Yes").'
'; - print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; + if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); + } + print $langs->trans("Yes").'
'; + print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; } print '
'; - print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; - print ''; - print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); - print "
'; + print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; + print ''; + print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); + print "
'; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 7b513ada33c..72cb99123a4 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -34,8 +34,8 @@ if ($_GET['id'] == 'NOUV') // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); + $obj_facturation = unserialize($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { // ... sinon, c'est une nouvelle vente $obj_facturation = new Facturation(); diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index cc71d1c20d8..7dbe7ceae3e 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -94,45 +94,45 @@ class Auth $test = true; - // Authentication mode - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; - // Set authmode - $authmode = explode(',', $dolibarr_main_authentication); + // Authentication mode + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; + // Set authmode + $authmode = explode(',', $dolibarr_main_authentication); - // No authentication mode - if (!count($authmode)) - { - $langs->load('main'); - dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); - exit; - } + // No authentication mode + if (!count($authmode)) + { + $langs->load('main'); + dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); + exit; + } $usertotest = $aLogin; $passwordtotest = $aPasswd; $entitytotest = $conf->entity; - // Validation tests user / password - // If ok, the variable will be initialized login - // If error, we will put error message in session under the name dol_loginmesg - $goontestloop = false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; - if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; + // Validation tests user / password + // If ok, the variable will be initialized login + // If error, we will put error message in session under the name dol_loginmesg + $goontestloop = false; + if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; + if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; - if ($test && $goontestloop) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + if ($test && $goontestloop) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); - if ($login) - { - $this->login($aLogin); - $this->passwd($aPasswd); - $ret = 0; - } else { - $ret = -1; - } - } + if ($login) + { + $this->login($aLogin); + $this->passwd($aPasswd); + $ret = 0; + } else { + $ret = -1; + } + } return $ret; } diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index f2223b0b45d..23eafadc7b8 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -25,553 +25,553 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; */ class Facturation { - /** - * Attributs "volatiles" : reinitialises apres chaque traitement d'un article - *

Attributs "volatiles" : reinitialises apres chaque traitement d'un article

- * int $id => 'rowid' du produit dans llx_product - * string $ref => 'ref' du produit dans llx_product - * int $qte => Quantite pour le produit en cours de traitement - * int $stock => Stock theorique pour le produit en cours de traitement - * int $remise_percent => Remise en pourcent sur le produit en cours - * int $montant_remise => Remise en pourcent sur le produit en cours - * int $prix => Prix HT du produit en cours - * int $tva => 'rowid' du taux de tva dans llx_c_tva - */ + /** + * Attributs "volatiles" : reinitialises apres chaque traitement d'un article + *

Attributs "volatiles" : reinitialises apres chaque traitement d'un article

+ * int $id => 'rowid' du produit dans llx_product + * string $ref => 'ref' du produit dans llx_product + * int $qte => Quantite pour le produit en cours de traitement + * int $stock => Stock theorique pour le produit en cours de traitement + * int $remise_percent => Remise en pourcent sur le produit en cours + * int $montant_remise => Remise en pourcent sur le produit en cours + * int $prix => Prix HT du produit en cours + * int $tva => 'rowid' du taux de tva dans llx_c_tva + */ - /** + /** * @var int ID */ public $id; - protected $ref; - protected $qte; - protected $stock; - protected $remise_percent; - protected $montant_remise; - protected $prix; - protected $tva; + protected $ref; + protected $qte; + protected $stock; + protected $remise_percent; + protected $montant_remise; + protected $prix; + protected $tva; - /** - * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) - * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) - * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) - * int $montant_encaisse => Montant encaisse en cas de reglement en especes - * int $montant_rendu => Monnaie rendue en cas de reglement en especes - * int $paiement_le => Date de paiement en cas de paiement differe - * - * int $prix_total_ht => Prix total hors taxes - * int $montant_tva => Montant total de la TVA, tous taux confondus - * int $prix_total_ttc => Prix total TTC - */ - protected $num_facture; - protected $mode_reglement; - protected $montant_encaisse; - protected $montant_rendu; - protected $paiement_le; + /** + * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) + * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) + * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) + * int $montant_encaisse => Montant encaisse en cas de reglement en especes + * int $montant_rendu => Monnaie rendue en cas de reglement en especes + * int $paiement_le => Date de paiement en cas de paiement differe + * + * int $prix_total_ht => Prix total hors taxes + * int $montant_tva => Montant total de la TVA, tous taux confondus + * int $prix_total_ttc => Prix total TTC + */ + protected $num_facture; + protected $mode_reglement; + protected $montant_encaisse; + protected $montant_rendu; + protected $paiement_le; - protected $prix_total_ht; - protected $montant_tva; - protected $prix_total_ttc; + protected $prix_total_ht; + protected $montant_tva; + protected $prix_total_ttc; - /** - * Constructor - */ - public function __construct() - { - $this->raz(); - $this->razPers(); - } + /** + * Constructor + */ + public function __construct() + { + $this->raz(); + $this->razPers(); + } - // Data processing methods + // Data processing methods - /** - * Add a product into cart - * - * @return void - */ - public function ajoutArticle() - { - global $conf, $db, $mysoc; + /** + * Add a product into cart + * + * @return void + */ + public function ajoutArticle() + { + global $conf, $db, $mysoc; - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); + $societe = new Societe($db); + $societe->fetch($thirdpartyid); - $product = new Product($db); - $product->fetch($this->id); + $product = new Product($db); + $product->fetch($this->id); - $vatrowid = $this->tva(); + $vatrowid = $this->tva(); - $tmp = getTaxesFromId($vatrowid); - $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); - $vat_npr = $tmp['npr']; + $tmp = getTaxesFromId($vatrowid); + $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); + $vat_npr = $tmp['npr']; - $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - // Clean vat code - $reg = array(); - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - // Define part of HT, VAT, TTC - $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); + // Define part of HT, VAT, TTC + $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); - // Calculation of total HT without discount - $total_ht = $resultarray[0]; - $total_vat = $resultarray[1]; - $total_ttc = $resultarray[2]; - $total_localtax1 = $resultarray[9]; - $total_localtax2 = $resultarray[10]; + // Calculation of total HT without discount + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_ttc = $resultarray[2]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; - // Calculation of the discount amount - if ($this->remisePercent()) - { - $remise_percent = $this->remisePercent(); - } else { - $remise_percent = 0; - } - $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->amountDiscount($montant_remise_ht); + // Calculation of the discount amount + if ($this->remisePercent()) + { + $remise_percent = $this->remisePercent(); + } else { + $remise_percent = 0; + } + $montant_remise_ht = ($resultarray[6] - $resultarray[0]); + $this->amountDiscount($montant_remise_ht); - $newcartarray = $_SESSION['poscart']; + $newcartarray = $_SESSION['poscart']; - $i = 0; - if (!is_null($newcartarray) && !empty($newcartarray)) { - $i = count($newcartarray); - } + $i = 0; + if (!is_null($newcartarray) && !empty($newcartarray)) { + $i = count($newcartarray); + } - $newcartarray[$i]['id'] = $i; - $newcartarray[$i]['ref'] = $product->ref; - $newcartarray[$i]['label'] = $product->label; - $newcartarray[$i]['price'] = $product->price; - $newcartarray[$i]['price_ttc'] = $product->price_ttc; + $newcartarray[$i]['id'] = $i; + $newcartarray[$i]['ref'] = $product->ref; + $newcartarray[$i]['label'] = $product->label; + $newcartarray[$i]['price'] = $product->price; + $newcartarray[$i]['price_ttc'] = $product->price_ttc; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (isset($product->multiprices[$societe->price_level])) - { - $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; - $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - } - } + if (!empty($conf->global->PRODUIT_MULTIPRICES)) + { + if (isset($product->multiprices[$societe->price_level])) + { + $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; + $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; + } + } - $newcartarray[$i]['fk_article'] = $this->id; - $newcartarray[$i]['qte'] = $this->qte(); - $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid - $newcartarray[$i]['remise_percent'] = $remise_percent; - $newcartarray[$i]['remise'] = price2num($montant_remise_ht); - $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); - $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); - $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); - $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); - $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); - $_SESSION['poscart'] = $newcartarray; + $newcartarray[$i]['fk_article'] = $this->id; + $newcartarray[$i]['qte'] = $this->qte(); + $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid + $newcartarray[$i]['remise_percent'] = $remise_percent; + $newcartarray[$i]['remise'] = price2num($montant_remise_ht); + $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); + $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); + $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); + $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); + $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); + $_SESSION['poscart'] = $newcartarray; - $this->raz(); - } + $this->raz(); + } - /** - * Remove a product from panel - * - * @param int $aArticle Id of line into cart to remove - * @return void - */ - public function supprArticle($aArticle) - { - $poscart = $_SESSION['poscart']; + /** + * Remove a product from panel + * + * @param int $aArticle Id of line into cart to remove + * @return void + */ + public function supprArticle($aArticle) + { + $poscart = $_SESSION['poscart']; - $j = 0; - $newposcart = array(); - foreach ($poscart as $key => $val) - { - if ($poscart[$key]['id'] != $aArticle) - { - $newposcart[$j] = $poscart[$key]; - $newposcart[$j]['id'] = $j; - $j++; - } - } - unset($poscart); - //var_dump($poscart);exit; - $_SESSION['poscart'] = $newposcart; - } + $j = 0; + $newposcart = array(); + foreach ($poscart as $key => $val) + { + if ($poscart[$key]['id'] != $aArticle) + { + $newposcart[$j] = $poscart[$key]; + $newposcart[$j]['id'] = $j; + $j++; + } + } + unset($poscart); + //var_dump($poscart);exit; + $_SESSION['poscart'] = $newposcart; + } - /** - * Calculation of total HT, total TTC and VAT amounts - * - * @return int Total - */ - public function calculTotaux() - { - global $db; + /** + * Calculation of total HT, total TTC and VAT amounts + * + * @return int Total + */ + public function calculTotaux() + { + global $db; - $total_ht = 0; - $total_ttc = 0; - $total_vat = 0; - $total_localtax1 = 0; - $total_localtax2 = 0; + $total_ht = 0; + $total_ttc = 0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; - $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); + $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - $tab_size = count($tab); - for ($i = 0; $i < $tab_size; $i++) - { - // Total HT - $remise = $tab[$i]['remise']; - $total_ht += ($tab[$i]['total_ht']); - $total_vat += ($tab[$i]['total_vat']); - $total_ttc += ($tab[$i]['total_ttc']); - $total_localtax1 += ($tab[$i]['total_localtax1']); - $total_localtax2 += ($tab[$i]['total_localtax2']); - } + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + // Total HT + $remise = $tab[$i]['remise']; + $total_ht += ($tab[$i]['total_ht']); + $total_vat += ($tab[$i]['total_vat']); + $total_ttc += ($tab[$i]['total_ttc']); + $total_localtax1 += ($tab[$i]['total_localtax1']); + $total_localtax2 += ($tab[$i]['total_localtax2']); + } - $this->prix_total_ttc = $total_ttc; - $this->prix_total_ht = $total_ht; - $this->prix_total_vat = $total_vat; - $this->prix_total_localtax1 = $total_localtax1; - $this->prix_total_localtax2 = $total_localtax2; + $this->prix_total_ttc = $total_ttc; + $this->prix_total_ht = $total_ht; + $this->prix_total_vat = $total_vat; + $this->prix_total_localtax1 = $total_localtax1; + $this->prix_total_localtax2 = $total_localtax2; - $this->montant_tva = $total_ttc - $total_ht; - //print 'total: '.$this->prix_total_ttc; exit; - } + $this->montant_tva = $total_ttc - $total_ht; + //print 'total: '.$this->prix_total_ttc; exit; + } - /** - * Reset attributes - * - * @return void - */ - public function raz() - { - $this->id('RESET'); - $this->ref('RESET'); - $this->qte('RESET'); - $this->stock('RESET'); - $this->remisePercent('RESET'); - $this->amountDiscount('RESET'); - $this->prix('RESET'); - $this->tva('RESET'); - } + /** + * Reset attributes + * + * @return void + */ + public function raz() + { + $this->id('RESET'); + $this->ref('RESET'); + $this->qte('RESET'); + $this->stock('RESET'); + $this->remisePercent('RESET'); + $this->amountDiscount('RESET'); + $this->prix('RESET'); + $this->tva('RESET'); + } - /** - * Resetting persistent attributes - * - * @return void - */ - private function razPers() - { - $this->numInvoice('RESET'); - $this->getSetPaymentMode('RESET'); - $this->amountCollected('RESET'); - $this->amountReturned('RESET'); - $this->paiementLe('RESET'); + /** + * Resetting persistent attributes + * + * @return void + */ + private function razPers() + { + $this->numInvoice('RESET'); + $this->getSetPaymentMode('RESET'); + $this->amountCollected('RESET'); + $this->amountReturned('RESET'); + $this->paiementLe('RESET'); - $this->amountWithoutTax('RESET'); - $this->amountVat('RESET'); - $this->amountWithTax('RESET'); - } + $this->amountWithoutTax('RESET'); + $this->amountVat('RESET'); + $this->amountWithTax('RESET'); + } - // Methods for modifying protected attributes + // Methods for modifying protected attributes - /** - * Getter for id - * - * @param int $aId Id - * @return int Id - */ - public function id($aId = null) - { + /** + * Getter for id + * + * @param int $aId Id + * @return int Id + */ + public function id($aId = null) + { - if (!$aId) - { - return $this->id; - } elseif ($aId == 'RESET') - { - $this->id = null; - } else { - $this->id = $aId; - } - } + if (!$aId) + { + return $this->id; + } elseif ($aId == 'RESET') + { + $this->id = null; + } else { + $this->id = $aId; + } + } - /** - * Getter for ref - * - * @param string $aRef Ref - * @return string Ref - */ - public function ref($aRef = null) - { + /** + * Getter for ref + * + * @param string $aRef Ref + * @return string Ref + */ + public function ref($aRef = null) + { - if (is_null($aRef)) - { - return $this->ref; - } elseif ($aRef == 'RESET') - { - $this->ref = null; - } else { - $this->ref = $aRef; - } - } + if (is_null($aRef)) + { + return $this->ref; + } elseif ($aRef == 'RESET') + { + $this->ref = null; + } else { + $this->ref = $aRef; + } + } - /** - * Getter for qte - * - * @param int $aQte Qty - * @return int Qty - */ - public function qte($aQte = null) - { - if (is_null($aQte)) - { - return $this->qte; - } elseif ($aQte == 'RESET') - { - $this->qte = null; - } else { - $this->qte = $aQte; - } - } + /** + * Getter for qte + * + * @param int $aQte Qty + * @return int Qty + */ + public function qte($aQte = null) + { + if (is_null($aQte)) + { + return $this->qte; + } elseif ($aQte == 'RESET') + { + $this->qte = null; + } else { + $this->qte = $aQte; + } + } - /** - * Getter for stock - * - * @param string $aStock Stock - * @return string Stock - */ - public function stock($aStock = null) - { + /** + * Getter for stock + * + * @param string $aStock Stock + * @return string Stock + */ + public function stock($aStock = null) + { - if (is_null($aStock)) - { - return $this->stock; - } elseif ($aStock == 'RESET') - { - $this->stock = null; - } else { - $this->stock = $aStock; - } - } + if (is_null($aStock)) + { + return $this->stock; + } elseif ($aStock == 'RESET') + { + $this->stock = null; + } else { + $this->stock = $aStock; + } + } - /** - * Getter for remise_percent - * - * @param string $aRemisePercent Discount - * @return string Discount - */ - public function remisePercent($aRemisePercent = null) - { + /** + * Getter for remise_percent + * + * @param string $aRemisePercent Discount + * @return string Discount + */ + public function remisePercent($aRemisePercent = null) + { - if (is_null($aRemisePercent)) - { - return $this->remise_percent; - } elseif ($aRemisePercent == 'RESET') - { - $this->remise_percent = null; - } else { - $this->remise_percent = $aRemisePercent; - } - } + if (is_null($aRemisePercent)) + { + return $this->remise_percent; + } elseif ($aRemisePercent == 'RESET') + { + $this->remise_percent = null; + } else { + $this->remise_percent = $aRemisePercent; + } + } - /** - * Getter for montant_remise - * - * @param int $aMontantRemise Amount - * @return string Amount - */ - public function amountDiscount($aMontantRemise = null) - { + /** + * Getter for montant_remise + * + * @param int $aMontantRemise Amount + * @return string Amount + */ + public function amountDiscount($aMontantRemise = null) + { - if (is_null($aMontantRemise)) { - return $this->montant_remise; - } elseif ($aMontantRemise == 'RESET') { - $this->montant_remise = null; - } else { - $this->montant_remise = $aMontantRemise; - } - } + if (is_null($aMontantRemise)) { + return $this->montant_remise; + } elseif ($aMontantRemise == 'RESET') { + $this->montant_remise = null; + } else { + $this->montant_remise = $aMontantRemise; + } + } - /** - * Getter for prix - * - * @param int $aPrix Price - * @return string Stock - */ - public function prix($aPrix = null) - { + /** + * Getter for prix + * + * @param int $aPrix Price + * @return string Stock + */ + public function prix($aPrix = null) + { - if (is_null($aPrix)) { - return $this->prix; - } elseif ($aPrix == 'RESET') { - $this->prix = null; - } else { - $this->prix = $aPrix; - } - } + if (is_null($aPrix)) { + return $this->prix; + } elseif ($aPrix == 'RESET') { + $this->prix = null; + } else { + $this->prix = $aPrix; + } + } - /** - * Getter for tva - * - * @param int $aTva Vat - * @return int Vat - */ - public function tva($aTva = null) - { - if (is_null($aTva)) { - return $this->tva; - } elseif ($aTva == 'RESET') { - $this->tva = null; - } else { - $this->tva = $aTva; - } - } + /** + * Getter for tva + * + * @param int $aTva Vat + * @return int Vat + */ + public function tva($aTva = null) + { + if (is_null($aTva)) { + return $this->tva; + } elseif ($aTva == 'RESET') { + $this->tva = null; + } else { + $this->tva = $aTva; + } + } - /** - * Get num invoice - * - * @param string $aNumFacture Invoice ref - * @return string Invoice ref - */ - public function numInvoice($aNumFacture = null) - { - if (is_null($aNumFacture)) { - return $this->num_facture; - } elseif ($aNumFacture == 'RESET') { - $this->num_facture = null; - } else { - $this->num_facture = $aNumFacture; - } - } + /** + * Get num invoice + * + * @param string $aNumFacture Invoice ref + * @return string Invoice ref + */ + public function numInvoice($aNumFacture = null) + { + if (is_null($aNumFacture)) { + return $this->num_facture; + } elseif ($aNumFacture == 'RESET') { + $this->num_facture = null; + } else { + $this->num_facture = $aNumFacture; + } + } - /** - * Get payment mode - * - * @param int $aModeReglement Payment mode - * @return int Payment mode - */ - public function getSetPaymentMode($aModeReglement = null) - { + /** + * Get payment mode + * + * @param int $aModeReglement Payment mode + * @return int Payment mode + */ + public function getSetPaymentMode($aModeReglement = null) + { - if (is_null($aModeReglement)) { - return $this->mode_reglement; - } elseif ($aModeReglement == 'RESET') { - $this->mode_reglement = null; - } else { - $this->mode_reglement = $aModeReglement; - } - } + if (is_null($aModeReglement)) { + return $this->mode_reglement; + } elseif ($aModeReglement == 'RESET') { + $this->mode_reglement = null; + } else { + $this->mode_reglement = $aModeReglement; + } + } - /** - * Get amount - * - * @param int $aMontantEncaisse Amount - * @return int Amount - */ - public function amountCollected($aMontantEncaisse = null) - { + /** + * Get amount + * + * @param int $aMontantEncaisse Amount + * @return int Amount + */ + public function amountCollected($aMontantEncaisse = null) + { - if (is_null($aMontantEncaisse)) { - return $this->montant_encaisse; - } elseif ($aMontantEncaisse == 'RESET') { - $this->montant_encaisse = null; - } else { - $this->montant_encaisse = $aMontantEncaisse; - } - } + if (is_null($aMontantEncaisse)) { + return $this->montant_encaisse; + } elseif ($aMontantEncaisse == 'RESET') { + $this->montant_encaisse = null; + } else { + $this->montant_encaisse = $aMontantEncaisse; + } + } - /** - * Get amount - * - * @param int $aMontantRendu Amount - * @return int Amount - */ - public function amountReturned($aMontantRendu = null) - { + /** + * Get amount + * + * @param int $aMontantRendu Amount + * @return int Amount + */ + public function amountReturned($aMontantRendu = null) + { - if (is_null($aMontantRendu)) { - return $this->montant_rendu; - } elseif ($aMontantRendu == 'RESET') { - $this->montant_rendu = null; - } else { - $this->montant_rendu = $aMontantRendu; - } - } + if (is_null($aMontantRendu)) { + return $this->montant_rendu; + } elseif ($aMontantRendu == 'RESET') { + $this->montant_rendu = null; + } else { + $this->montant_rendu = $aMontantRendu; + } + } - /** - * Get payment date - * - * @param integer $aPaiementLe Date - * @return integer Date - */ - public function paiementLe($aPaiementLe = null) - { - if (is_null($aPaiementLe)) { - return $this->paiement_le; - } elseif ($aPaiementLe == 'RESET') { - $this->paiement_le = null; - } else { - $this->paiement_le = $aPaiementLe; - } - } + /** + * Get payment date + * + * @param integer $aPaiementLe Date + * @return integer Date + */ + public function paiementLe($aPaiementLe = null) + { + if (is_null($aPaiementLe)) { + return $this->paiement_le; + } elseif ($aPaiementLe == 'RESET') { + $this->paiement_le = null; + } else { + $this->paiement_le = $aPaiementLe; + } + } - /** - * Get total HT - * - * @param int $aTotalHt Total amount - * @return int Total amount - */ - public function amountWithoutTax($aTotalHt = null) - { - if (is_null($aTotalHt)) { - return $this->prix_total_ht; - } elseif ($aTotalHt == 'RESET') { - $this->prix_total_ht = null; - } else { - $this->prix_total_ht = $aTotalHt; - } - } + /** + * Get total HT + * + * @param int $aTotalHt Total amount + * @return int Total amount + */ + public function amountWithoutTax($aTotalHt = null) + { + if (is_null($aTotalHt)) { + return $this->prix_total_ht; + } elseif ($aTotalHt == 'RESET') { + $this->prix_total_ht = null; + } else { + $this->prix_total_ht = $aTotalHt; + } + } - /** - * Get amount vat - * - * @param int $aMontantTva Amount vat - * @return int Amount vat - */ - public function amountVat($aMontantTva = null) - { - if (is_null($aMontantTva)) { - return $this->montant_tva; - } elseif ($aMontantTva == 'RESET') { - $this->montant_tva = null; - } else { - $this->montant_tva = $aMontantTva; - } - } + /** + * Get amount vat + * + * @param int $aMontantTva Amount vat + * @return int Amount vat + */ + public function amountVat($aMontantTva = null) + { + if (is_null($aMontantTva)) { + return $this->montant_tva; + } elseif ($aMontantTva == 'RESET') { + $this->montant_tva = null; + } else { + $this->montant_tva = $aMontantTva; + } + } - /** - * Get total TTC - * - * @param int $aTotalTtc Amount ttc - * @return int Amount ttc - */ - public function amountWithTax($aTotalTtc = null) - { - if (is_null($aTotalTtc)) - { - return $this->prix_total_ttc; - } elseif ($aTotalTtc == 'RESET') - { - $this->prix_total_ttc = null; - } else { - $this->prix_total_ttc = $aTotalTtc; - } - } + /** + * Get total TTC + * + * @param int $aTotalTtc Amount ttc + * @return int Amount ttc + */ + public function amountWithTax($aTotalTtc = null) + { + if (is_null($aTotalTtc)) + { + return $this->prix_total_ttc; + } elseif ($aTotalTtc == 'RESET') + { + $this->prix_total_ttc = null; + } else { + $this->prix_total_ttc = $aTotalTtc; + } + } } diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 16b4bfec017..76ad8571118 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -67,15 +67,15 @@ switch ($action) { $ret[$key] = $value; } - // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function + // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function $productid = $ret['rowid']; $product = new Product($db); - $product->fetch($productid); - $prod = $product; + $product->fetch($productid); + $prod = $product; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); + $societe = new Societe($db); $societe->fetch($thirdpartyid); // Update if prices fields are defined @@ -91,39 +91,39 @@ switch ($action) // multiprix if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) { - $pu_ht = $prod->multiprices[$societe->price_level]; - $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; - $price_min = $prod->multiprices_min[$societe->price_level]; - $price_base_type = $prod->multiprices_base_type[$societe->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; - } + $pu_ht = $prod->multiprices[$societe->price_level]; + $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; + $price_min = $prod->multiprices_min[$societe->price_level]; + $price_base_type = $prod->multiprices_base_type[$societe->price_level]; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; + } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; - $prodcustprice = new Productcustomerprice($db); + $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) - { - if (count($prodcustprice->lines) > 0) - { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; - $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; - } - } else { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr = 0; + } + } else { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); @@ -131,17 +131,17 @@ switch ($action) // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (!empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } } $obj_facturation->id($ret['rowid']); @@ -187,17 +187,17 @@ switch ($action) $newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int'); if ($newthirdpartyid > 0) { - $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; + $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; } $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; + break; case 'ajout_article': // We have clicked on button "Add product" if (!empty($obj_facturation->id)) // A product was previously selected and stored in session, so we can add it { - dol_syslog("facturation_verif save vat ".$_POST['selTva']); + dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index e8366e981cc..45ce3857068 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -51,9 +51,9 @@ if (empty($username)) // Check third party id if (!($thirdpartyid > 0)) { - $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; + $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); + header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); + exit; } // If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. @@ -107,12 +107,12 @@ if ($retour >= 0) $_SESSION['lastname'] = $tab['lastname']; $_SESSION['firstname'] = $tab['firstname']; $_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : ''); - $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); + $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); - //var_dump($_SESSION);exit; + $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); + //var_dump($_SESSION);exit; header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); exit; @@ -121,7 +121,7 @@ if ($retour >= 0) } } else { // Load translation files required by the page - $langs->loadLangs(array("other", "errors")); + $langs->loadLangs(array("other", "errors")); $retour = $langs->trans("ErrorBadLoginPassword"); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); exit; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d9d12c5d84e..d48fc544eb0 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -118,7 +118,7 @@ for ($i = 0; $i < $nbtoshow; $i++) $buyer = new Societe($db); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); - ?> + ?> diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index bd73954f6a0..e3c3c285966 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -50,22 +50,22 @@ $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab_size = count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; else { - for ($i = 0; $i < $tab_size; $i++) - { - echo ('
'."\n"); - echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); + for ($i = 0; $i < $tab_size; $i++) + { + echo ('
'."\n"); + echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); - if ($tab[$i]['remise_percent'] > 0) { - $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; - } else { - $remise_percent = ''; - } + if ($tab[$i]['remise_percent'] > 0) { + $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; + } else { + $remise_percent = ''; + } - $remise = $tab[$i]['remise']; + $remise = $tab[$i]['remise']; - echo ('

'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')

'."\n"); - echo ('
'."\n"); - } + echo ('

'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')

'."\n"); + echo ('
'."\n"); + } } echo ('

'.$langs->trans("Total").' : '.price(price2num($total_ttc, 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'

'."\n"); diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index b5994456252..101ea687e7b 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -55,11 +55,11 @@ $object->fetch($facid);

'; - print $object->ref; - ?>

+ // Recuperation et affichage de la date et de l'heure + $now = dol_now(); + print dol_print_date($now, 'dayhourtext').'
'; + print $object->ref; + ?>

@@ -78,14 +78,14 @@ $object->fetch($facid); + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + $remise = $tab[$i]['remise']; + ?> @@ -94,8 +94,8 @@ $object->fetch($facid); currency); ?> + } + ?> diff --git a/htdocs/cashdesk/validation_ticket.php b/htdocs/cashdesk/validation_ticket.php index 7e4e101c9b8..28ad91dc4e7 100644 --- a/htdocs/cashdesk/validation_ticket.php +++ b/htdocs/cashdesk/validation_ticket.php @@ -35,7 +35,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation); if (empty($reshook)) { - require 'tpl/ticket.tpl.php'; + require 'tpl/ticket.tpl.php'; } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index d57aaa251ce..9468c395756 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -39,11 +39,11 @@ $bankaccountid = GETPOST('cashdeskbank'); switch ($action) { default: - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; break; case 'validate_sell': - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $company = new Societe($db); $company->fetch($thirdpartyid); @@ -97,9 +97,9 @@ switch ($action) $obj_facturation->amountReturned($encaisse - $total); } else { - //$txtDatePaiement=$_POST['txtDatePaiement']; - $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); - $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); + //$txtDatePaiement=$_POST['txtDatePaiement']; + $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); + $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); $obj_facturation->paiementLe($txtDatePaiement); } @@ -252,12 +252,12 @@ switch ($action) } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } $id = $invoice->id; } else { - $resultcreate = $invoice->create($user, 0, 0); + $resultcreate = $invoice->create($user, 0, 0); if ($resultcreate > 0) { $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); @@ -282,8 +282,8 @@ switch ($action) if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); if ($result < 0) { - setEventMessages($mouvP->error, $mouvP->errors, 'errors'); - $error++; + setEventMessages($mouvP->error, $mouvP->errors, 'errors'); + $error++; } } } @@ -303,33 +303,33 @@ switch ($action) $paiement_id = $payment->create($user); if ($paiement_id > 0) { - if (!$error) - { - $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); - if (!$result > 0) - { - $errmsg = $paiement->error; - $error++; - } - } + if (!$error) + { + $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); + if (!$result > 0) + { + $errmsg = $paiement->error; + $error++; + } + } - if (!$error) - { - if ($invoice->total_ttc == $obj_facturation->amountWithTax() - && $obj_facturation->getSetPaymentMode() != 'DIFF') - { - // We set status to payed - $result = $invoice->set_paid($user); - //print 'set paid';exit; - } - } + if (!$error) + { + if ($invoice->total_ttc == $obj_facturation->amountWithTax() + && $obj_facturation->getSetPaymentMode() != 'DIFF') + { + // We set status to payed + $result = $invoice->set_paid($user); + //print 'set paid';exit; + } + } } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } } diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index f9127914059..693a3e53a2a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -42,26 +42,26 @@ $action = GETPOST('action', 'aZ09'); $reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 9bc1dd685ff..ff6a4ca7881 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -78,9 +78,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 6598387c36a..40542e70f6f 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -264,7 +264,7 @@ if ($user->rights->categorie->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d37bdfed04d..3aca92708a7 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1551,7 +1551,7 @@ class Categorie extends CommonObject if (colorIsLight($this->color)) $forced_color = 'categtextblack'; } - $link = ''; + $link = ''; $linkend = ''; $picto = 'category'; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 4b4eaffeb57..7764341dfd7 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -56,7 +56,7 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); if ($id > 0) { - $result = $object->fetch($id); + $result = $object->fetch($id); } $extrafields = new ExtraFields($db); @@ -73,23 +73,23 @@ $error = 0; */ if ($cancel) { - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; } // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; - $object->fk_parent = $parent != -1 ? $parent : 0; + $object->fk_parent = $parent != -1 ? $parent : 0; if (empty($object->label)) { - $error++; + $error++; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 5bd8f6c9d24..f64f3be8f9e 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -44,8 +44,8 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); if (!$object->fetch($id) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -72,7 +72,7 @@ $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { - $morehtmlref .= $way."
\n"; + $morehtmlref .= $way."
\n"; } $morehtmlref .= '
'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 280b278657c..4306bc728d6 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -126,19 +126,19 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $tmpobject = new Account($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'account'; - } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) - { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $tmpobject = new Project($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) + } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) + { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpobject = new Project($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'project'; + } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); @@ -162,9 +162,9 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } if ($elemid && $action == 'addintocategory' && - (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || - ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || - ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || + ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) )) { if ($type == Categorie::TYPE_PRODUCT) @@ -227,7 +227,7 @@ $morehtmlref = '
'; @@ -801,61 +801,61 @@ if ($type == Categorie::TYPE_CONTACT) // List of bank accounts if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $permission = $user->rights->banque->creer; + $permission = $user->rights->banque->creer; - $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($accounts < 0) - { - dol_print_error($db, $object->error, $object->errors); - } else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($accounts < 0) + { + dol_print_error($db, $object->error, $object->errors); + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); - print "\n"; - print ''."\n"; + print "
'.$langs->trans("Ref").'
\n"; + print ''."\n"; - if (count($accounts) > 0) - { - $i = 0; - foreach ($accounts as $key => $account) - { - $i++; - if ($i > $limit) break; + if (count($accounts) > 0) + { + $i = 0; + foreach ($accounts as $key => $account) + { + $i++; + if ($i > $limit) break; - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; - } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; - print $account->getNomUrl(1, 0); - print "'.$account->bank."'.$account->number."'; - if ($permission) - { - print ""; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\t".''."\n"; + print ''; + print $account->getNomUrl(1, 0); + print "\n"; + print ''.$account->bank."\n"; + print ''.$account->number."\n"; + // Link to delete from category + print ''; + if ($permission) + { + print "
"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "\n"; + } + } else { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; - print ''."\n"; - } + print ''."\n"; + } } // List of Project diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index a46e302bd4b..99326bb6abf 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -96,14 +96,14 @@ $formactions = new FormActions($db); // Load object if ($id > 0 && $action != 'add') { - $ret = $object->fetch($id); - if ($ret > 0) { - $ret = $object->fetch_optionals(); - $ret1 = $object->fetch_userassigned(); - } - if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); - } + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } } // fetch optionals attributes and labels @@ -172,10 +172,10 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt // Link to a project if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { - //$object->fetch($id); - $object->setProject(GETPOST('projectid', 'int')); + //$object->fetch($id); + $object->setProject(GETPOST('projectid', 'int')); } // Action clone object @@ -187,10 +187,10 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') } else { if ($id > 0) { //$object->fetch($id); - if (!empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contact_id = key($object->socpeopleassigned); + } $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -208,13 +208,13 @@ if (empty($reshook) && $action == 'add') { $error = 0; - if (empty($backtopage)) - { - if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; - } + if (empty($backtopage)) + { + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; + else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + } - if (!empty($socpeopleassigned[0])) + if (!empty($socpeopleassigned[0])) { $result = $contact->fetch($socpeopleassigned[0]); } @@ -225,9 +225,9 @@ if (empty($reshook) && $action == 'add') exit; } - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -284,13 +284,13 @@ if (empty($reshook) && $action == 'add') $taskid = GETPOST('taskid', 'int'); if (!empty($taskid)) { - $taskProject = new Task($db); - if ($taskProject->fetch($taskid) > 0) { - $object->fk_project = $taskProject->fk_project; - } + $taskProject = new Task($db); + if ($taskProject->fetch($taskid) > 0) { + $object->fk_project = $taskProject->fk_project; + } - $object->fk_element = $taskid; - $object->elementtype = 'task'; + $object->fk_element = $taskid; + $object->elementtype = 'task'; } $object->datep = $datep; @@ -390,7 +390,7 @@ if (empty($reshook) && $action == 'add') if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. // Create reminders - if ($addreminder == 'on'){ + if ($addreminder == 'on') { $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); @@ -409,7 +409,7 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $db->rollback(); $langs->load("errors"); @@ -419,13 +419,13 @@ if (empty($reshook) && $action == 'add') break; } } - } + } - if ($error) { - $db->rollback(); - } else { + if ($error) { + $db->rollback(); + } else { $db->commit(); - } + } if (!empty($backtopage)) { @@ -461,14 +461,14 @@ if (empty($reshook) && $action == 'update') { if (empty($cancel)) { - $fulldayevent = GETPOST('fullday'); - $aphour = GETPOST('aphour'); - $apmin = GETPOST('apmin'); - $p2hour = GETPOST('p2hour'); - $p2min = GETPOST('p2min'); + $fulldayevent = GETPOST('fullday'); + $aphour = GETPOST('aphour'); + $apmin = GETPOST('apmin'); + $p2hour = GETPOST('p2hour'); + $p2min = GETPOST('p2min'); $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters if ($aphour == -1) $aphour = '0'; if ($apmin == -1) $apmin = '0'; if ($p2hour == -1) $p2hour = '0'; @@ -494,7 +494,7 @@ if (empty($reshook) && $action == 'update') $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); - $object->contact_id = GETPOST("contactid", 'int'); + $object->contact_id = GETPOST("contactid", 'int'); if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); $object->contact_id = key($object->socpeopleassigned); @@ -564,64 +564,64 @@ if (empty($reshook) && $action == 'update') $ret = $extrafields->setOptionalsFromPost(null, $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; + 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 ("; + $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 .= ")"; + // 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); - } + $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) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } if (!$error) { @@ -646,7 +646,7 @@ if (empty($reshook) && $action == 'update') } //Create reminders - if ($addreminder == 'on' && $object->datep > dol_now()){ + if ($addreminder == 'on' && $object->datep > dol_now()) { $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); @@ -665,7 +665,7 @@ if (empty($reshook) && $action == 'update') $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $langs->load("errors"); $error = $langs->trans('ErrorReminderActionCommCreation'); @@ -689,12 +689,12 @@ if (empty($reshook) && $action == 'update') if (!$error) { - if (!empty($backtopage)) - { - unset($_SESSION['assignedtouser']); - header("Location: ".$backtopage); - exit; - } + if (!empty($backtopage)) + { + unset($_SESSION['assignedtouser']); + header("Location: ".$backtopage); + exit; + } } } @@ -704,9 +704,9 @@ if (empty($reshook) && $action == 'update') if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); - $object->fetch_optionals(); - $object->fetch_userassigned(); - $object->oldcopy = clone $object; + $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) @@ -729,112 +729,112 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes */ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $error = 0; + $error = 0; - $shour = dol_print_date($object->datep, "%H"); - $smin = dol_print_date($object->datep, "%M"); + $shour = dol_print_date($object->datep, "%H"); + $smin = dol_print_date($object->datep, "%M"); - $newdate = GETPOST('newdate', 'alpha'); - if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) - { - header("Location: ".$backtopage); - exit; - } + $newdate = GETPOST('newdate', 'alpha'); + if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) + { + header("Location: ".$backtopage); + exit; + } - $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); - if ($datep != $object->datep) - { - if (!empty($object->datef)) - { - $object->datef += $datep - $object->datep; - } - $object->datep = $datep; + $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); + if ($datep != $object->datep) + { + if (!empty($object->datef)) + { + $object->datef += $datep - $object->datep; + } + $object->datep = $datep; - 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; + 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 ("; + $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 .= ")"; + // 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); - } + $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) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - if (!$error) { - $db->begin(); - $result = $object->update($user); - if ($result < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } else { - $db->commit(); - } - } - } - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } else { - $action = ''; - } + if (!$error) { + $db->begin(); + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } else { + $db->commit(); + } + } + } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } else { + $action = ''; + } } // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -869,10 +869,10 @@ if ($action == 'create') dol_set_focus("#label"); - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print '
'; print ''; @@ -972,7 +972,7 @@ if ($action == 'create') print ''.$langs->trans("DateActionEnd").''; print ''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" } else { print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); } @@ -997,7 +997,7 @@ if ($action == 'create') } print '';*/ - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1061,11 +1061,11 @@ if ($action == 'create') $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''; - } + } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; @@ -1206,24 +1206,24 @@ if ($action == 'create') } // Priority - if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { print ''.$langs->trans("Priority").''; print ''; print ''; } - // Description - print ''.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); - $doleditor->Create(); - print ''; + // Description + print ''.$langs->trans("Description").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor->Create(); + print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1231,46 +1231,46 @@ if ($action == 'create') print ''; - if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) - { - //checkbox create reminder - print '
'; - print '
'; - print '

'; + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + //checkbox create reminder + print '
'; + print '
'; + print '

'; - print ''; - print "\n".''."\n"; - } + print ''."\n"; + } - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1327,7 +1327,7 @@ if ($id > 0) if ($listUserAssignedUpdated || $donotclearsession) { - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -1338,7 +1338,7 @@ if ($id > 0) $object->datef = $datef; $object->percentage = $percentage; $object->priority = GETPOST("priority", "alphanohtml"); - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; $object->location = GETPOST('location', "alpanohtml"); $object->socid = GETPOST("socid", "int"); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); @@ -1376,10 +1376,10 @@ if ($id > 0) if ($action == 'edit') { - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print ''; print ''; @@ -1420,42 +1420,42 @@ if ($id > 0) // Type of event if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''; - if ($object->type_code != 'AC_OTH_AUTO') - { - $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); - } else { - print ''.$langs->trans("Action".$object->type_code); - } + print ''.$langs->trans("Type").''; + if ($object->type_code != 'AC_OTH_AUTO') + { + $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); + } else { + print ''.$langs->trans("Action".$object->type_code); + } print ''; } // Title print ''.$langs->trans("Title").''; - // Full day event - print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; + // Full day event + print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; // Date start print ''.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } - print ' - '; + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } + print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } print ''; - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1512,50 +1512,50 @@ if ($id > 0) $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''; - } + } // Assigned to - $listofuserid = array(); // User assigned - if (empty($donotclearsession)) - { - if ($object->userownerid > 0) - { - $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'type'=>'user', - //'transparency'=>$object->userassigned[$user->id]['transparency'], - 'transparency'=>$object->transparency, // Force transparency on ownerfrom event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] - ); - } - if (!empty($object->userassigned)) // Now concat assigned users - { - // Restore array with key with same value than param 'id' - $tmplist1 = $object->userassigned; - foreach ($tmplist1 as $key => $val) - { - if ($val['id'] && $val['id'] != $object->userownerid) - { - $listofuserid[$val['id']] = $val; - } - } - } - $_SESSION['assignedtouser'] = json_encode($listofuserid); - } else { - if (!empty($_SESSION['assignedtouser'])) - { - $listofuserid = json_decode($_SESSION['assignedtouser'], true); - } - } - $listofcontactid = $object->socpeopleassigned; // Contact assigned - $listofotherid = $object->otherassigned; // Other undefined email (not used yet) + $listofuserid = array(); // User assigned + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) + { + $listofuserid[$object->userownerid] = array( + 'id'=>$object->userownerid, + 'type'=>'user', + //'transparency'=>$object->userassigned[$user->id]['transparency'], + 'transparency'=>$object->transparency, // Force transparency on ownerfrom event + 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], + 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + ); + } + if (!empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) + { + $listofuserid[$val['id']] = $val; + } + } + } + $_SESSION['assignedtouser'] = json_encode($listofuserid); + } else { + if (!empty($_SESSION['assignedtouser'])) + { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } + } + $listofcontactid = $object->socpeopleassigned; // Contact assigned + $listofotherid = $object->otherassigned; // Other undefined email (not used yet) - print ''.$langs->trans("ActionAssignedTo").''; + print ''.$langs->trans("ActionAssignedTo").''; print '
'; print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
'; @@ -1575,7 +1575,7 @@ if ($id > 0) print ''; } // Tags-Categories - if ($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1635,7 +1635,7 @@ if ($id > 0) } // Priority - if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { print ''.$langs->trans("Priority").''; print ''; print ''; @@ -1645,19 +1645,19 @@ if ($id > 0) if (!empty($object->fk_element) && !empty($object->elementtype)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print ''; + print ''; print ''.$langs->trans("LinkedObject").''; if ($object->elementtype == 'task' && !empty($conf->projet->enabled)) { - print ''; + print ''; $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility - $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; + $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; - // update task list - print "\n".''."\n"; + print ''."\n"; - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); - print ''; + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + print ''; - print ''; + print ''; } else { - print ''; - print dolGetElementUrl($object->fk_element, $object->elementtype, 1); - print ''; - print ''; - print ''; + print ''; + print dolGetElementUrl($object->fk_element, $object->elementtype, 1); + print ''; + print ''; + print ''; } print ''; } - // Description - print ''.$langs->trans("Description").''; - // Editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); - print ''; + // Description + print ''.$langs->trans("Description").''; + // Editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1832,46 +1832,46 @@ if ($id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
'.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) - { - if ($action != 'classify') { + $langs->load("projects"); + //$morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print '
'; @@ -1884,8 +1884,8 @@ if ($id > 0) print ''.$langs->trans("Type").''.$langs->trans($object->type).''; } - // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; + // Full day event + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; @@ -1900,19 +1900,19 @@ if ($id > 0) // Date end print ''.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); else print dol_print_date($object->datef, 'day'); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''.$object->location.''; - } + } // Assigned to - print ''.$langs->trans("ActionAssignedTo").''; + print ''.$langs->trans("ActionAssignedTo").''; $listofuserid = array(); if (empty($donotclearsession)) { @@ -1988,8 +1988,8 @@ if ($id > 0) if ($conf->societe->enabled) { - // Related company - print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); + // Related company + print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) @@ -2051,43 +2051,43 @@ if ($id > 0) print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); print ''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - // Reminders - if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) - { - $filtreuserid = $user->id; - if ($user->rights->agenda->allactions->read) $filtreuserid = 0; - $object->loadReminders('', $filteruserid, false); + // Reminders + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + $filtreuserid = $user->id; + if ($user->rights->agenda->allactions->read) $filtreuserid = 0; + $object->loadReminders('', $filteruserid, false); - print ''.$langs->trans("Reminders").''; + print ''.$langs->trans("Reminders").''; - if (count($object->reminders) > 0) { - $tmpuserstatic = new User($db); + if (count($object->reminders) > 0) { + $tmpuserstatic = new User($db); - foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; - if ($actioncommreminder->fk_user > 0) { - $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; - } - print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; - if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { - print ' - '; - print $langs->trans("NotSent"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { - print ' - '; - print $langs->trans("Done"); - print ' '; - } - print '
'; - } - } + foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { + print $TRemindTypes[$actioncommreminder->typeremind]; + if ($actioncommreminder->fk_user > 0) { + $tmpuserstatic->fetch($actioncommreminder->fk_user); + print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; + } + print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; + if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { + print ' - '; + print $langs->trans("NotSent"); + print ' '; + } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { + print ' - '; + print $langs->trans("Done"); + print ' '; + } + print '
'; + } + } - print ''; - } + print ''; + } print ''; @@ -2144,26 +2144,26 @@ if ($id > 0) if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) { print '
'; - print ''; // ancre + print ''; // ancre - /* + /* * Documents generes */ - $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->agenda->myactions->read; - $delallowed = $user->rights->agenda->myactions->create; + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); print '
'; print '
'; - } + } } } diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 16384edfcde..09c9a25ca1a 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -77,8 +77,8 @@ class ActionCommReminder extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), @@ -93,10 +93,10 @@ class ActionCommReminder extends CommonObject */ public $rowid; - /** - * @var int Entity - */ - public $entity; + /** + * @var int Entity + */ + public $entity; public $dateremind; public $typeremind; @@ -204,7 +204,7 @@ class ActionCommReminder extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -214,7 +214,7 @@ class ActionCommReminder extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0 || $mode == 1) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 6e86a556a1a..55a98dbb1dc 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -162,12 +162,12 @@ class CActionComm if ($qualified && $obj->module) { - if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified=0; - if ($obj->module == 'order' && !$conf->commande->enabled) $qualified=0; - if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified=0; - if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_invoice->enabled)) $qualified=0; - if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_order->enabled)) $qualified=0; - if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified=0; + if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0; + if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0; + if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0; + if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) $qualified = 0; + if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) $qualified = 0; + if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0; } if ($qualified) diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index b806dde94f9..4789e49f44a 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -32,144 +32,144 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; */ class ICal { - // Text in file - public $file_text; - public $cal; // Array to save iCalendar parse data - public $event_count; // Number of Events - public $todo_count; // Number of Todos - public $freebusy_count; // Number of Freebusy - public $last_key; //Help variable save last key (multiline string) + // Text in file + public $file_text; + public $cal; // Array to save iCalendar parse data + public $event_count; // Number of Events + public $todo_count; // Number of Todos + public $freebusy_count; // Number of Freebusy + public $last_key; //Help variable save last key (multiline string) - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Read text file, icalender text file - * - * @param string $file File - * @return string - */ - public function read_file($file) - { - // phpcs:enable - $this->file = $file; - $file_text = ''; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Read text file, icalender text file + * + * @param string $file File + * @return string + */ + public function read_file($file) + { + // phpcs:enable + $this->file = $file; + $file_text = ''; - $tmparray = file($file); - if (is_array($tmparray)) - { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); - } - return $file_text; // return all text - } + $tmparray = file($file); + if (is_array($tmparray)) + { + $file_text = join("", $tmparray); //load file + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + } + return $file_text; // return all text + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of calendar events - * - * @return int - */ - public function get_event_count() - { - // phpcs:enable - return $this->event_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of calendar events + * + * @return int + */ + public function get_event_count() + { + // phpcs:enable + return $this->event_count; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of to do - * - * @return int - */ - public function get_todo_count() - { - // phpcs:enable - return $this->todo_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of to do + * + * @return int + */ + public function get_todo_count() + { + // phpcs:enable + return $this->todo_count; + } - /** - * Translate Calendar - * - * @param string $uri Url - * @return array|string - */ - public function parse($uri) - { - $this->cal = array(); // new empty array + /** + * Translate Calendar + * + * @param string $uri Url + * @return array|string + */ + public function parse($uri) + { + $this->cal = array(); // new empty array - $this->event_count = -1; + $this->event_count = -1; - // read FILE text - $this->file_text = $this->read_file($uri); + // read FILE text + $this->file_text = $this->read_file($uri); - $this->file_text = preg_split("[\n]", $this->file_text); + $this->file_text = preg_split("[\n]", $this->file_text); - // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR - if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; + // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR + if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; - $insidealarm = 0; - $tmpkey = ''; $tmpvalue = ''; $type = ''; - foreach ($this->file_text as $text) - { - $text = trim($text); // trim one line - if (!empty($text)) - { - // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin - list($key, $value) = $this->retun_key_value($text); - //var_dump($text.' -> '.$key.' - '.$value); + $insidealarm = 0; + $tmpkey = ''; $tmpvalue = ''; $type = ''; + foreach ($this->file_text as $text) + { + $text = trim($text); // trim one line + if (!empty($text)) + { + // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin + list($key, $value) = $this->retun_key_value($text); + //var_dump($text.' -> '.$key.' - '.$value); - switch ($text) // search special string - { - case "BEGIN:VTODO": - $this->todo_count = $this->todo_count + 1; // new to do begin - $type = "VTODO"; - break; + switch ($text) // search special string + { + case "BEGIN:VTODO": + $this->todo_count = $this->todo_count + 1; // new to do begin + $type = "VTODO"; + break; - case "BEGIN:VEVENT": - $this->event_count = $this->event_count + 1; // new event begin - $type = "VEVENT"; - break; + case "BEGIN:VEVENT": + $this->event_count = $this->event_count + 1; // new event begin + $type = "VEVENT"; + break; - case "BEGIN:VFREEBUSY": - $this->freebusy_count = $this->freebusy_count + 1; // new event begin - $type = "VFREEBUSY"; - break; + case "BEGIN:VFREEBUSY": + $this->freebusy_count = $this->freebusy_count + 1; // new event begin + $type = "VFREEBUSY"; + break; - case "BEGIN:VCALENDAR": // all other special string - case "BEGIN:DAYLIGHT": - case "BEGIN:VTIMEZONE": - case "BEGIN:STANDARD": - $type = $value; // save array under value key - break; + case "BEGIN:VCALENDAR": // all other special string + case "BEGIN:DAYLIGHT": + case "BEGIN:VTIMEZONE": + case "BEGIN:STANDARD": + $type = $value; // save array under value key + break; - case "END:VTODO": // end special text - goto VCALENDAR key - case "END:VEVENT": - case "END:VFREEBUSY": + case "END:VTODO": // end special text - goto VCALENDAR key + case "END:VEVENT": + case "END:VFREEBUSY": - case "END:VCALENDAR": - case "END:DAYLIGHT": - case "END:VTIMEZONE": - case "END:STANDARD": - $type = "VCALENDAR"; - break; + case "END:VCALENDAR": + case "END:DAYLIGHT": + case "END:VTIMEZONE": + case "END:STANDARD": + $type = "VCALENDAR"; + break; - // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT - case "BEGIN:VALARM": - $insidealarm = 1; - break; - case "END:VALARM": - $insidealarm = 0; - break; + // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT + case "BEGIN:VALARM": + $insidealarm = 1; + break; + case "END:VALARM": + $insidealarm = 0; + break; - default: // no special string (SUMMARY, DESCRIPTION, ...) - if ($tmpvalue) + default: // no special string (SUMMARY, DESCRIPTION, ...) + if ($tmpvalue) { $tmpvalue .= $text; if (!preg_match('/=$/', $text)) // No more lines @@ -180,96 +180,96 @@ class ICal $tmpvalue = ''; } } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) - { - if (preg_match('/=$/', $value)) - { - $tmpkey = $key; - $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message - } else { - $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); - } - } //$value=quotedPrintDecode($tmpvalue.$value); - if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array - break; - } - } - } + { + if (preg_match('/=$/', $value)) + { + $tmpkey = $key; + $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message + } else { + $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); + } + } //$value=quotedPrintDecode($tmpvalue.$value); + if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array + break; + } + } + } - //var_dump($this->cal); - return $this->cal; - } + //var_dump($this->cal); + return $this->cal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Add to $this->ical array one value and key. - * - * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) - * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property - * @param string $value Value - * @return void - */ - public function add_to_array($type, $key, $value) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Add to $this->ical array one value and key. + * + * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) + * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property + * @param string $value Value + * @return void + */ + public function add_to_array($type, $key, $value) + { + // phpcs:enable - //print 'type='.$type.' key='.$key.' value='.$value.'
'."\n"; + //print 'type='.$type.' key='.$key.' value='.$value.'
'."\n"; - if (empty($key)) - { - $key = $this->last_key; - switch ($type) - { - case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; - case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; - case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; - } - } + if (empty($key)) + { + $key = $this->last_key; + switch ($type) + { + case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; + case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; + case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; + } + } - if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); - //if ($key == "RRULE" ) $value = $this->ical_rrule($value); + if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); + //if ($key == "RRULE" ) $value = $this->ical_rrule($value); - if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - list($key, $value) = array($key, $value); - } else { - list($key, $value) = $this->ical_dt_date($key, $value); - } - } + if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + list($key, $value) = array($key, $value); + } else { + list($key, $value) = $this->ical_dt_date($key, $value); + } + } - switch ($type) - { - case "VTODO": - $this->cal[$type][$this->todo_count][$key] = $value; - break; + switch ($type) + { + case "VTODO": + $this->cal[$type][$this->todo_count][$key] = $value; + break; - case "VEVENT": - $this->cal[$type][$this->event_count][$key] = $value; - break; + case "VEVENT": + $this->cal[$type][$this->event_count][$key] = $value; + break; - case "VFREEBUSY": - $this->cal[$type][$this->freebusy_count][$key] = $value; - break; + case "VFREEBUSY": + $this->cal[$type][$this->freebusy_count][$key] = $value; + break; - default: - $this->cal[$type][$key] = $value; - break; - } - $this->last_key = $key; - } + default: + $this->cal[$type][$key] = $value; + break; + } + $this->last_key = $key; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); - * - * @param string $text Text - * @return array - */ - public function retun_key_value($text) - { - // phpcs:enable - /* + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); + * + * @param string $text Text + * @return array + */ + public function retun_key_value($text) + { + // phpcs:enable + /* preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); if (empty($matches)) @@ -281,173 +281,173 @@ class ICal $matches = array_splice($matches, 1, 2); return $matches; }*/ - return explode(':', $text, 2); - } + return explode(':', $text, 2); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse RRULE return array - * - * @param string $value string - * @return array - */ - public function ical_rrule($value) - { - // phpcs:enable - $result = array(); - $rrule = explode(';', $value); - foreach ($rrule as $line) - { - $rcontent = explode('=', $line); - $result[$rcontent[0]] = $rcontent[1]; - } - return $result; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse RRULE return array + * + * @param string $value string + * @return array + */ + public function ical_rrule($value) + { + // phpcs:enable + $result = array(); + $rrule = explode(';', $value); + foreach ($rrule as $line) + { + $rcontent = explode('=', $line); + $result[$rcontent[0]] = $rcontent[1]; + } + return $result; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) - * - * @param string $ical_date String date - * @return int - */ - public function ical_date_to_unix($ical_date) - { - // phpcs:enable - $ical_date = str_replace('T', '', $ical_date); - $ical_date = str_replace('Z', '', $ical_date); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) + * + * @param string $ical_date String date + * @return int + */ + public function ical_date_to_unix($ical_date) + { + // phpcs:enable + $ical_date = str_replace('T', '', $ical_date); + $ical_date = str_replace('Z', '', $ical_date); - $ntime = 0; - // TIME LIMITED EVENT - if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) - $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); + $ntime = 0; + // TIME LIMITED EVENT + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) + $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); - //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; - //print dol_print_date($ntime,'dayhour');exit; - return $ntime; // ntime is a GTM time - } + //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; + //print dol_print_date($ntime,'dayhour');exit; + return $ntime; // ntime is a GTM time + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return unix date from iCal date format - * - * @param string $key Key - * @param string $value Value - * @return array - */ - public function ical_dt_date($key, $value) - { - // phpcs:enable - $return_value = array(); - $value = $this->ical_date_to_unix($value); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return unix date from iCal date format + * + * @param string $key Key + * @param string $value Value + * @return array + */ + public function ical_dt_date($key, $value) + { + // phpcs:enable + $return_value = array(); + $value = $this->ical_date_to_unix($value); - // Analyse TZID - $temp = explode(";", $key); + // Analyse TZID + $temp = explode(";", $key); - if (empty($temp[1])) // not TZID - { - $value = str_replace('T', '', $value); - return array($key, $value); - } + if (empty($temp[1])) // not TZID + { + $value = str_replace('T', '', $value); + return array($key, $value); + } - $key = $temp[0]; - $temp = explode("=", $temp[1]); - $return_value[$temp[0]] = $temp[1]; - $return_value['unixtime'] = $value; + $key = $temp[0]; + $temp = explode("=", $temp[1]); + $return_value[$temp[0]] = $temp[1]; + $return_value['unixtime'] = $value; - return array($key, $return_value); - } + return array($key, $return_value); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return sorted eventlist as array or false if calendar is empty - * - * @return array|false - */ - public function get_sort_event_list() - { - // phpcs:enable - $temp = $this->get_event_list(); - if (!empty($temp)) - { - usort($temp, array(&$this, "ical_dtstart_compare")); - return $temp; - } else { - return false; - } - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return sorted eventlist as array or false if calendar is empty + * + * @return array|false + */ + public function get_sort_event_list() + { + // phpcs:enable + $temp = $this->get_event_list(); + if (!empty($temp)) + { + usort($temp, array(&$this, "ical_dtstart_compare")); + return $temp; + } else { + return false; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Compare two unix timestamp - * - * @param array $a Operand a - * @param array $b Operand b - * @return integer - */ - public function ical_dtstart_compare($a, $b) - { - // phpcs:enable - return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Compare two unix timestamp + * + * @param array $a Operand a + * @param array $b Operand b + * @return integer + */ + public function ical_dtstart_compare($a, $b) + { + // phpcs:enable + return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sorted eventlist array) - * - * @return array - */ - public function get_event_list() - { - // phpcs:enable - return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sorted eventlist array) + * + * @return array + */ + public function get_event_list() + { + // phpcs:enable + return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sort eventlist array) - * - * @return array - */ - public function get_freebusy_list() - { - // phpcs:enable - return $this->cal['VFREEBUSY']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sort eventlist array) + * + * @return array + */ + public function get_freebusy_list() + { + // phpcs:enable + return $this->cal['VFREEBUSY']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return to do array (not sorted todo array) - * - * @return array - */ - public function get_todo_list() - { - // phpcs:enable - return $this->cal['VTODO']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return to do array (not sorted todo array) + * + * @return array + */ + public function get_todo_list() + { + // phpcs:enable + return $this->cal['VTODO']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return base calendar data - * - * @return array - */ - public function get_calender_data() - { - // phpcs:enable - return $this->cal['VCALENDAR']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return base calendar data + * + * @return array + */ + public function get_calender_data() + { + // phpcs:enable + return $this->cal['VCALENDAR']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return array with all data - * - * @return array - */ - public function get_all_data() - { - // phpcs:enable - return $this->cal; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array with all data + * + * @return array + */ + public function get_all_data() + { + // phpcs:enable + return $this->cal; + } } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 292c0ea94ce..40787abb8c3 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -41,8 +41,8 @@ $id = GETPOST('id', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -86,19 +86,19 @@ $morehtmlref = '
'; // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
'.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').': '; - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } + $langs->load("projects"); + //$morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 582f1c538f0..a9e365534f3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -57,10 +57,10 @@ $confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); $search_id = GETPOST('search_id', 'alpha'); @@ -166,13 +166,13 @@ if (GETPOST('cancel', 'alpha')) if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $param .= '&'.$key.'='.urlencode($val); - } - } + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $param .= '&'.$key.'='.urlencode($val); + } + } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param); exit; @@ -187,15 +187,15 @@ 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')) // All tests are required to be compatible with all browsers { - //$actioncode=''; - $search_id = ''; + //$actioncode=''; + $search_id = ''; $search_title = ''; - $search_note = ''; - $datestart = ''; - $dateend = ''; - $search_status = ''; + $search_note = ''; + $datestart = ''; + $dateend = ''; + $search_status = ''; $toselect = ''; - $search_array_options = array(); + $search_array_options = array(); } if (empty($reshook) && !empty($massaction)) @@ -341,26 +341,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -381,10 +381,10 @@ if ($search_note) $sql .= natural_search('a.note', $search_note); // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) @@ -405,13 +405,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -452,13 +452,13 @@ if ($resql) if ($showbirthday) $nav .= ''; print $nav; - //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); - //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - //print dol_get_fiche_end(); + //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); + //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + //print dol_get_fiche_end(); - // Add link to show birthdays - $link = ''; - /* + // Add link to show birthdays + $link = ''; + /* if (empty($conf->use_javascript_ajax)) { $newparam=$param; // newparam is for birthday links @@ -473,49 +473,49 @@ if ($resql) } */ - $s = $newtitle; + $s = $newtitle; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } - $viewmode = ''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewList").''; + $viewmode = ''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewList").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewCal").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewCal").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewWeek").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewWeek").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewDay").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewDay").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewPerUser").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewPerUser").''; $viewmode .= ''; @@ -538,21 +538,21 @@ if ($resql) print $s; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - $moreforfilter = ''; + $moreforfilter = ''; $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); - $i = 0; + $i = 0; - print '
'; - print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
'; + print '
'; + print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
'; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; if (!empty($arrayfields['a.id']['checked'])) print ''; @@ -571,8 +571,8 @@ if ($resql) print ''; } if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } + print ''; + } if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; if (!empty($arrayfields['a.fk_element']['checked'])) print ''; @@ -588,10 +588,10 @@ if ($resql) if (!empty($arrayfields['a.tms']['checked'])) print ''; if (!empty($arrayfields['a.percent']['checked'])) { print ''; - } + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); + print ajax_combobox('selectsearch_status'); + print ''; + } // Action column print ''; + print ''; } // Extra fields @@ -858,7 +858,7 @@ if ($resql) $i++; } print "
'; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); - print ajax_combobox('selectsearch_status'); - print ''; $searchpicto = $form->showFilterButtons(); @@ -610,10 +610,10 @@ if ($resql) if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -634,18 +634,18 @@ if ($resql) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); - $contactListCache = array(); + $contactListCache = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } $actionstatic->id = $obj->id; $actionstatic->ref = $obj->id; @@ -771,29 +771,29 @@ if ($resql) if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; - if (!empty($actionstatic->socpeopleassigned)) - { - $contactList = array(); - foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) - { - if (!isset($contactListCache[$socpeopleassigned['id']])) - { - // if no cache found we fetch it - $contact = new Contact($db); - if ($contact->fetch($socpeopleassigned['id']) > 0) - { - $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); - $contactList[] = $contact->getNomUrl(1, '', 0); - } - } else { - // use cache - $contactList[] = $contactListCache[$socpeopleassigned['id']]; - } - } - if (!empty($contactList)) { - print implode(', ', $contactList); - } - } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event + if (!empty($actionstatic->socpeopleassigned)) + { + $contactList = array(); + foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) + { + if (!isset($contactListCache[$socpeopleassigned['id']])) + { + // if no cache found we fetch it + $contact = new Contact($db); + if ($contact->fetch($socpeopleassigned['id']) > 0) + { + $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); + $contactList[] = $contact->getNomUrl(1, '', 0); + } + } else { + // use cache + $contactList[] = $contactListCache[$socpeopleassigned['id']]; + } + } + if (!empty($contactList)) { + print implode(', ', $contactList); + } + } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { $contactstatic->id = $obj->fk_contact; $contactstatic->email = $obj->email; @@ -812,15 +812,15 @@ if ($resql) // Linked object if (!empty($arrayfields['a.fk_element']['checked'])) { - print ''; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && !empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print '
"; - print '
'; + print '
'; print ''; $db->free($resql); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index f0c1a0d1951..4f292047700 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -126,16 +126,16 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { - $action = 'show_year'; + $action = 'show_year'; } // View by year // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -317,8 +317,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -345,15 +345,15 @@ if ($conf->use_javascript_ajax) //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -451,26 +451,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -480,28 +480,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -512,10 +512,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -525,104 +525,104 @@ dol_syslog("comm/action/pertype.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -634,7 +634,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -722,7 +722,7 @@ foreach ($typeofevents as $typeofevent) continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -946,15 +946,15 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; - $cases1[$h][$event->id]['typecode'] = $event->type_code; + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; + $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) { @@ -993,13 +993,13 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 899925b16f6..8983dbff7f6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -129,13 +129,13 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -323,8 +323,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -351,15 +351,15 @@ if ($conf->use_javascript_ajax) //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -408,7 +408,7 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction //$param='month='.$monthshown.'&year='.$year; $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -457,26 +457,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -486,28 +486,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -518,10 +518,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -531,105 +531,105 @@ dol_syslog("comm/action/peruser.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; - $event->fetch_userassigned(); // This load $event->userassigned + $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -641,7 +641,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -750,15 +750,15 @@ while ($currentdaytoshow < $lastdaytoshow) { { foreach ($eventarray as $daykey => $notused) { - // Get all assigned users for each event - foreach ($eventarray[$daykey] as $index => $event) - { - $event->fetch_userassigned(); + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); $listofuserid = $event->userassigned; foreach ($listofuserid as $userid => $tmp) { if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } - } + } } } else { /* Use this list to have for all users */ @@ -770,17 +770,17 @@ while ($currentdaytoshow < $lastdaytoshow) { //print $sql; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); $usernamesid[$obj->rowid] = $obj->rowid; $i++; - } - } + } + } } else dol_print_error($db); } //var_dump($usernamesid); @@ -846,7 +846,7 @@ while ($currentdaytoshow < $lastdaytoshow) { continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -1102,13 +1102,13 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; @@ -1149,12 +1149,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; @@ -1241,7 +1241,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } $ids1 = ''; - $ids2 = ''; + $ids2 = ''; if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index fbb49772d3e..3534d3d8996 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -91,13 +91,13 @@ $sql .= " ORDER BY year DESC, month DESC, df DESC"; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -113,7 +113,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print '
'; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; @@ -125,10 +125,10 @@ if ($resql) $moreforfilter = ''; $i = 0; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index 79836087775..84af27bb7b9 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -78,9 +78,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print ''; - print "
"; + print '
'; + print ''; + print "
"; } @@ -92,10 +92,10 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index df7e96fc742..bfff6cf1e35 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -487,7 +487,7 @@ if ($object->id > 0) print ''; } - if (! empty($conf->intracommreport->enabled)) + if (!empty($conf->intracommreport->enabled)) { // Transport mode by default print ''; @@ -1030,12 +1030,12 @@ if ($action == 'create') // Display of the TEST form if ($action == 'test') { - print '
'; - print load_fiche_titre($langs->trans("TestMailing")); + print '
'; + print load_fiche_titre($langs->trans("TestMailing")); - print dol_get_fiche_head(null, '', '', -1); + print dol_get_fiche_head(null, '', '', -1); - // Create mail form object + // Create mail form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->fromname = $object->email_from; @@ -1103,14 +1103,14 @@ if ($action == 'create') } print ''; - // Background color - /*print '';*/ print '
'.$langs->trans("Period").''.$langs->trans("EventsNb").''.$langs->trans("Action").'
'; @@ -675,15 +675,15 @@ if ($object->id > 0) if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { $warn = ''; if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) { - $warn = ' ' . img_warning($langs->trans("OutstandingBillReached")); + $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } $text = $langs->trans("CurrentOutstandingBillLate"); - $link = DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $object->id; + $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; - $boxstat .= '
'; - $boxstat .= '' . img_object("", $icon) . ' ' . $text . '
'; - $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . ''; + if ($link) $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; if ($link) $boxstat .= '
'; } @@ -973,7 +973,7 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); } } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 1038afa923f..9c4e1437ced 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,13 +59,13 @@ llxHeader('', $langs->trans("Contacts")); if ($type == "c" || $type == "p") { - $label = $langs->trans("Customers"); - $urlfiche = "card.php"; + $label = $langs->trans("Customers"); + $urlfiche = "card.php"; } if ($type == "f") { - $label = $langs->trans("Suppliers"); - $urlfiche = "card.php"; + $label = $langs->trans("Suppliers"); + $urlfiche = "card.php"; } /* @@ -88,29 +88,29 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if (dol_strlen($stcomm)) { - $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); + $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); } if (!empty($search_lastname)) { - $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; } if (!empty($search_firstname)) { - $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; + $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; } if (!empty($search_company)) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; + $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (!empty($contactname)) // acces a partir du module de recherche { - $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.name"; + $sortorder = "ASC"; } $sql .= $db->order($sortfield, $sortorder); @@ -171,7 +171,7 @@ if ($resql) $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index bb74fb686aa..09ed51f9418 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -103,7 +103,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action = ''; + $action = ''; } // Action send emailing for everybody @@ -188,18 +188,18 @@ if (empty($reshook)) // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other = explode(';', $obj->other); $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - $targetobject = null; // Not defined with mass emailing - $parameters = array('mode'=>'emailing'); - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; @@ -253,7 +253,7 @@ if (empty($reshook)) } //$substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs); $newsubject = make_substitutions($subject, $substitutionarray); $newmessage = make_substitutions($message, $substitutionarray); @@ -319,7 +319,7 @@ if (empty($reshook)) dol_print_error($db); } - //Update status communication of contact prospect + //Update status communication of contact prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); @@ -331,13 +331,13 @@ if (empty($reshook)) } } - if (!empty($conf->global->MAILING_DELAY)) - { - dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); - sleep($conf->global->MAILING_DELAY); - } + if (!empty($conf->global->MAILING_DELAY)) + { + dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); + sleep($conf->global->MAILING_DELAY); + } - //test if CHECK READ change statut prospect contact + //test if CHECK READ change statut prospect contact } else { // Mail failed $nbko++; @@ -417,7 +417,7 @@ if (empty($reshook)) $object->substitutionarrayfortest['__MAILTOEMAIL__'] = ''.$object->sendto.''; // Subject and message substitutions - complete_substitutions_array($object->substitutionarrayfortest, $langs); + complete_substitutions_array($object->substitutionarrayfortest, $langs); $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); @@ -426,11 +426,11 @@ if (empty($reshook)) $arr_name = array(); $arr_css = array(); - // Add CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + // Add CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - // Attached files + // Attached files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { @@ -462,9 +462,9 @@ if (empty($reshook)) { $mesgs = array(); - $object->email_from = GETPOST("from", "none"); // Must allow 'name ' - $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' - $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' + $object->email_from = GETPOST("from", "none"); // Must allow 'name ' + $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' + $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' $object->title = GETPOST("title"); $object->sujet = GETPOST("sujet"); $object->body = GETPOST("bodyemail", 'restricthtml'); @@ -504,7 +504,7 @@ if (empty($reshook)) elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' - elseif ($action == 'settitle' && empty($object->title)) { + elseif ($action == 'settitle' && empty($object->title)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); @@ -533,8 +533,8 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + // Set tmp user directory + dol_add_file_process($upload_dir, 0, 0); $action = "edit"; } @@ -546,7 +546,7 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing $action = "edit"; } @@ -611,14 +611,14 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->setStatut(0); - if ($result > 0) - { - //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result > 0) + { + //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { dol_print_error($db); } @@ -717,7 +717,7 @@ if ($action == 'create') // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -782,7 +782,7 @@ if ($action == 'create') */ if ($action == 'sendall') { - // Define message to recommand from command line + // Define message to recommand from command line $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function @@ -802,29 +802,29 @@ if ($action == 'create') $_GET["action"] = ''; } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); // The feature is forbidden from GUI, we show just message to use from command line. - setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; } else { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - $text = ''; - if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) - { - $text .= $langs->trans("MailingNeedCommand"); - $text .= '
'; - $text .= '

'; - } - $text .= $langs->trans('ConfirmSendingEmailing').'
'; + $text = ''; + if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) + { + $text .= $langs->trans("MailingNeedCommand"); + $text .= '
'; + $text .= '

'; + } + $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); } @@ -896,23 +896,23 @@ if ($action == 'create') $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text = ''; - if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { - $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { - $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); - } - } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) + { + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + } else { + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) - { - print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { - print $nbemail; - } + { + print $form->textwithpicto($nbemail, $text, 1, 'warning'); + } else { + print $nbemail; + } } print '
'.$langs->trans("BackgroundColorByDefault").''; + // Background color + /*print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); print '
'; - // Message + // Message print '
'; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { @@ -1186,7 +1186,7 @@ if ($action == 'create') // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); @@ -1261,7 +1261,7 @@ if ($action == 'create') print $out; print ''; - // Background color + // Background color print ''.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 7c219cc448a..0d621dfa186 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -78,13 +78,13 @@ if ($action == 'add') foreach ($modulesdir as $dir) { - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - dol_syslog("Scan directory ".$dir." for modules"); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); - // Loading Class - $file = $dir."/".$module.".modules.php"; - $classname = "mailing_".$module; + // Loading Class + $file = $dir."/".$module.".modules.php"; + $classname = "mailing_".$module; if (file_exists($file)) { @@ -337,12 +337,12 @@ if ($object->fetch($id) >= 0) foreach ($modulesdir as $dir) { - $modulenames = array(); + $modulenames = array(); - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - dol_syslog("Scan directory ".$dir." for modules"); - $handle = @opendir($dir); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); + $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -396,7 +396,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; } else { - print '
'; + print '
'; } print '
'; @@ -425,14 +425,14 @@ if ($object->fetch($id) >= 0) print '
'; if ($allowaddtarget) { - try { - $filter = $obj->formFilter(); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } - if ($filter) print $filter; - else print $langs->trans("None"); + try { + $filter = $obj->formFilter(); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + if ($filter) print $filter; + else print $langs->trans("None"); } print '
'; @@ -441,7 +441,7 @@ if ($object->fetch($id) >= 0) { print ''; } else { - print ''; + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -474,13 +474,13 @@ if ($object->fetch($id) >= 0) $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets @@ -503,7 +503,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; $morehtmlcenter = ''; @@ -521,7 +521,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -611,30 +611,30 @@ if ($object->fetch($id) >= 0) print ''.$obj->firstname.''; print ''.$obj->other.''; print ''; - if (empty($obj->source_id) || empty($obj->source_type)) - { - print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility - } else { - if ($obj->source_type == 'member') - { + if (empty($obj->source_id) || empty($obj->source_type)) + { + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility + } else { + if ($obj->source_type == 'member') + { $objectstaticmember->fetch($obj->source_id); - print $objectstaticmember->getNomUrl(1); - } elseif ($obj->source_type == 'user') - { + print $objectstaticmember->getNomUrl(1); + } elseif ($obj->source_type == 'user') + { $objectstaticuser->fetch($obj->source_id); - print $objectstaticuser->getNomUrl(1); - } elseif ($obj->source_type == 'thirdparty') - { + print $objectstaticuser->getNomUrl(1); + } elseif ($obj->source_type == 'thirdparty') + { $objectstaticcompany->fetch($obj->source_id); - print $objectstaticcompany->getNomUrl(1); - } elseif ($obj->source_type == 'contact') - { - $objectstaticcontact->fetch($obj->source_id); - print $objectstaticcontact->getNomUrl(1); - } else { - print $obj->source_url; - } - } + print $objectstaticcompany->getNomUrl(1); + } elseif ($obj->source_type == 'contact') + { + $objectstaticcontact->fetch($obj->source_id); + print $objectstaticcontact->getNomUrl(1); + } else { + print $obj->source_url; + } + } print ''; // Date last update @@ -680,9 +680,9 @@ if ($object->fetch($id) >= 0) } else { if ($object->statut < 2) { - print ''; - print $langs->trans("NoTargetYet"); - print ''; + print ''; + print $langs->trans("NoTargetYet"); + print ''; } } print "
"; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index b5e115d8463..447b970f39e 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -28,10 +28,10 @@ */ class AdvanceTargetingMailing extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,20 +58,20 @@ class AdvanceTargetingMailing extends CommonObject */ public $id; - public $name; - public $entity; - public $fk_element; - public $type_element; - public $filtervalue; - public $fk_user_author; - public $datec = ''; - public $fk_user_mod; - public $tms = ''; + public $name; + public $entity; + public $fk_element; + public $type_element; + public $filtervalue; + public $fk_user_author; + public $datec = ''; + public $fk_user_mod; + public $tms = ''; - public $select_target_type = array(); - public $type_statuscommprospect = array(); - public $thirdparty_lines; - public $contact_lines; + public $select_target_type = array(); + public $type_statuscommprospect = array(); + public $thirdparty_lines; + public $contact_lines; /** @@ -79,7 +79,7 @@ class AdvanceTargetingMailing extends CommonObject * * @param DoliDb $db Database handler */ - public function __construct($db) + public function __construct($db) { global $langs; $langs->load('customers'); @@ -108,7 +108,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -177,7 +177,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -226,16 +226,16 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch_by_mailing($id = 0) + public function fetch_by_mailing($id = 0) { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -290,7 +290,7 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -298,9 +298,9 @@ class AdvanceTargetingMailing extends CommonObject * @param string $type_element Type target * @return int <0 if KO, >0 if OK */ - public function fetch_by_element($id = 0, $type_element = 'mailing') + public function fetch_by_element($id = 0, $type_element = 'mailing') { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -359,7 +359,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -389,9 +389,9 @@ class AdvanceTargetingMailing extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback if ($error) @@ -416,7 +416,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -457,7 +457,7 @@ class AdvanceTargetingMailing extends CommonObject * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function savequery($user, $arrayquery) + public function savequery($user, $arrayquery) { global $langs, $conf; @@ -477,16 +477,16 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function query_thirdparty($arrayquery) + public function query_thirdparty($arrayquery) { - // phpcs:enable + // phpcs:enable global $langs, $conf, $extrafields; $sql = "SELECT"; @@ -625,7 +625,7 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * @@ -633,9 +633,9 @@ class AdvanceTargetingMailing extends CommonObject * @param int $withThirdpartyFilter add contact with tridparty filter * @return int <0 if KO, >0 if OK */ - public function query_contact($arrayquery, $withThirdpartyFilter = 0) + public function query_contact($arrayquery, $withThirdpartyFilter = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; $sql = "SELECT"; @@ -878,8 +878,8 @@ class AdvanceTargetingMailing extends CommonObject * For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima * @return string Sql to use for the where condition */ - public function transformToSQL($column_to_test, $criteria) - { + public function transformToSQL($column_to_test, $criteria) + { $return_sql_criteria = '('; //This is a multiple value test diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 53fafb0ce61..9d230404cba 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -28,9 +28,9 @@ class FormAdvTargetEmailing extends Form { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -42,12 +42,12 @@ class FormAdvTargetEmailing extends Form * * @param DoliDB $db handler */ - public function __construct($db) - { - global $langs; + public function __construct($db) + { + global $langs; - $this->db = $db; - } + $this->db = $db; + } /** * Affiche un champs select contenant une liste @@ -56,8 +56,8 @@ class FormAdvTargetEmailing extends Form * @param string $htmlname select field * @return string select field */ - public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') - { + public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') + { global $conf, $langs; $options_array = array(); @@ -84,7 +84,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return combo list of activated countries, into language of user @@ -93,8 +93,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array or Code or Label of preselected country * @return string HTML string with select */ - public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) - { + public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) + { global $conf, $langs; $langs->load("dict"); @@ -142,7 +142,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -152,14 +152,14 @@ class FormAdvTargetEmailing extends Form * @param User $user User action * @return string combo list code */ - public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) - { + public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) + { global $conf; $options_array = array(); - $sql_usr = ''; + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; @@ -183,7 +183,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -192,8 +192,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array selected array * @return string combo list code */ - public function multiselectselectLanguage($htmlname = '', $selected_array = array()) - { + public function multiselectselectLanguage($htmlname = '', $selected_array = array()) + { global $conf, $langs; @@ -208,7 +208,7 @@ class FormAdvTargetEmailing extends Form } asort($options_array); return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return multiselect list of entities for extrafeild type sellist @@ -330,14 +330,14 @@ class FormAdvTargetEmailing extends Form * @param int $showempty show empty * @return string HTML combo */ - public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) - { + public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) + { global $conf, $langs; $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; - } + } /** * Return a combo list to select emailing target selector @@ -349,8 +349,8 @@ class FormAdvTargetEmailing extends Form * @param string $morecss More CSS * @return string HTML combo */ - public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') - { + public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') + { global $conf, $user, $langs; $out = ''; @@ -390,5 +390,5 @@ class FormAdvTargetEmailing extends Form } $this->db->free($resql); return $out; - } + } } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index a4088975bd2..48c00c697a1 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -68,8 +68,8 @@ class Mailing extends CommonObject public $user_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creat; @@ -81,13 +81,13 @@ class Mailing extends CommonObject public $statuts = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { $this->db = $db; // List of language codes for status @@ -101,7 +101,7 @@ class Mailing extends CommonObject $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore - } + } /** * Create an EMailing @@ -224,8 +224,8 @@ class Mailing extends CommonObject $this->title = $obj->title; $this->sujet = $obj->sujet; - if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT|ENT_HTML5))) { - $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT|ENT_HTML5); + if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) { + $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5); } else { $this->body = $obj->body; } @@ -427,7 +427,7 @@ class Mailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete targets emailing * @@ -435,7 +435,7 @@ class Mailing extends CommonObject */ public function delete_targets() { - // phpcs:enable + // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -451,7 +451,7 @@ class Mailing extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change status of each recipient * @@ -460,7 +460,7 @@ class Mailing extends CommonObject */ public function reset_targets_status($user) { - // phpcs:enable + // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut = 0"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -485,26 +485,26 @@ class Mailing extends CommonObject */ public function countNbOfTargets($mode) { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$this->id; - if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; - elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; - elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; - else { - $this->error = 'BadValueForParameterMode'; - return -2; - } + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " WHERE fk_mailing = ".$this->id; + if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; + elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; + elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; + else { + $this->error = 'BadValueForParameterMode'; + return -2; + } - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) return $obj->nb; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - return 0; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) return $obj->nb; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + return 0; } @@ -593,7 +593,7 @@ class Mailing extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -603,7 +603,7 @@ class Mailing extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("mailing"); diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index ddcdaabf14e..8c1e392ed68 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -57,19 +57,19 @@ print '
'; //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ - // Recherche emails - print ''; - print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // Recherche emails + print ''; + print ''; + print '
'; + print '
'.$langs->trans("SearchAMailing").'
'; - print $langs->trans("Ref").':
'; - print $langs->trans("Other").':
'; + print ''; + print ''; + print ''; + print ''; - print "
'.$langs->trans("SearchAMailing").'
'; + print $langs->trans("Ref").':
'; + print $langs->trans("Other").':

\n"; + print "

\n"; //} @@ -82,63 +82,63 @@ $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) - { - $modulename = $reg[1]; - if ($modulename == 'example') continue; + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) + { + $modulename = $reg[1]; + if ($modulename == 'example') continue; - // Loading Class - $file = $dir."/".$modulename.".modules.php"; - $classname = "mailing_".$modulename; - require_once $file; - $mailmodule = new $classname($db); + // Loading Class + $file = $dir."/".$modulename.".modules.php"; + $classname = "mailing_".$modulename; + require_once $file; + $mailmodule = new $classname($db); - $qualified = 1; - foreach ($mailmodule->require_module as $key) - { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) - { - $qualified = 0; - //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; - break; - } - } + $qualified = 1; + foreach ($mailmodule->require_module as $key) + { + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) + { + $qualified = 0; + //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; + break; + } + } - // Si le module mailing est qualifi� - if ($qualified) - { - foreach ($mailmodule->getSqlArrayForStats() as $sql) - { - print ''; + // Si le module mailing est qualifi� + if ($qualified) + { + foreach ($mailmodule->getSqlArrayForStats() as $sql) + { + print ''; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); - $i = 0; + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; - $i++; - } + while ($i < $num) + { + $obj = $db->fetch_object($result); + print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + $i++; + } - $db->free($result); - } else { - dol_print_error($db); - } - print ''; - } - } - } - } - } - closedir($handle); + $db->free($result); + } else { + dol_print_error($db); + } + print ''; + } + } + } + } + } + closedir($handle); } @@ -160,42 +160,42 @@ $sql .= " ORDER BY m.date_creat DESC"; $sql .= " LIMIT ".$limit; $result = $db->query($sql); if ($result) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print '
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; - $num = $db->num_rows($result); - if ($num > 0) - { - $i = 0; + $num = $db->num_rows($result); + if ($num > 0) + { + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } else { - print ''; - } - print "
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'.$mailstatic->getNomUrl(1).''.dol_trunc($obj->title, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
'.$langs->trans("None").'

"; - $db->free($result); + print ''; + print ''.$mailstatic->getNomUrl(1).''; + print ''.dol_trunc($obj->title, 38).''; + print ''.dol_print_date($db->jdate($obj->date_creat), 'day').''; + print ''.($obj->nbemail ? $obj->nbemail : "0").''; + print ''.$mailstatic->LibStatut($obj->statut, 5).''; + print ''; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print "

"; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -204,12 +204,12 @@ print '
'; if ($langs->file_exists("html/spam.html", 0)) { - print "



".$langs->trans("Note")."
"; - print '
'; - dol_print_file($langs, "html/spam.html", 0); - print '
'; + print "



".$langs->trans("Note")."
"; + print '
'; + dol_print_file($langs, "html/spam.html", 0); + print '
'; - print '
'; + print '
'; } $parameters = array('user' => $user); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 525064942a6..9da825e262e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -60,7 +60,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre'=>'Ref', ); @@ -169,7 +169,7 @@ if ($resql) $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; @@ -190,8 +190,8 @@ if ($resql) $moreforfilter = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; print ''; @@ -1718,9 +1718,9 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } @@ -2208,21 +2208,21 @@ if ($action == 'create') print ''; } - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - if ($totalWeight) { - print ''; - print ''; - } - if ($totalVolume) { - print ''; - print ''; - } + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + if ($totalWeight) { + print ''; + print ''; + } + if ($totalVolume) { + print ''; + print ''; + } // Incoterms if (!empty($conf->incoterm->enabled)) @@ -2354,7 +2354,7 @@ if ($action == 'create') print '
'; if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { - print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index dd84fbd651a..904f33cb1eb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -166,7 +166,7 @@ if (empty($reshook)) if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference - $date_delivery = dol_mktime(12, 0, 0, + $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int') @@ -174,7 +174,7 @@ if (empty($reshook)) if (!empty($object->date_livraison) && !empty($date_delivery)) { //Attempt to get the date without possible hour rounding errors - $old_date_delivery = dol_mktime(12, 0, 0, + $old_date_delivery = dol_mktime(12, 0, 0, dol_print_date($object->date_livraison, '%m'), dol_print_date($object->date_livraison, '%d'), dol_print_date($object->date_livraison, '%Y') @@ -666,82 +666,82 @@ if (empty($reshook)) } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $user->rights->propal->creer - && $object->statut == Propal::STATUS_DRAFT - ) + && $user->rights->propal->creer + && $object->statut == Propal::STATUS_DRAFT + ) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - $situation_percent = 100; - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -890,8 +890,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) @@ -1286,8 +1286,8 @@ if (empty($reshook)) header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } elseif ($action == 'classin' && $usercancreate) { - // Set project - $object->setProject(GETPOST('projectid', 'int')); + // Set project + $object->setProject(GETPOST('projectid', 'int')); } // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); @@ -1530,7 +1530,7 @@ if ($action == 'create') if ($socid > 0) { - // Contacts (ask contact only if thirdparty already defined). + // Contacts (ask contact only if thirdparty already defined). print "
".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'.$langs->trans("CalculatedWeight").''; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedVolume").''; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedWeight").''; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print '
'.$langs->trans("CalculatedVolume").''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + print '
'; + print '
'; } if (!empty($object->lines)) @@ -2379,7 +2379,7 @@ if ($action == 'create') if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { - print '
'; + print ''; } print '
'; @@ -2535,7 +2535,7 @@ if ($action == 'create') $compatibleImportElementsList = false; if ($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e5176cebdde..602e3445ae2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1350,7 +1350,7 @@ class Propal extends CommonObject $object->id = 0; $object->ref = ''; - $object->entity = (! empty($forceentity) ? $forceentity : $object->entity); + $object->entity = (!empty($forceentity) ? $forceentity : $object->entity); $object->statut = self::STATUS_DRAFT; // Clear fields @@ -1499,14 +1499,14 @@ class Propal extends CommonObject $this->project = null; // Clear if another value was already set by fetch_projet $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->status = (int) $obj->fk_statut; - $this->statut = $this->status; // deprecated + $this->statut = $this->status; // deprecated $this->statut_libelle = $obj->statut_label; $this->datec = $this->db->jdate($obj->datec); // TODO deprecated @@ -2074,7 +2074,7 @@ class Propal extends CommonObject return $this->setDeliveryDate($user, $delivery_date, $notrigger); } - /** + /** * Set delivery date * * @param User $user Object user that modify @@ -2082,7 +2082,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function setDeliveryDate($user, $delivery_date, $notrigger = 0) + public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { if (!empty($user->rights->propal->creer)) { @@ -2141,9 +2141,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_availability($user, $id, $notrigger = 0) + public function set_availability($user, $id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error = 0; @@ -2208,9 +2208,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_demand_reason($user, $id, $notrigger = 0) + public function set_demand_reason($user, $id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error = 0; @@ -2277,9 +2277,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer)) { $error = 0; @@ -2338,9 +2338,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_remise_percent($user, $remise, $notrigger = 0) + public function set_remise_percent($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->propal->creer)) @@ -2403,9 +2403,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->propal->creer)) @@ -2470,7 +2470,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { $this->statut = $statut; @@ -2529,7 +2529,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - public function cloture($user, $status, $note = "", $notrigger = 0) + public function cloture($user, $status, $note = "", $notrigger = 0) { global $langs, $conf; @@ -2628,7 +2628,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - public function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error = 0; @@ -2682,15 +2682,15 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function setDraft($user, $notrigger = 0) + public function setDraft($user, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $error = 0; // Protection if ($this->statut <= self::STATUS_DRAFT) { - return 0; + return 0; } dol_syslog(get_class($this)."::setDraft", LOG_DEBUG); @@ -2723,10 +2723,10 @@ class Propal extends CommonObject if (!$error) { - $this->statut = self::STATUS_DRAFT; - $this->brouillon = 1; + $this->statut = self::STATUS_DRAFT; + $this->brouillon = 1; - $this->db->commit(); + $this->db->commit(); return 1; } else { foreach ($this->errors as $errmsg) @@ -2740,7 +2740,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of proposal (eventually filtered on user) into an array * @@ -2754,9 +2754,9 @@ class Propal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { - // phpcs:enable + // phpcs:enable global $user; $ga = array(); @@ -2818,7 +2818,7 @@ class Propal extends CommonObject * * @return array Array of invoices */ - public function getInvoiceArrayList() + public function getInvoiceArrayList() { return $this->InvoiceArrayList($this->id); } @@ -2830,9 +2830,9 @@ class Propal extends CommonObject * @param int $id Id propal * @return array Array of invoices id */ - public function InvoiceArrayList($id) + public function InvoiceArrayList($id) { - // phpcs:enable + // phpcs:enable $ga = array(); $linkedInvoices = array(); @@ -2912,7 +2912,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2931,9 +2931,9 @@ class Propal extends CommonObject if (!$error) { - $main = MAIN_DB_PREFIX.'propaldet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")"; + $main = MAIN_DB_PREFIX.'propaldet'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; if ($this->db->query($sqlef) && $this->db->query($sql)) { @@ -3031,7 +3031,7 @@ class Propal extends CommonObject * @return int >0 if OK, <0 if KO * @deprecated use set_availability */ - public function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -3098,9 +3098,9 @@ class Propal extends CommonObject * @return int >0 si ok, <0 si ko * @deprecated use set_demand_reason */ - public function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; if ($this->statut >= self::STATUS_DRAFT) @@ -3164,7 +3164,7 @@ class Propal extends CommonObject * @param int $id Proposal id * @return void */ - public function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -3217,12 +3217,12 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -3230,9 +3230,9 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($status, $mode = 1) + public function LibStatut($status, $mode = 1) { - // phpcs:enable + // phpcs:enable global $conf; // Init/load array of translation of status @@ -3263,7 +3263,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -3271,9 +3271,9 @@ class Propal extends CommonObject * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user, $mode) + public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $clause = " WHERE"; @@ -3354,7 +3354,7 @@ class Propal extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { global $conf, $langs; @@ -3431,7 +3431,7 @@ class Propal extends CommonObject { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; - $line->product_ref = 'SPECIMEN'; + $line->product_ref = 'SPECIMEN'; } $this->lines[$xnbp] = $line; @@ -3450,9 +3450,9 @@ class Propal extends CommonObject * * @return int <0 if ko, >0 if ok */ - public function load_state_board() + public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -3494,7 +3494,7 @@ class Propal extends CommonObject * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - public function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $langs; $langs->load("propal"); @@ -3549,10 +3549,10 @@ class Propal extends CommonObject * @param string $get_params Parametres added to url * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $addlinktonotes -1=Disable, 0=Just add label show notes, 1=Add private note (only internal user), 2=Add public note (internal or external user), 3=Add private (internal user) and public note (internal and external user) + * @param int $addlinktonotes -1=Disable, 0=Just add label show notes, 1=Add private note (only internal user), 2=Add public note (internal or external user), 3=Add private (internal user) and public note (internal and external user) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1) { global $langs, $conf, $user; @@ -3620,45 +3620,45 @@ class Propal extends CommonObject if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; - if ($addlinktonotes >= 0) { - $txttoshow = ''; + if ($addlinktonotes >= 0) { + $txttoshow = ''; - if ($addlinktonotes == 0) { - if (!empty($this->note_private) || !empty($this->note_public)) { - $txttoshow = $langs->trans('ViewPrivateNote'); - } - } elseif ($addlinktonotes == 1) { - if (!empty($this->note_private)) { - $txttoshow .= ($user->socid > 0 ? '' : dol_string_nohtmltag($this->note_private, 1)); - } - } elseif ($addlinktonotes == 2) { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - } elseif ($addlinktonotes == 3) { - if ($user->socid > 0) { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - } else { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - if (!empty($this->note_private)) { - if (!empty($txttoshow)) $txttoshow .= '

'; - $txttoshow .= dol_string_nohtmltag($this->note_private, 1); - } - } - } + if ($addlinktonotes == 0) { + if (!empty($this->note_private) || !empty($this->note_public)) { + $txttoshow = $langs->trans('ViewPrivateNote'); + } + } elseif ($addlinktonotes == 1) { + if (!empty($this->note_private)) { + $txttoshow .= ($user->socid > 0 ? '' : dol_string_nohtmltag($this->note_private, 1)); + } + } elseif ($addlinktonotes == 2) { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + } elseif ($addlinktonotes == 3) { + if ($user->socid > 0) { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + } else { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + if (!empty($this->note_private)) { + if (!empty($txttoshow)) $txttoshow .= '

'; + $txttoshow .= dol_string_nohtmltag($this->note_private, 1); + } + } + } - if ($txttoshow) { - $result .= ' '; - $result .= ''; - $result .= img_picto('', 'note'); - $result .= ''; - $result .= ''; - } - } + if ($txttoshow) { + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + $result .= ''; + } + } return $result; } @@ -3668,7 +3668,7 @@ class Propal extends CommonObject * * @return int >0 if OK, <0 if KO */ - public function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3681,7 +3681,7 @@ class Propal extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3740,68 +3740,68 @@ class PropaleLigne extends CommonObjectLine */ public $table_element = 'propaldet'; - public $oldline; + public $oldline; // From llx_propaldet - public $fk_propal; - public $fk_parent_line; - public $desc; // Description ligne - public $fk_product; // Id produit predefini + public $fk_propal; + public $fk_parent_line; + public $desc; // Description ligne + public $fk_product; // Id produit predefini /** * @deprecated * @see $product_type */ - public $fk_product_type; + public $fk_product_type; /** * Product type. * @var int * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE */ - public $product_type = Product::TYPE_PRODUCT; + public $product_type = Product::TYPE_PRODUCT; - public $qty; - public $tva_tx; - public $subprice; - public $remise_percent; - public $fk_remise_except; + public $qty; + public $tva_tx; + public $subprice; + public $remise_percent; + public $fk_remise_except; - public $rang = 0; + public $rang = 0; - public $fk_fournprice; - public $pa_ht; - public $marge_tx; - public $marque_tx; + public $fk_fournprice; + public $pa_ht; + public $marge_tx; + public $marque_tx; - public $special_code; // Tag for special lines (exlusive tags) + public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port // 2: ecotaxe // 3: option line (when qty = 0) - public $info_bits = 0; // Some other info: + public $info_bits = 0; // Some other info: // Bit 0: 0 si TVA normal - 1 si TVA NPR // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne - public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne /** * @deprecated * @see $remise_percent, $fk_remise_except */ - public $remise; + public $remise; /** * @deprecated * @see $subprice */ - public $price; + public $price; // From llx_product /** * @deprecated * @see $product_ref */ - public $ref; + public $ref; /** * Product reference * @var string @@ -3811,7 +3811,7 @@ class PropaleLigne extends CommonObjectLine * @deprecated * @see $product_label */ - public $libelle; + public $libelle; /** * Product label * @var string @@ -3823,32 +3823,32 @@ class PropaleLigne extends CommonObjectLine */ public $product_desc; - public $localtax1_tx; // Local tax 1 - public $localtax2_tx; // Local tax 2 - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type - public $total_localtax1; // Line total local tax 1 - public $total_localtax2; // Line total local tax 2 + public $localtax1_tx; // Local tax 1 + public $localtax2_tx; // Local tax 2 + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $total_localtax1; // Line total local tax 1 + public $total_localtax2; // Line total local tax 2 - public $date_start; - public $date_end; + public $date_start; + public $date_end; - public $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines // Multicurrency - public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_subprice; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -3859,7 +3859,7 @@ class PropaleLigne extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - public function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql .= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; @@ -3949,7 +3949,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf, $user; @@ -3981,7 +3981,7 @@ class PropaleLigne extends CommonObjectLine if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) @@ -4088,7 +4088,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf; @@ -4139,7 +4139,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function update($notrigger = 0) + public function update($notrigger = 0) { global $conf, $user; @@ -4147,7 +4147,7 @@ class PropaleLigne extends CommonObjectLine $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - if (empty($this->id) && ! empty($this->rowid)) $this->id = $this->rowid; + if (empty($this->id) && !empty($this->rowid)) $this->id = $this->rowid; // Clean parameters if (empty($this->tva_tx)) $this->tva_tx = 0; @@ -4265,9 +4265,9 @@ class PropaleLigne extends CommonObjectLine * * @return int <0 if KO, >0 if OK */ - public function update_total() + public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 8f71447ab0b..ca95be53fc1 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -36,18 +36,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class PropaleStats extends Stats { - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; - public $join; + public $from; + public $field; + public $where; + public $join; /** @@ -55,65 +55,65 @@ class PropaleStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param int $userid Id user for filter (creation user) + * @param int $userid Id user for filter (creation user) * @param string $mode Option ('customer', 'supplier') - * @param int $typentid Id typent of thirdpary for filter - * @param int $categid Id category of thirdpary for filter + * @param int $typentid Id typent of thirdpary for filter + * @param int $categid Id category of thirdpary for filter */ - public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer', $typentid = 0, $categid = 0) + public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer', $typentid = 0, $categid = 0) { global $user, $conf; $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); - $this->userid = $userid; - $this->join = ''; + $this->socid = ($socid > 0 ? $socid : 0); + $this->userid = $userid; + $this->join = ''; - if ($mode == 'customer') - { - $object = new Propal($this->db); + if ($mode == 'customer') + { + $object = new Propal($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date = 'p.datep'; - $this->field = 'total_ht'; - $this->field_line = 'total_ht'; + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field_date = 'p.datep'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - //$this->where .= " p.fk_statut > 0"; - } - if ($mode == 'supplier') - { - $object = new SupplierProposal($this->db); + //$this->where .= " p.fk_statut > 0"; + } + if ($mode == 'supplier') + { + $object = new SupplierProposal($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date = 'p.date_valid'; - $this->field = 'total_ht'; - $this->field_line = 'total_ht'; + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field_date = 'p.date_valid'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - //$this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed - } + //$this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed + } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; + $this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { $this->where .= " AND p.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; - if ($typentid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; - } + if ($typentid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->where .= ' AND s.fk_typent = '.$typentid; + } - if ($categid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; - $this->where .= ' AND c.rowid = '.$categid; - } + if ($categid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; + $this->where .= ' AND c.rowid = '.$categid; + } } @@ -121,21 +121,21 @@ class PropaleStats extends Stats * Return propals number by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with number by month */ - public function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); return $res; @@ -147,17 +147,17 @@ class PropaleStats extends Stats * @return array Array with number by year * */ - public function getNbByYear() + public function getNbByYear() { global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -166,21 +166,21 @@ class PropaleStats extends Stats * Return the propals amount by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ - public function getAmountByMonth($year, $format) + public function getAmountByMonth($year, $format) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); return $res; @@ -192,18 +192,18 @@ class PropaleStats extends Stats * @param int $year year for stats * @return array array with number by month */ - public function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -213,17 +213,17 @@ class PropaleStats extends Stats * * @return array Array of values */ - public function getAllByYear() + public function getAllByYear() { global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -234,23 +234,23 @@ class PropaleStats extends Stats * Return nb, amount of predefined product for year * * @param int $year Year to scan - * @param int $limit Limit + * @param int $limit Limit * @return array Array of values */ - public function getAllByProduct($year, $limit = 10) + public function getAllByProduct($year, $limit = 10) { global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; - $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; - $sql .= $this->db->order('nb', 'DESC'); - //$sql.= $this->db->plimit(20); + $sql .= $this->db->order('nb', 'DESC'); + //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 9c491c7227c..4d70b11cdfe 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -76,11 +76,11 @@ if (!$error) if ($action == 'addcontact' && $user->rights->propale->creer) { - if ($object->id > 0) - { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + if ($object->id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -100,7 +100,7 @@ elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } } // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->propale->creer) @@ -135,7 +135,7 @@ $formother = new FormOther($db); if ($object->id > 0) { - $head = propal_prepare_head($object); + $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal'); @@ -153,36 +153,36 @@ if ($object->id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 309c2a44ad4..fbe7fdbec5c 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -78,9 +78,9 @@ $object->fetch($id, $ref); if ($object->id > 0) { - $object->fetch_thirdparty(); - $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; + $object->fetch_thirdparty(); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -122,36 +122,36 @@ if ($object->id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 692f561867a..b51f138b0e5 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -154,7 +154,7 @@ if ($resql) } } - if ($conf->use_javascript_ajax) { + if ($conf->use_javascript_ajax) { print ''; print ''; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index e56a5129c5c..cf63d919f62 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -46,8 +46,8 @@ $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); if (!$object->fetch($id, $ref) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } @@ -82,36 +82,36 @@ $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->ge // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 80b991a2526..06be1179fb1 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -75,7 +75,7 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch_thirdparty() > 0) { - $head = propal_prepare_head($object); + $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal'); $cssclass = 'titlefield'; @@ -97,36 +97,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index e439056de5f..8b9c6b34dee 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -50,8 +50,8 @@ $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); @@ -77,19 +77,19 @@ $langs->loadLangs(array('propal', 'other', 'companies')); if ($mode == 'customer') { - $picto = 'propal'; - $title = $langs->trans("ProposalsStatistics"); - $dir = $conf->propale->dir_temp; - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $picto = 'propal'; + $title = $langs->trans("ProposalsStatistics"); + $dir = $conf->propale->dir_temp; + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { $picto = 'supplier_proposal'; - $title = $langs->trans("ProposalsStatisticsSuppliers"); - $dir = $conf->supplier_proposal->dir_temp; - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); + $title = $langs->trans("ProposalsStatisticsSuppliers"); + $dir = $conf->supplier_proposal->dir_temp; + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } llxHeader('', $title); @@ -110,36 +110,36 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfProposals")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfProposals")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -148,36 +148,36 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, 0); if (!$user->rights->societe->client->voir || $user->socid) { - $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; + $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfProposals")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); + $px2->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfProposals")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); @@ -185,38 +185,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); $fileurl_avg = ''; if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -260,23 +260,23 @@ print '
'; $filter = 's.client IN (1,2,3)'; print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print ''; - // ThirdParty Type - print ''.$langs->trans("ThirdPartyType").''; - $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. - print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; - // Category - print ''.$cat_label.''; - print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); - print ''; + // ThirdParty Type + print ''.$langs->trans("ThirdPartyType").''; + $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. + print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; + // Category + print ''.$cat_label.''; + print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); + print ''; // User print ''.$langs->trans("CreatedBy").''; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; // Status print ''.$langs->trans("Status").''; - $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); + $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); print ''; // Year print ''.$langs->trans("Year").''; @@ -306,31 +306,31 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while (!empty($year) && $oldyear > $year + 1) - { // If we have empty year - $oldyear--; + $year = $val['year']; + while (!empty($year) && $oldyear > $year + 1) + { // If we have empty year + $oldyear--; - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; - print '0'; - print ''; - print '0'; - print ''; - print '0'; - print ''; - print ''; - } - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$year.''; - print ''.$val['nb'].''; + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; + print '0'; + print ''; + print '0'; + print ''; + print '0'; + print ''; + print ''; + } + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$year.''; + print ''.$val['nb'].''; print ''.round($val['nb_diff']).''; - print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['total'], 'MT'), 1).''; print ''.round($val['total_diff']).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; print ''.round($val['avg_diff']).''; - print ''; - $oldyear = $year; + print ''; + $oldyear = $year; } print ''; @@ -342,11 +342,11 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); - print "
\n"; - print $px3->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 160ae657ce9..300b35cc868 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -25,8 +25,8 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { - print "Error, template page can't be called as URL"; - exit; + print "Error, template page can't be called as URL"; + exit; } @@ -46,42 +46,42 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; - print ''; - print ''.$langs->trans("Proposal"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) - { - $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; - print ' '; - } - print ''; - print ''.$objectlink->getNomUrl(1).''; - print ''.$objectlink->ref_client.''; - print ''.dol_print_date($objectlink->date, 'day').''; - print ''; - if ($user->rights->propale->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + print ''; + print ''.$langs->trans("Proposal"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + { + $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; + print ' '; } - print ''; - print ''.$objectlink->getLibStatut(3).''; - print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - print "\n"; + print ''; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date, 'day').''; + print ''; + if ($user->rights->propale->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + print ''; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - print ''; - print ''.$langs->trans("Total").''; - print ''; - print ''; - print ''; - print ''.price($total).''; - print ''; - print ''; - print "\n"; + print ''; + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''; + print ''.price($total).''; + print ''; + print ''; + print "\n"; } print "\n"; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index d99b3509b26..7ae61362f09 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -206,11 +206,11 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.''; print ""; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - print $companystatic->getNomUrl(1, '', 44); + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + print $companystatic->getNomUrl(1, '', 44); print "\n"; print ""; print dol_print_date($db->jdate($obj->dp), 'day')."\n"; @@ -257,11 +257,11 @@ if ($resql) $obj = $db->fetch_object($resql); print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - print $companystatic->getNomUrl(1, 'prospect', 44); + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + print $companystatic->getNomUrl(1, 'prospect', 44); print ''; $i++; } diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index 6302b7680ab..1acf2cbf218 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -34,8 +34,8 @@ if (!empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } @@ -48,38 +48,38 @@ llxHeader(); if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); + $societe = new Societe($db); + $societe->fetch($socid); - /* + /* * Affichage onglets */ $head = societe_prepare_head($societe); - print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); + print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); - print "\n"; - print '
'; + print "\n"; + print '
'; - print ''; + print '
'; - // Name - print ''; + // Name + print ''; // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } - print "
'.$langs->trans("Thirdpary").''.$societe->getNomUrl(1).'
'.$langs->trans("Thirdpary").''.$societe->getNomUrl(1).'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm ? $societe->prefix_comm : ' '); - print '
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm ? $societe->prefix_comm : ' '); + print '
"; + print "
"; - print "
\n"; + print "\n"; - print '
'; + print '
'; print $langs->trans("FeatureNotYetAvailable"); diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 9ac8062c156..254305a9443 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -34,8 +34,8 @@ if (!empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } @@ -48,38 +48,38 @@ llxHeader(); if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); + $societe = new Societe($db); + $societe->fetch($socid); - /* + /* * Affichage onglets */ $head = societe_prepare_head($societe); - print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); + print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); - print "\n"; - print '
'; + print "\n"; + print '
'; - print ''; + print '
'; - // Name - print ''; + // Name + print ''; - // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + // Prefix + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } - print "
'.$langs->trans("ThirdParty").''.$societe->getNomUrl(1).'
'.$langs->trans("ThirdParty").''.$societe->getNomUrl(1).'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm ? $societe->prefix_comm : ' '); - print '
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm ? $societe->prefix_comm : ' '); + print '
"; + print "
"; - print "
\n"; + print "\n"; - print '
'; + print '
'; print $langs->trans("FeatureNotYetAvailable"); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 21f06e7bc1d..34ac6229ac1 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -47,8 +47,8 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; + header("Location: ".$backtopage); + exit; } if (GETPOST('action', 'aZ09') == 'setremise') @@ -66,14 +66,14 @@ if (GETPOST('action', 'aZ09') == 'setremise') if ($result > 0) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: remise.php?id=".$_GET["id"]); - exit; - } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } else { + header("Location: remise.php?id=".$_GET["id"]); + exit; + } } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -108,28 +108,28 @@ if ($socid > 0) print '
'; print ''; print ''; - print ''; + print ''; print dol_get_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; - if (!$isCustomer && !$isSupplier) { - print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; + if (!$isCustomer && !$isSupplier) { + print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - // End of page - llxFooter(); - $db->close(); - exit; - } + // End of page + llxFooter(); + $db->close(); + exit; + } print ''; @@ -172,7 +172,7 @@ if ($socid > 0) print ''; } if ($isSupplier) { - print ' '; + print ' '; } print ''; } @@ -193,11 +193,11 @@ if ($socid > 0) print '
'; print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } + if (!empty($backtopage)) + { + print '     '; + print ''; + } print '
'; print ""; @@ -234,22 +234,22 @@ if ($socid > 0) print ''; print ''; $num = $db->num_rows($resql); - if ($num > 0) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } } else { - print ''; + print ''; } $db->free($resql); print "
'.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc), "dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'
'.dol_print_date($db->jdate($obj->dc), "dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'
'.$langs->trans("None").'
'.$langs->trans("None").'
"; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 922e384af4d..98aa79161fb 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -52,8 +52,8 @@ if ($user->socid > 0) if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; + header("Location: ".$backtopage); + exit; } if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') @@ -138,8 +138,8 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') $db->begin(); $discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source - // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source - $discount->fk_invoice_supplier_source = 0; + // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source + $discount->fk_invoice_supplier_source = 0; $res = $discount->delete($user); $newid1 = $newdiscount1->create($user); $newid2 = $newdiscount2->create($user); @@ -181,13 +181,13 @@ if ($action == 'setremise' && $user->rights->societe->creer) if ($discountid > 0) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage.'&discountid='.$discountid); - exit; - } else { - header("Location: remx.php?id=".$id); - exit; + if (!empty($backtopage)) + { + header("Location: ".$backtopage.'&discountid='.$discountid); + exit; + } else { + header("Location: remx.php?id=".$id); + exit; } } else { $error++; @@ -248,27 +248,27 @@ if ($socid > 0) print '
'; print ''; print ''; - print ''; + print ''; print dol_get_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; - if (!$isCustomer && !$isSupplier) { - print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; + if (!$isCustomer && !$isSupplier) { + print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - llxFooter(); - $db->close(); - exit; - } + llxFooter(); + $db->close(); + exit; + } print ''; @@ -298,7 +298,7 @@ if ($socid > 0) if (!empty($user->fk_soc)) // No need to show this for external users { print ''; - print ''; + print ''; } } @@ -341,56 +341,56 @@ if ($socid > 0) if ($user->rights->societe->creer) { - print '
'; + print '
'; - print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); + print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); - if ($isCustomer && !$isSupplier) { - print ''; - } + if ($isCustomer && !$isSupplier) { + print ''; + } - if (!$isCustomer && $isSupplier) { - print ''; - } + if (!$isCustomer && $isSupplier) { + print ''; + } - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print '
'.$langs->trans("CustomerAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'; + print '
'; if ($isCustomer && $isSupplier) { print ''; print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print "
'.$langs->trans('DiscountType').' '; print '   '; print '
'.$langs->trans("AmountHT").''; - print ' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("VAT").''; - print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); - print '
'.$langs->trans("NoteReason").'
'.$langs->trans("AmountHT").''; + print ' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("VAT").''; + print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); + print '
'.$langs->trans("NoteReason").'
"; + print ""; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if ($user->rights->societe->creer) { - print '
'; - print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } - print '
'; - } + print '
'; + print ''; + if (!empty($backtopage)) + { + print '     '; + print ''; + } + print '
'; + } - print ''; + print ''; print '
'; @@ -441,13 +441,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("DiscountOfferedBy").''; print ' '; @@ -459,76 +459,76 @@ if ($socid > 0) $num = $db->num_rows($resql); if ($num > 0) { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; - if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } else { - print ''; - print $obj->description; - print ''; - } - print ''.$langs->trans("NotConsumed").''; - print ''.price($obj->amount_ht).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ht).''; - } - print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ttc).''; - } - print ''; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; - print ''; - if ($user->rights->societe->creer || $user->rights->facture->creer) - { - print ''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; - print ''; - } else print ' '; - print ''; + print ''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } else { + print ''; + print $obj->description; + print ''; + } + print ''.$langs->trans("NotConsumed").''; + print ''.price($obj->amount_ht).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ht).''; + } + print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; + print ''.price($obj->amount_ttc).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ttc).''; + } + print ''; + print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + print ''; + if ($user->rights->societe->creer || $user->rights->facture->creer) + { + print ''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print ''; + } else print ' '; + print ''; - if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) - { - $showconfirminfo['rowid'] = $obj->rowid; - $showconfirminfo['amount_ttc'] = $obj->amount_ttc; - } - $i++; - } + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) + { + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; + } + $i++; + } } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } $db->free($resql); print ""; @@ -589,13 +589,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("DiscountOfferedBy").''; print ' '; @@ -646,13 +646,13 @@ if ($socid > 0) print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; @@ -770,13 +770,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("Author").''; print ' '; @@ -787,12 +787,12 @@ if ($socid > 0) $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0; $i < $num; $i++) - { - $sqlobj = $db->fetch_object($resql); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); - } + for ($i = 0; $i < $num; $i++) + { + $sqlobj = $db->fetch_object($resql); + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); + } } $db->free($resql); @@ -809,69 +809,69 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0; - while ($i < $num) - { - $obj = array_shift($tab_sqlobj); - print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; - if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } else { - print ''; - print $obj->description; - print ''; - } - print ''; - if ($obj->invoiceid) - { - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; - } - print ''; - print ''.price($obj->amount_ht).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ht).''; - } - print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ttc).''; - } - print ''; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; - print ''; - print ' '; - print ''; - $i++; - } + $i = 0; + while ($i < $num) + { + $obj = array_shift($tab_sqlobj); + print ''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } else { + print ''; + print $obj->description; + print ''; + } + print ''; + if ($obj->invoiceid) + { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; + print ''.price($obj->amount_ht).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ht).''; + } + print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; + print ''.price($obj->amount_ttc).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ttc).''; + } + print ''; + print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + print ''; + print ' '; + print ''; + $i++; + } } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; @@ -940,13 +940,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("Author").''; print ' '; @@ -1022,13 +1022,13 @@ if ($socid > 0) print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 901a0f6f385..b1194edd965 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -537,14 +537,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setdate_livraison' && $usercancreate) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); - $object->fetch($id); - $result = $object->setDeliveryDate($user, $datedelivery); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $object->fetch($id); + $result = $object->setDeliveryDate($user, $datedelivery); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fdc9ddaf646..5934dc066a3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1357,7 +1357,7 @@ class Commande extends CommonOrder $this->shipping_method_id = $object->shipping_method_id; $this->warehouse_id = $object->warehouse_id; $this->fk_delivery_address = $object->fk_delivery_address; - $this->contact_id = $object->contact_id; + $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) @@ -1848,7 +1848,7 @@ class Commande extends CommonOrder $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index c9dc5eaffa8..57f8147cd57 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -35,18 +35,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class CommandeStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; - public $join; + public $from; + public $field; + public $where; + public $join; /** @@ -56,8 +56,8 @@ class CommandeStats extends Stats * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) - * @param int $typentid Id typent of thirdpary for filter - * @param int $categid Id category of thirdpary for filter + * @param int $typentid Id typent of thirdpary for filter + * @param int $categid Id category of thirdpary for filter */ public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) { @@ -66,9 +66,9 @@ class CommandeStats extends Stats $this->db = $db; $this->socid = ($socid > 0 ? $socid : 0); - $this->userid = $userid; + $this->userid = $userid; $this->cachefilesuffix = $mode; - $this->join = ''; + $this->join = ''; if ($mode == 'customer') { @@ -88,34 +88,34 @@ class CommandeStats extends Stats //$this->where .= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where .= ($this->where ? ' AND ' : ''). 'c.entity IN ('.getEntity('commande').')'; + $this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')'; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; - if ($typentid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; - } + if ($typentid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; + $this->where .= ' AND s.fk_typent = '.$typentid; + } - if ($categid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; - $this->where .= ' AND cat.rowid = '.$categid; - } + if ($categid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; + $this->where .= ' AND cat.rowid = '.$categid; + } } /** * Return orders number by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with number by month */ public function getNbByMonth($year, $format = 0) @@ -125,11 +125,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); return $res; @@ -148,10 +148,10 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -160,7 +160,7 @@ class CommandeStats extends Stats * Return the orders amount by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ public function getAmountByMonth($year, $format = 0) @@ -170,11 +170,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); return $res; @@ -193,11 +193,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -214,10 +214,10 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -226,7 +226,7 @@ class CommandeStats extends Stats * Return nb, amount of predefined product for year * * @param int $year Year to scan - * @param int $limit Limit + * @param int $limit Limit * @return array Array of values */ public function getAllByProduct($year, $limit = 10) @@ -236,14 +236,14 @@ class CommandeStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; - $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; - $sql .= $this->db->order('nb', 'DESC'); - //$sql.= $this->db->plimit(20); + $sql .= $this->db->order('nb', 'DESC'); + //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql, $limit); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 84c4eb5626a..a3c31d4cf7b 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -53,11 +53,11 @@ if ($action == 'addcontact' && $user->rights->commande->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -79,7 +79,7 @@ elseif ($action == 'swapstatut' && $user->rights->commande->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) if ($object->fetch($id, $ref) > 0) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); $head = commande_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); @@ -150,40 +150,40 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); @@ -196,8 +196,8 @@ if ($id > 0 || !empty($ref)) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; } } else { // Contact not found diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index c3afff9e00d..f95f61b6025 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -107,7 +107,7 @@ if ($id > 0 || !empty($ref)) $totalsize = 0; foreach ($filearray as $key => $file) { - $totalsize += $file['size']; + $totalsize += $file['size']; } // Order card @@ -124,36 +124,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 96476caeeed..4a18f96ddde 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -71,15 +71,15 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search customer orders - print '
'; - print ''; - print '
'; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'; - print $langs->trans("CustomerOrder").':

\n"; + // Search customer orders + print '
'; + print ''; + print '
'; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("CustomerOrder").':

\n"; } @@ -100,81 +100,81 @@ $sql .= " GROUP BY c.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $total = 0; - $totalinprocess = 0; - $dataseries = array(); - $colorseries = array(); - $vals = array(); - // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { - $row = $db->fetch_row($resql); - if ($row) - { - //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) - { - if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; - $vals[$row[1]] += $row[0]; - $totalinprocess += $row[0]; - } - $total += $row[0]; - } - $i++; - } - $db->free($resql); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); + // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; + $vals[$row[1]] += $row[0]; + $totalinprocess += $row[0]; + } + $total += $row[0]; + } + $i++; + } + $db->free($resql); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - print '
'; - print ''; - print ''."\n"; - $listofstatus = array(0, 1, 2, 3, -1); - foreach ($listofstatus as $status) - { - $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; - if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; - if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; - if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + print '
'; + print '
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'; + print ''."\n"; + $listofstatus = array(0, 1, 2, 3, -1); + foreach ($listofstatus as $status) + { + $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; + if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) - { - print ''; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; - } + print ''; + } - //if ($totalinprocess != $total) - print ''; - print "
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; - print $commandestatic->LibStatut($status, 0, 3, 1); - print '
'; + if (empty($conf->use_javascript_ajax)) + { + print '
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; + print $commandestatic->LibStatut($status, 0, 3, 1); + print '
'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''.$total.'

"; + //if ($totalinprocess != $total) + print ''.$langs->trans("Total").''.$total.''; + print "

"; } else { - dol_print_error($db); + dol_print_error($db); } @@ -184,9 +184,9 @@ if ($resql) if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -199,7 +199,7 @@ if (!empty($conf->commande->enabled)) $resql = $db->query($sql); if ($resql) { - print '
'; + print '
'; print ''; print ''; print ''; @@ -212,8 +212,8 @@ if (!empty($conf->commande->enabled)) { $obj = $db->fetch_object($resql); - $commandestatic->id = $obj->rowid; - $commandestatic->ref = $obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -224,10 +224,10 @@ if (!empty($conf->commande->enabled)) print ''; print '"; - print '"; + print ''; + print ''; $i++; } } else { @@ -266,7 +266,7 @@ $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { - print '
'; + print '
'; print '
'.$langs->trans("DraftOrders").'
'; print $commandestatic->getNomUrl(1); - print "'; + print "'; print $companystatic->getNomUrl(1, 'company', 16); - print '
'; print ''; print ''; @@ -310,8 +310,8 @@ if ($resql) print ''; print ''; + print $companystatic->getNomUrl(1, 'company', 16); + print ''; print ''; print ''; print ''; @@ -329,9 +329,9 @@ $max = 10; if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -347,7 +347,7 @@ if (!empty($conf->commande->enabled)) { $num = $db->num_rows($resql); - print '
'; + print '
'; print '
'.$langs->trans("LastModifiedOrders", $max).'
'; - print $companystatic->getNomUrl(1, 'company', 16); - print ''.dol_print_date($db->jdate($obj->datem), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
'; print ''; print ''; @@ -389,10 +389,10 @@ if (!empty($conf->commande->enabled)) print ''; print ''; + print $companystatic->getNomUrl(1, 'company', 24); + print ''; - print ''."\n"; + print ''."\n"; print ''; @@ -414,9 +414,9 @@ if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -432,7 +432,7 @@ if (!empty($conf->commande->enabled)) { $num = $db->num_rows($resql); - print '
'; + print '
'; print '
'.$langs->trans("OrdersToProcess").' '.$num.'
'; - print $companystatic->getNomUrl(1, 'company', 24); - print ''.dol_print_date($db->jdate($obj->date), 'day').''.dol_print_date($db->jdate($obj->date), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
'; print ''; print ''; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index dd31e547569..117afab2398 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -48,8 +48,8 @@ $result = restrictedArea($user, 'commande', $comid, ''); $object = new Commande($db); if (!$object->fetch($id, $ref) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } @@ -80,36 +80,36 @@ $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->ge // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index cb9e06a5549..e9c379c9327 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -140,9 +140,9 @@ $checkedtypetiers = 0; $arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1), 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), @@ -161,7 +161,7 @@ $arrayfields = array( 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -488,7 +488,7 @@ if ($resql) 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'cancelorders'=>$langs->trans("Cancel"), - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), ); if ($user->rights->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); @@ -670,7 +670,7 @@ if ($resql) // Project title if (!empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } // Thirpdarty if (!empty($arrayfields['s.nom']['checked'])) @@ -923,13 +923,13 @@ if ($resql) $text_warning = ''; $nbprod = 0; - $companystatic->id = $obj->socid; + $companystatic->id = $obj->socid; $companystatic->code_client = $obj->code_client; $companystatic->name = $obj->name; $companystatic->client = $obj->client; $companystatic->email = $obj->email; if (!isset($getNomUrl_cache[$obj->socid])) { - $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); } $generic_commande->id = $obj->rowid; @@ -1087,7 +1087,7 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; @@ -1096,13 +1096,13 @@ if ($resql) // Project label if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } // Third party diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index c996aea7601..0cf0da709da 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -93,36 +93,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= ''; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 1da32f13e80..54846a32852 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -51,8 +51,8 @@ $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); @@ -81,8 +81,8 @@ $dir = $conf->commande->dir_temp; if ($mode == 'supplier') { $picto = 'supplier_order'; - $title = $langs->trans("OrdersStatisticsSuppliers"); - $dir = $conf->fournisseur->commande->dir_temp; + $title = $langs->trans("OrdersStatisticsSuppliers"); + $dir = $conf->fournisseur->commande->dir_temp; } llxHeader('', $title); @@ -111,38 +111,38 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; + if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; + if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfOrder")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfOrder")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -152,38 +152,38 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; + $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; + if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; + if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfOrders")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); + $px2->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfOrders")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } @@ -191,38 +191,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -277,13 +277,13 @@ print ''; // Category if ($mode == 'customer') { - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Supplier").' '.lcfirst($langs->trans("Customer")); + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Supplier").' '.lcfirst($langs->trans("Customer")); } print ''; // Year @@ -376,11 +376,11 @@ print '
'; // Show graphs print '
'.$langs->trans("OnProcessOrders").' '.$num.'
'; if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); + print $projectstatic->getNomUrl(1); } print ''; - if ($obj->project_id > 0) - { - print $projectstatic->title; - } - print ''; + if ($obj->project_id > 0) + { + print $projectstatic->title; + } + print '
'.$cat_label.''; print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); @@ -295,18 +295,18 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0 print '
'.$langs->trans("Status").''; if ($mode == 'customer') { - $liststatus = array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSent"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") - ); - print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSent"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") + ); + print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); } if ($mode == 'supplier') { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); + $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); } print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); - print "
\n"; - print $px3->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index a593e10adf4..a9c01386bf7 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -40,44 +40,44 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; - echo ''; - echo ''.$langs->trans("CustomerOrder"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' '; - echo ''.$objectlink->getNomUrl(1).''; - echo ''.$objectlink->ref_client.''; - echo ''.dol_print_date($objectlink->date, 'day').''; - echo ''; - if ($user->rights->commande->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } - echo ''; - echo ''.$objectlink->getLibStatut(3).''; - echo ''; - // For now, shipments must stay linked to order, so link is not deletable - if ($object->element != 'shipping') { - echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - } - echo ''; - echo "\n"; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + echo ''; + echo ''.$langs->trans("CustomerOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + print ' '; + echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->ref_client.''; + echo ''.dol_print_date($objectlink->date, 'day').''; + echo ''; + if ($user->rights->commande->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + echo ''; + echo ''.$objectlink->getLibStatut(3).''; + echo ''; + // For now, shipments must stay linked to order, so link is not deletable + if ($object->element != 'shipping') { + echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + } + echo ''; + echo "\n"; } if (count($linkedObjectBlock) > 1) { - echo ''; - echo ''.$langs->trans("Total").''; - echo ''; - echo ''; - echo ''; - echo ''.price($total).''; - echo ''; - echo ''; - echo "\n"; + echo ''; + echo ''.$langs->trans("Total").''; + echo ''; + echo ''; + echo ''; + echo ''.price($total).''; + echo ''; + echo ''; + echo "\n"; } echo "\n"; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index ac31d091833..3b135637a25 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -19,10 +19,10 @@ */ /** - * \file htdocs/compta/accounting-files.php - * \ingroup compta - * \brief Page to show portoflio and files of a thirdparty and download it - */ + * \file htdocs/compta/accounting-files.php + * \ingroup compta + * \brief Page to show portoflio and files of a thirdparty and download it + */ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); @@ -79,8 +79,8 @@ if (!$sortorder) $sortorder = "DESC"; $arrayfields = array( - 'type'=>array('label'=>"Type", 'checked'=>1), - 'date'=>array('label'=>"Date", 'checked'=>1), + 'type'=>array('label'=>"Type", 'checked'=>1), + 'date'=>array('label'=>"Date", 'checked'=>1), 'date_due'=>array('label'=>"DateDue", 'checked'=>1), 'ref'=>array('label'=>"Ref", 'checked'=>1), 'documents'=>array('label'=>"Documents", 'checked'=>1), @@ -93,10 +93,10 @@ $arrayfields = array( // Security check if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { - accessforbidden(); + accessforbidden(); } if ($user->socid > 0) { - accessforbidden(); + accessforbidden(); } // Define $arrayofentities if multientity is set. @@ -150,242 +150,242 @@ if (($action == 'searchfiles' || $action == 'dl')) { if (GETPOST('selectinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; } - // Vendor invoices + // Vendor invoices if (GETPOST('selectsupplierinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; } - // Expense reports + // Expense reports if (GETPOST('selectexpensereports')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE date_fin between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE date_fin between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; } - // Donations + // Donations if (GETPOST('selectdonations')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; - $sql .= " WHERE datedon between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; + $sql .= " WHERE datedon between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; } - // Payments of salaries + // Payments of salaries if (GETPOST('selectpaymentsofsalaries')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; } - // Social contributions + // Social contributions if (GETPOST('selectsocialcontributions')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql .= " WHERE t.date_ech between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql .= " WHERE t.date_ech between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; } - // Various payments + // Various payments if (GETPOST('selectvariouspayment')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; } - // Loan payments + // Loan payments if (GETPOST('selectloanspayment')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; } if ($sql) { - $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); //print $sql; - $resd = $db->query($sql); - $files = array(); - $link = ''; + $resd = $db->query($sql); + $files = array(); + $link = ''; - if ($resd) - { - $numd = $db->num_rows($resd); + if ($resd) + { + $numd = $db->num_rows($resd); - $tmpinvoice = new Facture($db); - $tmpinvoicesupplier = new FactureFournisseur($db); - $tmpdonation = new Don($db); + $tmpinvoice = new Facture($db); + $tmpinvoicesupplier = new FactureFournisseur($db); + $tmpdonation = new Don($db); - $upload_dir = ''; - $i = 0; - while ($i < $numd) - { - $objd = $db->fetch_object($resd); + $upload_dir = ''; + $i = 0; + while ($i < $numd) + { + $objd = $db->fetch_object($resd); - switch ($objd->item) - { - case "Invoice": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture"; - break; - case "SupplierInvoice": - $tmpinvoicesupplier->fetch($objd->id); - $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture_fournisseur"; - break; - case "ExpenseReport": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "expensereport"; - break; - case "SalaryPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "salaries"; - break; - case "Donation": - $tmpdonation->fetch($objp->id); - $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output.'/'.$subdir; - $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "don"; - break; - case "SocialContributions": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output.'/'.$subdir; - $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "tax"; - break; - case "VariousPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->bank->dir_output.'/'.$subdir; - $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "banque"; - break; - case "LoanPayment": - // Loan payment has no linked file - $subdir = ''; - $upload_dir = $conf->loan->dir_output.'/'.$subdir; - $link = ""; - $modulepart = ""; - break; - default: - $subdir = ''; - $upload_dir = ''; - $link = ''; - break; - } + switch ($objd->item) + { + case "Invoice": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture"; + break; + case "SupplierInvoice": + $tmpinvoicesupplier->fetch($objd->id); + $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture_fournisseur"; + break; + case "ExpenseReport": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "expensereport"; + break; + case "SalaryPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "salaries"; + break; + case "Donation": + $tmpdonation->fetch($objp->id); + $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output.'/'.$subdir; + $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "don"; + break; + case "SocialContributions": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output.'/'.$subdir; + $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "tax"; + break; + case "VariousPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->bank->dir_output.'/'.$subdir; + $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "banque"; + break; + case "LoanPayment": + // Loan payment has no linked file + $subdir = ''; + $upload_dir = $conf->loan->dir_output.'/'.$subdir; + $link = ""; + $modulepart = ""; + break; + default: + $subdir = ''; + $upload_dir = ''; + $link = ''; + break; + } - if (!empty($upload_dir)) - { - $result = true; + if (!empty($upload_dir)) + { + $result = true; - $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - //var_dump($upload_dir); - //var_dump($files); - if (count($files) < 1) - { - $nofile = array(); - $nofile['id'] = $objd->id; - $nofile['entity'] = $objd->entity; - $nofile['date'] = $db->idate($objd->date); - $nofile['date_due'] = $db->idate($objd->date_due); - $nofile['paid'] = $objd->paid; - $nofile['amount_ht'] = $objd->total_ht; - $nofile['amount_ttc'] = $objd->total_ttc; - $nofile['amount_vat'] = $objd->total_vat; - $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $nofile['fk'] = $objd->fk_soc; - $nofile['item'] = $objd->item; - $nofile['thirdparty_name'] = $objd->thirdparty_name; - $nofile['thirdparty_code'] = $objd->thirdparty_code; - $nofile['country_code'] = $objd->country_code; - $nofile['vatnum'] = $objd->vatnum; - $nofile['sens'] = $objd->sens; + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + //var_dump($upload_dir); + //var_dump($files); + if (count($files) < 1) + { + $nofile = array(); + $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; + $nofile['date'] = $db->idate($objd->date); + $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['paid'] = $objd->paid; + $nofile['amount_ht'] = $objd->total_ht; + $nofile['amount_ttc'] = $objd->total_ttc; + $nofile['amount_vat'] = $objd->total_vat; + $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $nofile['fk'] = $objd->fk_soc; + $nofile['item'] = $objd->item; + $nofile['thirdparty_name'] = $objd->thirdparty_name; + $nofile['thirdparty_code'] = $objd->thirdparty_code; + $nofile['country_code'] = $objd->country_code; + $nofile['vatnum'] = $objd->vatnum; + $nofile['sens'] = $objd->sens; - $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; - } else { - foreach ($files as $key => $file) - { - $file['id'] = $objd->id; - $file['entity'] = $objd->entity; - $file['date'] = $db->idate($objd->date); - $file['date_due'] = $db->idate($objd->date_due); - $file['paid'] = $objd->paid; - $file['amount_ht'] = $objd->total_ht; - $file['amount_ttc'] = $objd->total_ttc; - $file['amount_vat'] = $objd->total_vat; - $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $file['fk'] = $objd->fk_soc; - $file['item'] = $objd->item; - $file['thirdparty_name'] = $objd->thirdparty_name; - $file['thirdparty_code'] = $objd->thirdparty_code; - $file['country_code'] = $objd->country_code; - $file['vatnum'] = $objd->vatnum; - $file['sens'] = $objd->sens; + $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; + } else { + foreach ($files as $key => $file) + { + $file['id'] = $objd->id; + $file['entity'] = $objd->entity; + $file['date'] = $db->idate($objd->date); + $file['date_due'] = $db->idate($objd->date_due); + $file['paid'] = $objd->paid; + $file['amount_ht'] = $objd->total_ht; + $file['amount_ttc'] = $objd->total_ttc; + $file['amount_vat'] = $objd->total_vat; + $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $file['fk'] = $objd->fk_soc; + $file['item'] = $objd->item; + $file['thirdparty_name'] = $objd->thirdparty_name; + $file['thirdparty_code'] = $objd->thirdparty_code; + $file['country_code'] = $objd->country_code; + $file['vatnum'] = $objd->vatnum; + $file['sens'] = $objd->sens; - // Save record into array (only the first time it is found) - if (empty($filesarray[$file['item'].'_'.$file['id']])) { - $filesarray[$file['item'].'_'.$file['id']] = $file; - } + // Save record into array (only the first time it is found) + if (empty($filesarray[$file['item'].'_'.$file['id']])) { + $filesarray[$file['item'].'_'.$file['id']] = $file; + } - // Add or concat file - if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { - $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); - } - $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( - 'link' => $link.urlencode($file['name']), - 'name'=>$file['name'], - 'ref'=>$file['ref'], - 'fullname' => $file['fullname'], - 'relpath' => '/'.$file['name'], - 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], - 'modulepart' => $modulepart, - 'subdir' => $subdir, - ); - //var_dump($file['item'].'_'.$file['id']); - //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); - } - } - } + // Add or concat file + if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { + $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); + } + $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( + 'link' => $link.urlencode($file['name']), + 'name'=>$file['name'], + 'ref'=>$file['ref'], + 'fullname' => $file['fullname'], + 'relpath' => '/'.$file['name'], + 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], + 'modulepart' => $modulepart, + 'subdir' => $subdir, + ); + //var_dump($file['item'].'_'.$file['id']); + //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); + } + } + } - $i++; - } - } else { - dol_print_error($db); - } + $i++; + } + } else { + dol_print_error($db); + } - $db->free($resd); + $db->free($resd); } else { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors'); $error++; @@ -414,81 +414,81 @@ if ($result && $action == "dl" && !$error) exit; } - dol_mkdir($dirfortmpfile); + dol_mkdir($dirfortmpfile); - $log = $langs->transnoentitiesnoconv("Type"); - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - $log .= ','.$langs->transnoentitiesnoconv("Entity"); - } - $log .= ','.$langs->transnoentitiesnoconv("Date"); - $log .= ','.$langs->transnoentitiesnoconv("DateDue"); - $log .= ','.$langs->transnoentitiesnoconv("Ref"); - $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); - $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); - $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); - $log .= ','.$langs->transnoentitiesnoconv("Paid"); - $log .= ','.$langs->transnoentitiesnoconv("Document"); - $log .= ','.$langs->transnoentitiesnoconv("ItemID"); - $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); - $log .= ','.$langs->transnoentitiesnoconv("Code"); - $log .= ','.$langs->transnoentitiesnoconv("Country"); - $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); - $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } + $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("DateDue"); + $log .= ','.$langs->transnoentitiesnoconv("Ref"); + $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); + $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); + $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); + $log .= ','.$langs->transnoentitiesnoconv("Paid"); + $log .= ','.$langs->transnoentitiesnoconv("Document"); + $log .= ','.$langs->transnoentitiesnoconv("ItemID"); + $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); + $log .= ','.$langs->transnoentitiesnoconv("Code"); + $log .= ','.$langs->transnoentitiesnoconv("Country"); + $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); + $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; - dol_delete_file($zipname); + dol_delete_file($zipname); - $zip = new ZipArchive; - $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); - if ($res) - { - foreach ($filesarray as $key => $file) - { - if (!empty($file['files'])) { - foreach ($file['files'] as $filecursor) { - if (file_exists($filecursor["fullname"])) { - $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); - } - } - } + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res) + { + foreach ($filesarray as $key => $file) + { + if (!empty($file['files'])) { + foreach ($file['files'] as $filecursor) { + if (file_exists($filecursor["fullname"])) { + $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); + } + } + } - $log .= '"'.$langs->trans($file['item']).'"'; - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; - } - $log .= ','.dol_print_date($file['date'], 'dayrfc'); - $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); - $log .= ',"'.$file['ref'].'"'; - $log .= ','.$file['amount_ht']; - $log .= ','.$file['amount_ttc']; - $log .= ','.$file['amount_vat']; - $log .= ','.$file['paid']; - $log .= ',"'.$file["name"].'"'; - $log .= ','.$file['fk']; - $log .= ',"'.$file['thirdparty_name'].'"'; - $log .= ',"'.$file['thirdparty_code'].'"'; - $log .= ',"'.$file['country_code'].'"'; - $log .= ',"'.$file['vatnum'].'"'; - $log .= ',"'.$file['sens'].'"'; - $log .= "\n"; - } - $zip->addFromString('transactions.csv', $log); - $zip->close(); + $log .= '"'.$langs->trans($file['item']).'"'; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; + } + $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); + $log .= ',"'.$file['ref'].'"'; + $log .= ','.$file['amount_ht']; + $log .= ','.$file['amount_ttc']; + $log .= ','.$file['amount_vat']; + $log .= ','.$file['paid']; + $log .= ',"'.$file["name"].'"'; + $log .= ','.$file['fk']; + $log .= ',"'.$file['thirdparty_name'].'"'; + $log .= ',"'.$file['thirdparty_code'].'"'; + $log .= ',"'.$file['country_code'].'"'; + $log .= ',"'.$file['vatnum'].'"'; + $log .= ',"'.$file['sens'].'"'; + $log .= "\n"; + } + $zip->addFromString('transactions.csv', $log); + $zip->close(); - ///Then download the zipped file. - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: '.filesize($zipname)); - readfile($zipname); + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.basename($zipname)); + header('Content-Length: '.filesize($zipname)); + readfile($zipname); - dol_delete_file($zipname); + dol_delete_file($zipname); - exit(); - } else { - setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); - } + exit(); + } else { + setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); + } } @@ -571,222 +571,222 @@ print dol_get_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param = 'action=searchfiles'; - $param .= '&date_startday='.GETPOST('date_startday', 'int'); - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); - $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); - $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); - $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); - $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - foreach ($listofchoices as $choice => $val) { - $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); - } - print '
'."\n"; - print ''; + $param = 'action=searchfiles'; + $param .= '&date_startday='.GETPOST('date_startday', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); + $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + } + print ''."\n"; + print ''; - echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); - print ''; - print ''; - foreach ($listofchoices as $choice => $val) { - print ''; - } + print ''; + print ''; + foreach ($listofchoices as $choice => $val) { + print ''; + } - print ''; - print '
'."\n"; + print ''; + print ''."\n"; - print '
'; + print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("TotalHT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalTTC").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalVAT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').'
'; + print ''; + print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; - print ''; - if ($conf->multicurrency->enabled) print ''; - print ''; - if ($result) - { - $TData = dol_sort_array($filesarray, $sortfield, $sortorder); + print ''; + if ($conf->multicurrency->enabled) print ''; + print ''; + if ($result) + { + $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - if (empty($TData)) - { - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print ''; - } else { - // Sort array by date ASC to calculate balance + if (empty($TData)) + { + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print ''; + } else { + // Sort array by date ASC to calculate balance - $totalET_debit = 0; - $totalIT_debit = 0; - $totalVAT_debit = 0; - $totalET_credit = 0; - $totalIT_credit = 0; - $totalVAT_credit = 0; + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; - // Display array - foreach ($TData as $data) - { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; + // Display array + foreach ($TData as $data) + { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; - // Type - print ''; + // Type + print ''; - // Date - print '\n"; + // Date + print '\n"; - // Date due - print '\n"; + // Date due + print '\n"; - // Ref - print ''; + print ''; - // File link - print '\n"; + // File link + print '\n"; - // Paid - print ''; + // Paid + print ''; - // Total ET - print '\n"; - // Total IT - print '\n"; - // Total VAT - print '\n"; + // Total ET + print '\n"; + // Total IT + print '\n"; + // Total VAT + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - if ($data['sens']) { - $totalET_credit += $data['amount_ht']; - $totalIT_credit += $data['amount_ttc']; - $totalVAT_credit += $data['amount_vat']; - } else { - $totalET_debit -= $data['amount_ht']; - $totalIT_debit -= $data['amount_ttc']; - $totalVAT_debit -= $data['amount_vat']; - } + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; + } - if (! empty($conf->multicurrency->enabled)) { - print '\n"; - } + if (! empty($conf->multicurrency->enabled)) { + print '\n"; + } - print "\n"; - } + print "\n"; + } - // Total credits - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Total debits - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Balance - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - } - } - print "
'.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("TotalHT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalTTC").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalVAT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("ThirdParty").''.$langs->trans("Code").''.$langs->trans("Country").''.$langs->trans("VATIntra").''.$langs->trans("Currency").'
'.$langs->trans("VATIntra").''.$langs->trans("Currency").'
'.$langs->trans("NoItem").'
'.$langs->trans("NoItem").'
'.$langs->trans($data['item']).''.$langs->trans($data['item']).''; - print dol_print_date($data['date'], 'day'); - print "'; + print dol_print_date($data['date'], 'day'); + print "'; - print dol_print_date($data['date_due'], 'day'); - print "'; + print dol_print_date($data['date_due'], 'day'); + print "'; + // Ref + print ''; if ($data['item'] == 'Invoice') { $invoice->id = $data['id']; - $invoice->ref = $data['ref']; - $invoice->total_ht = $data['amount_ht']; - $invoice->total_ttc = $data['amount_ttc']; - $invoice->total_tva = $data['amount_vat']; - $invoice->multicurrency_code = $data['currency']; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + $invoice->ref = $data['ref']; + $invoice->total_ht = $data['amount_ht']; + $invoice->total_ttc = $data['amount_ttc']; + $invoice->total_tva = $data['amount_vat']; + $invoice->multicurrency_code = $data['currency']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; - $supplier_invoice->ref = $data['ref']; - $supplier_invoice->total_ht = $data['amount_ht']; - $supplier_invoice->total_ttc = $data['amount_ttc']; - $supplier_invoice->total_tva = $data['amount_vat']; - $supplier_invoice->multicurrency_code = $data['currency']; - print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + $supplier_invoice->total_ht = $data['amount_ht']; + $supplier_invoice->total_ttc = $data['amount_ttc']; + $supplier_invoice->total_tva = $data['amount_vat']; + $supplier_invoice->multicurrency_code = $data['currency']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; - $expensereport->ref = $data['ref']; - print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; - $salary_payment->ref = $data['ref']; - print $salary_payment->getNomUrl(1, '', 0, '', 0); + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1, '', 0, '', 0); } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; - $don->ref = $data['ref']; - print $don->getNomUrl(1, 0, '', 0); + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; - $charge_sociales->ref = $data['ref']; - print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; - $various_payment->ref = $data['ref']; - print $various_payment->getNomUrl(1, '', 0, 0); + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; - $payment_loan->ref = $data['ref']; - print $payment_loan->getNomUrl(1, 0, 0, '', 0); + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); } else { - print $data['ref']; + print $data['ref']; } - print ''; - if (!empty($data['files'])) - { - foreach ($data['files'] as $id=>$filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; - } - } - print "
'; + if (!empty($data['files'])) + { + foreach ($data['files'] as $id=>$filecursor) { + print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; + } + } + print "
'.$data['paid'].''.$data['paid'].''.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."'.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."'.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."'.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."'.$data['thirdparty_name']."'.$data['thirdparty_name']."'.$data['thirdparty_code']."'.$data['thirdparty_code']."'.$data['country_code']."'.$data['country_code']."'.$data['vatnum']."'.$data['vatnum']."'.$data['currency']."'.$data['currency']."
'.$langs->trans('Total').' '.$langs->trans('Income').''.price(price2num($totalET_credit, 'MT')).''.price(price2num($totalIT_credit, 'MT')).''.price(price2num($totalVAT_credit, 'MT')).'
'.$langs->trans('Total').' '.$langs->trans('Outcome').''.price(price2num($totalET_debit, 'MT')).''.price(price2num($totalIT_debit, 'MT')).''.price(price2num($totalVAT_debit, 'MT')).'
'.$langs->trans('Total').''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'
"; - print '
'; + // Total credits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Income').''; + print ''.price(price2num($totalET_credit, 'MT')).''; + print ''.price(price2num($totalIT_credit, 'MT')).''; + print ''.price(price2num($totalVAT_credit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Total debits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; + print ''.price(price2num($totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_debit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Balance + print ''; + print ''.$langs->trans('Total').''; + print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + } + } + print ""; + print '
'; } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index f190ddb1471..a0650e9ffa4 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -148,20 +148,20 @@ $linkback = ', 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - public function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = '', $url_id = '', $type = '') { - // phpcs:enable + // phpcs:enable $lines = array(); // Check parameters @@ -481,7 +481,7 @@ class Account extends CommonObject * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ - public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) { // Deprecation warning if (is_numeric($oper)) { @@ -589,7 +589,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int < 0 if KO, > 0 if OK */ - public function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { global $langs, $conf, $hookmanager; @@ -747,7 +747,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $langs, $conf, $hookmanager; @@ -842,16 +842,16 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update BBAN (RIB) account fields * * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - public function update_bban(User $user = null) + public function update_bban(User $user = null) { - // phpcs:enable + // phpcs:enable global $conf, $langs; // Clean parameters @@ -907,7 +907,7 @@ class Account extends CommonObject * @param string $ref Ref of bank account to get * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -925,11 +925,11 @@ class Account extends CommonObject $sql .= " ba.datec as date_creation, ba.tms as date_update,"; $sql .= ' c.code as country_code, c.label as country,'; $sql .= ' d.code_departement as state_code, d.nom as state'; - $sql .= ' , aj.code as accountancy_journal'; + $sql .= ' , aj.code as accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; $sql .= " WHERE ba.entity IN (".getEntity($this->element).")"; if ($id) $sql .= " AND ba.rowid = ".$id; if ($ref) $sql .= " AND ba.ref = '".$this->db->escape($ref)."'"; @@ -1007,10 +1007,10 @@ class Account extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ - public function setCategories($categories) - { + public function setCategories($categories) + { // Handle single category if (!is_array($categories)) { $categories = array($categories); @@ -1051,7 +1051,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - public function delete(User $user = null) + public function delete(User $user = null) { global $conf; @@ -1115,12 +1115,12 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->clos, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of given object status * @@ -1128,9 +1128,9 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('banks'); @@ -1148,15 +1148,15 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un compte peut etre supprimer ou non (sans mouvements) * * @return boolean vrai si peut etre supprime, faux sinon */ - public function can_be_deleted() + public function can_be_deleted() { - // phpcs:enable + // phpcs:enable $can_be_deleted = false; $sql = "SELECT COUNT(rowid) as nb"; @@ -1179,7 +1179,7 @@ class Account extends CommonObject * * @return string Error string */ - public function error() + public function error() { return $this->error; } @@ -1190,7 +1190,7 @@ class Account extends CommonObject * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) * @return int Current sold (value date <= today) */ - public function solde($option = 0) + public function solde($option = 0) { $solde = 0; @@ -1216,7 +1216,7 @@ class Account extends CommonObject return price2num($solde, 'MU'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1224,9 +1224,9 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board(User $user, $filteraccountid = 0) + public function load_board(User $user, $filteraccountid = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -1272,15 +1272,15 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ - public function load_state_board($filteraccountid = 0) + public function load_state_board($filteraccountid = 0) { - // phpcs:enable + // phpcs:enable global $user; if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -1348,10 +1348,10 @@ class Account extends CommonObject * @param string $mode ''=Link to card, 'transactions'=Link to transactions card * @param string $option ''=Show ref, 'reflabel'=Show ref+label * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip 1=Disable tooltip + * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $user; @@ -1401,10 +1401,10 @@ class Account extends CommonObject $linkstart = 'getCountryCode(); @@ -1507,7 +1507,7 @@ class Account extends CommonObject * * @return int 1 = mandatory / 0 = Not mandatory */ - public function needIBAN() + public function needIBAN() { $country_code = $this->getCountryCode(); @@ -1557,7 +1557,7 @@ class Account extends CommonObject * @param int $id Id of object to load * @return void */ - public function info($id) + public function info($id) { } @@ -1640,7 +1640,7 @@ class Account extends CommonObject //Replace the old AccountNumber key with the new BankAccountNumber key $fieldlists = explode( ' ', - preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION) + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION) ); } } @@ -1656,7 +1656,7 @@ class Account extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { $this->specimen = 1; $this->ref = 'MBA'; @@ -1688,10 +1688,10 @@ class AccountLine extends CommonObject */ public $error = ''; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string ID to identify managed object @@ -1713,54 +1713,54 @@ class AccountLine extends CommonObject */ public $id; - /** - * @var string Ref - */ - public $ref; + /** + * @var string Ref + */ + public $ref; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date (dateo) - * - * @var integer - */ + /** + * Date (dateo) + * + * @var integer + */ public $dateo; /** - * Date value (datev) - * - * @var integer - */ + * Date value (datev) + * + * @var integer + */ public $datev; public $amount; - /** - * @var string bank transaction lines label - */ - public $label; + /** + * @var string bank transaction lines label + */ + public $label; - public $note; + public $note; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_rappro; /** - * @var int ID - */ + * @var int ID + */ public $fk_type; public $rappro; // Is it conciliated @@ -1769,13 +1769,13 @@ class AccountLine extends CommonObject public $bank_chq; // Bank of cheque /** - * @var int ID of cheque receipt - */ + * @var int ID of cheque receipt + */ public $fk_bordereau; /** - * @var int ID of bank account - */ + * @var int ID of bank account + */ public $fk_account; /** @@ -1783,7 +1783,7 @@ class AccountLine extends CommonObject */ public $bank_account_label; - /** + /** * @var string Name of check issuer */ public $emetteur; @@ -1793,7 +1793,7 @@ class AccountLine extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct(DoliDB $db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -1806,7 +1806,7 @@ class AccountLine extends CommonObject * @param string $num External num to load (ex: num of transaction for paypal fee) * @return int <0 if KO, 0 if OK but not found, >0 if OK and found */ - public function fetch($rowid, $ref = '', $num = '') + public function fetch($rowid, $ref = '', $num = '') { global $conf; @@ -1926,9 +1926,9 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - public function delete(User $user = null) + public function delete(User $user = null) { - global $conf; + global $conf; $nbko = 0; @@ -1988,16 +1988,16 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete bank line records * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - public function delete_urls(User $user = null) + public function delete_urls(User $user = null) { - // phpcs:enable + // phpcs:enable $nbko = 0; if ($this->rappro) @@ -2032,7 +2032,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -2056,7 +2056,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update conciliation field * @@ -2065,9 +2065,9 @@ class AccountLine extends CommonObject * @param int $conciliated 1=Set transaction to conciliated, 0=Keep transaction non conciliated * @return int <0 if KO, >0 if OK */ - public function update_conciliation(User $user, $cat, $conciliated = 1) + public function update_conciliation(User $user, $cat, $conciliated = 1) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $this->db->begin(); @@ -2119,7 +2119,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease value date of a rowid * @@ -2127,9 +2127,9 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - public function datev_change($rowid, $sign = 1) + public function datev_change($rowid, $sign = 1) { - // phpcs:enable + // phpcs:enable $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; $resql = $this->db->query($sql); if ($resql) @@ -2156,34 +2156,34 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function datev_next($id) + public function datev_next($id) { - // phpcs:enable + // phpcs:enable return $this->datev_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function datev_previous($id) + public function datev_previous($id) { - // phpcs:enable + // phpcs:enable return $this->datev_change($id, -1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease operation date of a rowid * @@ -2191,9 +2191,9 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - public function dateo_change($rowid, $sign = 1) + public function dateo_change($rowid, $sign = 1) { - // phpcs:enable + // phpcs:enable $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; $resql = $this->db->query($sql); if ($resql) @@ -2220,29 +2220,29 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function dateo_next($id) + public function dateo_next($id) { - // phpcs:enable + // phpcs:enable return $this->dateo_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function dateo_previous($id) + public function dateo_previous($id) { - // phpcs:enable + // phpcs:enable return $this->dateo_change($id, -1); } @@ -2253,7 +2253,7 @@ class AccountLine extends CommonObject * @param int $id Id of object to load * @return void */ - public function info($id) + public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; $sql .= ' b.fk_user_author, b.fk_user_rappro'; @@ -2301,7 +2301,7 @@ class AccountLine extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) { global $langs; @@ -2358,12 +2358,12 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2371,9 +2371,9 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; //$langs->load('companies'); /* diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 9c92eed8e70..694a1d7f6f0 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -443,105 +443,105 @@ class BankAccounts extends DolibarrApi $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql .= " ORDER BY rowid"; + $sql .= " ORDER BY rowid"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - for ($i = 0; $i < $num; $i++) { - $obj = $this->db->fetch_object($result); - $accountLine = new AccountLine($this->db); - if ($accountLine->fetch($obj->rowid) > 0) { - $list[] = $this->_cleanObjectDatas($accountLine); - } - } - } else { - throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); - } + if ($result) { + $num = $this->db->num_rows($result); + for ($i = 0; $i < $num; $i++) { + $obj = $this->db->fetch_object($result); + $accountLine = new AccountLine($this->db); + if ($accountLine->fetch($obj->rowid) > 0) { + $list[] = $this->_cleanObjectDatas($accountLine); + } + } + } else { + throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); + } - return $list; - } + return $list; + } - /** - * Add a line to an account - * - * @param int $id ID of account - * @param int $date Payment date (timestamp) {@from body} {@type timestamp} - * @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body} - * @param string $label Label {@from body} - * @param float $amount Amount (may be 0) {@from body} - * @param int $category Category - * @param string $cheque_number Cheque numberl {@from body} - * @param string $cheque_writer Name of cheque writer {@from body} - * @param string $cheque_bank Bank of cheque writer {@from body} - * @return int ID of line - * - * @url POST {id}/lines - */ - public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') - { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { - throw new RestException(401); - } + /** + * Add a line to an account + * + * @param int $id ID of account + * @param int $date Payment date (timestamp) {@from body} {@type timestamp} + * @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body} + * @param string $label Label {@from body} + * @param float $amount Amount (may be 0) {@from body} + * @param int $category Category + * @param string $cheque_number Cheque numberl {@from body} + * @param string $cheque_writer Name of cheque writer {@from body} + * @param string $cheque_bank Bank of cheque writer {@from body} + * @return int ID of line + * + * @url POST {id}/lines + */ + public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') + { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { + throw new RestException(401); + } - $account = new Account($this->db); - $result = $account->fetch($id); - if (!$result) { - throw new RestException(404, 'account not found'); - } + $account = new Account($this->db); + $result = $account->fetch($id); + if (!$result) { + throw new RestException(404, 'account not found'); + } - $result = $account->addline( - $date, - $type, - $label, - $amount, - $cheque_number, - $category, - DolibarrApiAccess::$user, - $cheque_writer, $cheque_bank - ); - if ($result < 0) { - throw new RestException(503, 'Error when adding line to account: '.$account->error); - } - return $result; - } + $result = $account->addline( + $date, + $type, + $label, + $amount, + $cheque_number, + $category, + DolibarrApiAccess::$user, + $cheque_writer, $cheque_bank + ); + if ($result < 0) { + throw new RestException(503, 'Error when adding line to account: '.$account->error); + } + return $result; + } - /** - * Add a link to an account line - * - * @param int $id ID of account - * @param int $line_id ID of account line - * @param int $url_id ID to set in the URL {@from body} - * @param string $url URL of the link {@from body} - * @param string $label Label {@from body} - * @param string $type Type of link ('payment', 'company', 'member', ...) {@from body} - * @return int ID of link - * - * @url POST {id}/lines/{line_id}/links - */ - public function addLink($id, $line_id, $url_id, $url, $label, $type) - { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { - throw new RestException(401); - } + /** + * Add a link to an account line + * + * @param int $id ID of account + * @param int $line_id ID of account line + * @param int $url_id ID to set in the URL {@from body} + * @param string $url URL of the link {@from body} + * @param string $label Label {@from body} + * @param string $type Type of link ('payment', 'company', 'member', ...) {@from body} + * @return int ID of link + * + * @url POST {id}/lines/{line_id}/links + */ + public function addLink($id, $line_id, $url_id, $url, $label, $type) + { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { + throw new RestException(401); + } - $account = new Account($this->db); - $result = $account->fetch($id); - if (!$result) { - throw new RestException(404, 'account not found'); - } + $account = new Account($this->db); + $result = $account->fetch($id); + if (!$result) { + throw new RestException(404, 'account not found'); + } - $accountLine = new AccountLine($this->db); - $result = $accountLine->fetch($line_id); - if (!$result) { - throw new RestException(404, 'account line not found'); - } + $accountLine = new AccountLine($this->db); + $result = $accountLine->fetch($line_id); + if (!$result) { + throw new RestException(404, 'account line not found'); + } - $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); - if ($result < 0) { - throw new RestException(503, 'Error when adding link to account line: '.$account->error); - } - return $result; - } + $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); + if ($result < 0) { + throw new RestException(503, 'Error when adding link to account line: '.$account->error); + } + return $result; + } } diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index c7e86e51cfb..99a941b074d 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -30,20 +30,20 @@ class BankCateg // extends CommonObject { //public $element='bank_categ'; //!< Id that identify managed objects //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'generic'; /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** - * @var string bank categories label - */ - public $label; + * @var string bank categories label + */ + public $label; /** @@ -213,46 +213,46 @@ class BankCateg // extends CommonObject // Delete link between tag and bank account if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql .= " WHERE fk_categorie = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; + $sql .= " WHERE fk_categorie = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } // Delete link between tag and bank lines if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; - $sql .= " WHERE fk_categ = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; + $sql .= " WHERE fk_categ = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } // Delete bank categ if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql .= " WHERE rowid=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql .= " WHERE rowid=".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 157a7096eb8..2a29fa81681 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -63,35 +63,35 @@ class PaymentVarious extends CommonObject public $amount; public $type_payment; public $num_payment; - public $category_transaction; + public $category_transaction; /** - * @var string various payments label - */ - public $label; + * @var string various payments label + */ + public $label; public $accountancy_code; - public $subledger_account; + public $subledger_account; /** - * @var int ID - */ + * @var int ID + */ public $fk_project; /** - * @var int ID - */ + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; @@ -131,7 +131,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; $this->element = 'payment_various'; @@ -145,7 +145,7 @@ class PaymentVarious extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -173,7 +173,7 @@ class PaymentVarious extends CommonObject $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; $sql .= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; - $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; + $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; $sql .= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql .= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank : "null").","; $sql .= " fk_user_author=".(int) $this->fk_user_author.","; @@ -214,7 +214,7 @@ class PaymentVarious extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - public function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -286,7 +286,7 @@ class PaymentVarious extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - public function delete($user) + public function delete($user) { global $conf, $langs; @@ -320,7 +320,7 @@ class PaymentVarious extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { $this->id = 0; @@ -331,7 +331,7 @@ class PaymentVarious extends CommonObject $this->amount = ''; $this->label = ''; $this->accountancy_code = ''; - $this->subledger_account = ''; + $this->subledger_account = ''; $this->note = ''; $this->fk_bank = ''; $this->fk_user_author = ''; @@ -362,7 +362,7 @@ class PaymentVarious extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - public function create($user) + public function create($user) { global $conf, $langs; @@ -460,13 +460,13 @@ class PaymentVarious extends CommonObject $sign = 1; if ($this->sens == '0') $sign = -1; - $bank_line_id = $acc->addline( + $bank_line_id = $acc->addline( $this->datep, $this->type_payment, $this->label, $sign * abs($this->amount), $this->num_payment, - ($this->category_transaction > 0 ? $this->category_transaction : 0), + ($this->category_transaction > 0 ? $this->category_transaction : 0), $user, '', '', @@ -525,16 +525,16 @@ class PaymentVarious extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment various and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - public function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); @@ -554,12 +554,12 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -567,9 +567,9 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -608,10 +608,10 @@ class PaymentVarious extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip 1=Disable tooltip + * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $db, $conf, $langs, $hookmanager; global $langs; @@ -679,8 +679,8 @@ class PaymentVarious extends CommonObject * @param int $id Id of record * @return void */ - public function info($id) - { + public function info($id) + { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql .= ' WHERE v.rowid = '.$id; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 896b91545db..c67c0496727 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -41,11 +41,11 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } if ($user->socid) - $socid = $user->socid; + $socid = $user->socid; // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -57,9 +57,9 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) - $sortorder = "ASC"; + $sortorder = "ASC"; if (!$sortfield) - $sortfield = "name"; + $sortfield = "name"; $object = new Account($db); if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); @@ -73,8 +73,8 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); if ($object->id > 0) { - $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); + $object->fetch_thirdparty(); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); } include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -91,52 +91,52 @@ llxHeader('', $title, $helpurl); $form = new Form($db); if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output.'/'.$object->ref; + if ($object->fetch($id, $ref)) { + $upload_dir = $conf->bank->dir_output.'/'.$object->ref; - // Onglets - $head = bank_prepare_head($object); - print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account'); + // Onglets + $head = bank_prepare_head($object); + print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account'); - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize += $file['size']; + } - $morehtmlref = ''; + $morehtmlref = ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print ''; - print ''; - print ''; - print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
\n"; + print ''; + print ''; + print ''; + print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
\n"; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'bank'; - $permission = $user->rights->banque->modifier; - $permtoedit = $user->rights->banque->modifier; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } else { - dol_print_error($db); - } + $modulepart = 'bank'; + $permission = $user->rights->banque->modifier; + $permtoedit = $user->rights->banque->modifier; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + } else { + dol_print_error($db); + } } else { - Header('Location: index.php'); - exit; + Header('Location: index.php'); + exit; } // End of page diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 9350e211284..f141abc8e87 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -741,14 +741,14 @@ if ($account) if ($_GET["option"] != 'all') { $morehtml = ''.$langs->trans("ShowAllAccounts").''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { $morehtml = ''.$langs->trans("BackToAccount").''; print $langs->trans("AllAccounts"); //print $morehtml; } } else { - $bankaccount = new Account($db); + $bankaccount = new Account($db); $listid = explode(',', $account); foreach ($listid as $key => $id) { diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 7ae7c995935..dd14ebf4e54 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -65,30 +65,30 @@ if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessf if ($cancel) { - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } } if ($user->rights->banque->consolidate && $action == 'donext') { - $al = new AccountLine($db); - $al->dateo_next($_GET["rowid"]); + $al = new AccountLine($db); + $al->dateo_next($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'doprev') { - $al = new AccountLine($db); - $al->dateo_previous($_GET["rowid"]); + $al = new AccountLine($db); + $al->dateo_previous($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'dvnext') { - $al = new AccountLine($db); - $al->datev_next($_GET["rowid"]); + $al = new AccountLine($db); + $al->datev_next($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'dvprev') { - $al = new AccountLine($db); - $al->datev_previous($_GET["rowid"]); + $al = new AccountLine($db); + $al->datev_previous($_GET["rowid"]); } if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) @@ -96,10 +96,10 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban $cat1 = GETPOST("cat1", 'int'); if (!empty($rowid) && !empty($cat1)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1; - if (!$db->query($sql)) - { - dol_print_error($db); - } + if (!$db->query($sql)) + { + dol_print_error($db); + } } else { setEventMessages($langs->trans("MissingIds"), null, 'errors'); } @@ -157,31 +157,31 @@ if ($user->rights->banque->modifier && $action == "update") $result = $db->query($sql); if (!$result) { - $error++; + $error++; } if (!$error) { - $arrayofcategs = GETPOST('custcats', 'array'); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; - if (!$db->query($sql)) - { - $error++; - dol_print_error($db); - } - if (count($arrayofcategs)) - { - foreach ($arrayofcategs as $val) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; - if (!$db->query($sql)) - { - $error++; - dol_print_error($db); - } - } - // $arrayselected will be loaded after in page output - } + $arrayofcategs = GETPOST('custcats', 'array'); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; + if (!$db->query($sql)) + { + $error++; + dol_print_error($db); + } + if (count($arrayofcategs)) + { + foreach ($arrayofcategs as $val) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; + if (!$db->query($sql)) + { + $error++; + dol_print_error($db); + } + } + // $arrayselected will be loaded after in page output + } } if (!$error) @@ -198,37 +198,37 @@ if ($user->rights->banque->modifier && $action == "update") // Reconcile if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) { - $num_rel = trim($_POST["num_rel"]); - $rappro = $_POST['reconciled'] ? 1 : 0; + $num_rel = trim($_POST["num_rel"]); + $rappro = $_POST['reconciled'] ? 1 : 0; - // Check parameters - if ($rappro && empty($num_rel)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors'); - $error++; - } + // Check parameters + if ($rappro && empty($num_rel)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors'); + $error++; + } - if (!$error) - { - $db->begin(); + if (!$error) + { + $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); - if (empty($num_rel)) $sql .= ", rappro = 0"; - else $sql .= ", rappro = ".$rappro; - $sql .= " WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); + if (empty($num_rel)) $sql .= ", rappro = 0"; + else $sql .= ", rappro = ".$rappro; + $sql .= " WHERE rowid = ".$rowid; - dol_syslog("line.php", LOG_DEBUG); - $result = $db->query($sql); - if ($result) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - dol_print_error($db); - } - } + dol_syslog("line.php", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + dol_print_error($db); + } + } } @@ -244,7 +244,7 @@ llxHeader('', $langs->trans("BankTransaction")); $c = new Categorie($db); $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE); foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + $arrayselected[] = $cat->id; } $head = bankline_prepare_head($rowid); @@ -259,385 +259,385 @@ $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { - $i = 0; $total = 0; - if ($db->num_rows($result)) - { - $objp = $db->fetch_object($result); + $i = 0; $total = 0; + if ($db->num_rows($result)) + { + $objp = $db->fetch_object($result); - $total = $total + $objp->amount; + $total = $total + $objp->amount; - $acct = new Account($db); - $acct->fetch($objp->fk_account); - $account = $acct->id; + $acct = new Account($db); + $acct->fetch($objp->fk_account); + $account = $acct->id; - $bankline = new AccountLine($db); - $bankline->fetch($rowid, $ref); + $bankline = new AccountLine($db); + $bankline->fetch($rowid, $ref); - $links = $acct->get_url($rowid); - $bankline->load_previous_next_ref('', 'rowid'); + $links = $acct->get_url($rowid); + $bankline->load_previous_next_ref('', 'rowid'); - // Confirmations - if ($action == 'delete_categ') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); - } + // Confirmations + if ($action == 'delete_categ') + { + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + } - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); + print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($bankline, 'rowid', $linkback); + dol_banner_tab($bankline, 'rowid', $linkback); print '
'; - print '
'; - print ''; + print '
'; + print '
'; - $i++; + $i++; - // Bank account - print ''; - print ''; - print ''; + // Bank account + print ''; + print ''; + print ''; - // Show links of bank transactions - if (count($links)) - { - print ''; - print ''; + print ''; - } + print $paymenttmp->getNomUrl(1); + } elseif ($links[$key]['type'] == 'company') { + $societe = new Societe($db); + $societe->fetch($links[$key]['url_id']); + print $societe->getNomUrl(1); + } elseif ($links[$key]['type'] == 'sc') { + print ''; + print img_object($langs->trans('SocialContribution'), 'bill').' '; + print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); + print ''; + } elseif ($links[$key]['type'] == 'payment_sc') { + print ''; + print img_object($langs->trans('Payment'), 'payment').' '; + print $langs->trans("SocialContributionPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_vat') { + print ''; + print img_object($langs->trans('VAT'), 'payment').' '; + print $langs->trans("VATPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_salary') { + print ''; + print img_object($langs->trans('PaymentSalary'), 'payment').' '; + print $langs->trans("SalaryPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_loan') { + print ''; + print img_object($langs->trans('LoanPayment'), 'payment').' '; + print $langs->trans("PaymentLoan"); + print ''; + } elseif ($links[$key]['type'] == 'loan') { + print ''; + print img_object($langs->trans('Loan'), 'bill').' '; + print $langs->trans("Loan"); + print ''; + } elseif ($links[$key]['type'] == 'member') { + print ''; + print img_object($langs->trans('Member'), 'user').' '; + print $links[$key]['label']; + print ''; + } elseif ($links[$key]['type'] == 'payment_donation') { + print ''; + print img_object($langs->trans('Donation'), 'payment').' '; + print $langs->trans("DonationPayment"); + print ''; + } elseif ($links[$key]['type'] == 'banktransfert') { + print ''; + print img_object($langs->trans('Transaction'), 'payment').' '; + print $langs->trans("TransactionOnTheOtherAccount"); + print ''; + } elseif ($links[$key]['type'] == 'user') { + print ''; + print img_object($langs->trans('User'), 'user').' '; + print $langs->trans("User"); + print ''; + } elseif ($links[$key]['type'] == 'payment_various') { + print ''; + print img_object($langs->trans('VariousPayment'), 'payment').' '; + print $langs->trans("VariousPayment"); + print ''; + } else { + print ''; + print img_object('', 'generic').' '; + print $links[$key]['label']; + print ''; + } + } + print ''; + } - //$user->rights->banque->modifier=false; - //$user->rights->banque->consolidate=true; + //$user->rights->banque->modifier=false; + //$user->rights->banque->consolidate=true; - // Type of payment / Number - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Type of payment / Number + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Transmitter - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Transmitter + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Bank of cheque - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Bank of cheque + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Date ope - print ''; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + // Date ope + print ''; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - // Value date - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Value date + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Description - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + // Description + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - // Amount - print ""; - if ($user->rights->banque->modifier) - { - print ''; - } else { - print ''; - } - print ""; + // Amount + print ""; + if ($user->rights->banque->modifier) + { + print ''; + } else { + print ''; + } + print ""; - // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { - $langs->load('categories'); + // Categories + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { + $langs->load('categories'); - // Bank line - print '"; - } + // Bank line + print '"; + } - print "
'.$langs->trans("Account").''; - if (!$objp->rappro && !$bankline->getVentilExportCompta()) - { - $form->select_comptes($acct->id, 'accountid', 0, '', 0); - } else { - print $acct->getNomUrl(1, 'transactions', 'reflabel'); - } - print '
'.$langs->trans("Account").''; + if (!$objp->rappro && !$bankline->getVentilExportCompta()) + { + $form->select_comptes($acct->id, 'accountid', 0, '', 0); + } else { + print $acct->getNomUrl(1, 'transactions', 'reflabel'); + } + print '
'.$langs->trans("Links").''; - foreach ($links as $key=>$val) - { - if ($key) print '
'; - if ($links[$key]['type'] == 'payment') { - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $paymenttmp = new Paiement($db); - $paymenttmp->fetch($links[$key]['url_id']); - $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; - /*print ''; + // Show links of bank transactions + if (count($links)) + { + print '
'.$langs->trans("Links").''; + foreach ($links as $key=>$val) + { + if ($key) print '
'; + if ($links[$key]['type'] == 'payment') { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paymenttmp = new Paiement($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('Payment'),'payment').' '; print $langs->trans("Payment"); print '';*/ - print $paymenttmp->getNomUrl(1); - } elseif ($links[$key]['type'] == 'payment_supplier') { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; - $paymenttmp = new PaiementFourn($db); - $paymenttmp->fetch($links[$key]['url_id']); - $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; - /*print ''; + print $paymenttmp->getNomUrl(1); + } elseif ($links[$key]['type'] == 'payment_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + $paymenttmp = new PaiementFourn($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('Payment'),'payment').' '; print $langs->trans("Payment"); print '';*/ - print $paymenttmp->getNomUrl(1); - } elseif ($links[$key]['type'] == 'company') { - $societe = new Societe($db); - $societe->fetch($links[$key]['url_id']); - print $societe->getNomUrl(1); - } elseif ($links[$key]['type'] == 'sc') { - print ''; - print img_object($langs->trans('SocialContribution'), 'bill').' '; - print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); - print ''; - } elseif ($links[$key]['type'] == 'payment_sc') { - print ''; - print img_object($langs->trans('Payment'), 'payment').' '; - print $langs->trans("SocialContributionPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_vat') { - print ''; - print img_object($langs->trans('VAT'), 'payment').' '; - print $langs->trans("VATPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_salary') { - print ''; - print img_object($langs->trans('PaymentSalary'), 'payment').' '; - print $langs->trans("SalaryPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_loan') { - print ''; - print img_object($langs->trans('LoanPayment'), 'payment').' '; - print $langs->trans("PaymentLoan"); - print ''; - } elseif ($links[$key]['type'] == 'loan') { - print ''; - print img_object($langs->trans('Loan'), 'bill').' '; - print $langs->trans("Loan"); - print ''; - } elseif ($links[$key]['type'] == 'member') { - print ''; - print img_object($langs->trans('Member'), 'user').' '; - print $links[$key]['label']; - print ''; - } elseif ($links[$key]['type'] == 'payment_donation') { - print ''; - print img_object($langs->trans('Donation'), 'payment').' '; - print $langs->trans("DonationPayment"); - print ''; - } elseif ($links[$key]['type'] == 'banktransfert') { - print ''; - print img_object($langs->trans('Transaction'), 'payment').' '; - print $langs->trans("TransactionOnTheOtherAccount"); - print ''; - } elseif ($links[$key]['type'] == 'user') { - print ''; - print img_object($langs->trans('User'), 'user').' '; - print $langs->trans("User"); - print ''; - } elseif ($links[$key]['type'] == 'payment_various') { - print ''; - print img_object($langs->trans('VariousPayment'), 'payment').' '; - print $langs->trans("VariousPayment"); - print ''; - } else { - print ''; - print img_object('', 'generic').' '; - print $links[$key]['label']; - print ''; - } - } - print '
".$langs->trans("Type")." / ".$langs->trans("Numero"); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print "'; - $form->select_types_paiements($objp->fk_type, "value", '', 2); - print ''; - if ($objp->receiptid) - { - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $receipt = new RemiseCheque($db); - $receipt->fetch($objp->receiptid); - print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); - } - print ''.$objp->fk_type.' '.$objp->num_chq.'
".$langs->trans("Type")." / ".$langs->trans("Numero"); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print "'; + $form->select_types_paiements($objp->fk_type, "value", '', 2); + print ''; + if ($objp->receiptid) + { + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; + $receipt = new RemiseCheque($db); + $receipt->fetch($objp->receiptid); + print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); + } + print ''.$objp->fk_type.' '.$objp->num_chq.'
".$langs->trans("CheckTransmitter"); - print ' ('.$langs->trans("ChequeMaker").')'; - print "'; - print ''; - print ''.$objp->emetteur.'
".$langs->trans("CheckTransmitter"); + print ' ('.$langs->trans("ChequeMaker").')'; + print "'; + print ''; + print ''.$objp->emetteur.'
".$langs->trans("Bank"); - print ' ('.$langs->trans("ChequeBank").')'; - print "'; - print ''; - print ''.$objp->banque.'
".$langs->trans("Bank"); + print ' ('.$langs->trans("ChequeBank").')'; + print "'; + print ''; + print ''.$objp->banque.'
'.$langs->trans("DateOperation").''; - print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); - if (!$objp->rappro) - { - print '   '; - print ''; - print img_edit_remove()." "; - print ''; - print img_edit_add().""; - } - print ''; - print dol_print_date($db->jdate($objp->do), "day"); - print '
'.$langs->trans("DateOperation").''; + print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); + if (!$objp->rappro) + { + print '   '; + print ''; + print img_edit_remove()." "; + print ''; + print img_edit_add().""; + } + print ''; + print dol_print_date($db->jdate($objp->do), "day"); + print '
".$langs->trans("DateValue")."'; - print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); - if (!$objp->rappro) - { - print '   '; - print ''; - print img_edit_remove()." "; - print ''; - print img_edit_add().""; - } - print ''; - print dol_print_date($db->jdate($objp->dv), "day"); - print '
".$langs->trans("DateValue")."'; + print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); + if (!$objp->rappro) + { + print '   '; + print ''; + print img_edit_remove()." "; + print ''; + print img_edit_add().""; + } + print ''; + print dol_print_date($db->jdate($objp->dv), "day"); + print '
".$langs->trans("Label")."'; - print 'rappro ? ' disabled' : '').' value="'; - if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } else { - print $objp->label; - } - print '">'; - print ''; - if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } else { - print $objp->label; - } - print '
".$langs->trans("Label")."'; + print 'rappro ? ' disabled' : '').' value="'; + if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } else { + print $objp->label; + } + print '">'; + print ''; + if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } else { + print $objp->label; + } + print '
".$langs->trans("Amount")."'; - print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); - print ''; - print price($objp->amount); - print '
".$langs->trans("Amount")."'; + print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); + print ''; + print price($objp->amount); + print '
'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); - print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); - print "
'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); + print "
"; + print ""; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '

'; + print '

'; - print ""; + print ""; - // Releve rappro - if ($acct->canBeConciliated() > 0) // Si compte rapprochable - { - print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account'); - print '
'."\n"; + // Releve rappro + if ($acct->canBeConciliated() > 0) // Si compte rapprochable + { + print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account'); + print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; + print '
'; - print ''; + print '
'; - print '"; - if ($user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + print '"; + if ($user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - print ""; - if ($user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; - print '
'.$langs->trans("Conciliation")."'; - if ($objp->rappro) - { - print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; - print ''; - } else { - print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; - } - if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; - print ''.$objp->num_releve.' 
'.$langs->trans("Conciliation")."'; + if ($objp->rappro) + { + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; + print ''; + } else { + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; + } + if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; + print ''.$objp->num_releve.' 
".$langs->trans("BankLineConciliated")."'; - print 'rappro ? ' checked="checked"' : '')).'">'; - print ''.yn($objp->rappro).'
'; + print "".$langs->trans("BankLineConciliated").""; + if ($user->rights->banque->consolidate) + { + print ''; + print 'rappro ? ' checked="checked"' : '')).'">'; + print ''; + } else { + print ''.yn($objp->rappro).''; + } + print ''; + print ''; - print '
'; + print '
'; - print '
'; + print '
'; - print ''; - if ($backtopage) - { - print '   '; - print ''; - } - print '
'; + print ''; + if ($backtopage) + { + print '   '; + print ''; + } + print '
'; print '
'; - } - } + } + } - $db->free($result); + $db->free($result); } else dol_print_error($db); // End of page diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 4e3653d2ea4..22bd08da1ba 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -86,24 +86,24 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'b.ref'=>'Ref', - 'b.label'=>'Label', + 'b.ref'=>'Ref', + 'b.label'=>'Label', ); $checkedtypetiers = 0; $arrayfields = array( - 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), - 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), - 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), - 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), - 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), + 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), + 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), + 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), + 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), ); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) @@ -134,10 +134,10 @@ 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')) // All tests are required to be compatible with all browsers { - $search_ref = ''; - $search_label = ''; - $search_number = ''; - $search_status = ''; + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; } @@ -194,8 +194,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } $sql .= $db->plimit($limit + 1, $offset); @@ -203,15 +203,15 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $accounts[$objp->rowid] = $objp->courant; - $i++; - } - $db->free($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $accounts[$objp->rowid] = $objp->courant; + $i++; + } + $db->free($resql); } else dol_print_error($db); @@ -267,8 +267,8 @@ 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).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -302,53 +302,53 @@ print ''; // Ref if (!empty($arrayfields['b.ref']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Label if (!empty($arrayfields['b.label']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Account type if (!empty($arrayfields['accountype']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Bank number if (!empty($arrayfields['b.number']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Account number if (!empty($arrayfields['b.account_number']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Accountancy journal if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Transactions to reconcile if (!empty($arrayfields['toreconcile']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Currency if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -360,30 +360,30 @@ print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['b.datec']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Date modification if (!empty($arrayfields['b.tms']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Status if (!empty($arrayfields['b.clos']['checked'])) { - print ''; - $array = array( - 'opened'=>$langs->trans("Opened"), - 'closed'=>$langs->trans("Closed") - ); - print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); - print ''; + print ''; + $array = array( + 'opened'=>$langs->trans("Opened"), + 'closed'=>$langs->trans("Closed") + ); + print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); + print ''; } // Balance if (!empty($arrayfields['balance']['checked'])) { - print ''; + print ''; } // Action column print ''; @@ -422,7 +422,7 @@ foreach ($accounts as $key=>$type) { if ($i >= $limit) break; - $found++; + $found++; $result = $objecttmp->fetch($key); @@ -439,163 +439,163 @@ foreach ($accounts as $key=>$type) print ''; - // Ref - if (!empty($arrayfields['b.ref']['checked'])) - { - print ''.$objecttmp->getNomUrl(1).''; - if (!$i) $totalarray['nbfield']++; - } + // Ref + if (!empty($arrayfields['b.ref']['checked'])) + { + print ''.$objecttmp->getNomUrl(1).''; + if (!$i) $totalarray['nbfield']++; + } - // Label - if (!empty($arrayfields['b.label']['checked'])) - { + // Label + if (!empty($arrayfields['b.label']['checked'])) + { print ''.$objecttmp->label.''; - if (!$i) $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; + } - // Account type - if (!empty($arrayfields['accountype']['checked'])) - { - print ''; + // Account type + if (!empty($arrayfields['accountype']['checked'])) + { + print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Number - if (!empty($arrayfields['b.number']['checked'])) - { - print ''.$objecttmp->number.''; - if (!$i) $totalarray['nbfield']++; - } - - // Account number - if (!empty($arrayfields['b.account_number']['checked'])) - { - print ''; - if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) - { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $objecttmp->account_number, 1); - print $accountingaccount->getNomUrl(0, 1, 1, '', 1); - } else { - print $objecttmp->account_number; - } - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Accountancy journal - if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) - { - print ''; - if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) - { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objecttmp->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } else { - print ''; - } - print ''; if (!$i) $totalarray['nbfield']++; - } + } - // Currency - if (!empty($arrayfields['b.currency_code']['checked'])) - { - print ''; + // Number + if (!empty($arrayfields['b.number']['checked'])) + { + print ''.$objecttmp->number.''; + if (!$i) $totalarray['nbfield']++; + } + + // Account number + if (!empty($arrayfields['b.account_number']['checked'])) + { + print ''; + if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('', $objecttmp->account_number, 1); + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); + } else { + print $objecttmp->account_number; + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Accountancy journal + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) + { + print ''; + if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } else { + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Currency + if (!empty($arrayfields['b.currency_code']['checked'])) + { + print ''; print $objecttmp->currency_code; - print ''; - if (!$i) $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Transactions to reconcile - if (!empty($arrayfields['toreconcile']['checked'])) - { - print ''; + // Transactions to reconcile + if (!empty($arrayfields['toreconcile']['checked'])) + { + print ''; - $conciliate = $objecttmp->canBeConciliated(); - if ($conciliate == -2) print ''.$langs->trans("CashAccount").''; - elseif ($conciliate == -3) print ''.$langs->trans("Closed").''; - elseif (empty($objecttmp->rappro)) { - print ''.$langs->trans("ConciliationDisabled").''; - } else { - $result = $objecttmp->load_board($user, $objecttmp->id); - if ($result < 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - } else { - print ''; - print ''; - print $result->nbtodo; - print ''; + $conciliate = $objecttmp->canBeConciliated(); + if ($conciliate == -2) print ''.$langs->trans("CashAccount").''; + elseif ($conciliate == -3) print ''.$langs->trans("Closed").''; + elseif (empty($objecttmp->rappro)) { + print ''.$langs->trans("ConciliationDisabled").''; + } else { + $result = $objecttmp->load_board($user, $objecttmp->id); + if ($result < 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + } else { + print ''; + print ''; + print $result->nbtodo; + print ''; print ''; - if ($result->nbtodolate) { - print ''; - print ' '.$result->nbtodolate; - print ''; - } - } - } + if ($result->nbtodolate) { + print ''; + print ' '.$result->nbtodolate; + print ''; + } + } + } - print ''; - if (!$i) $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Extra fields + // Extra fields if (is_array($objecttmp->array_options)) { $obj = new stdClass(); foreach ($objecttmp->array_options as $k => $v) { $obj->$k = $v; } } - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook - print $hookmanager->resPrint; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook + print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['b.datec']['checked'])) - { - print ''; - print dol_print_date($objecttmp->date_creation, 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date modification - if (!empty($arrayfields['b.tms']['checked'])) - { - print ''; - print dol_print_date($objecttmp->date_update, 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; - } + if (!empty($arrayfields['b.datec']['checked'])) + { + print ''; + print dol_print_date($objecttmp->date_creation, 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['b.tms']['checked'])) + { + print ''; + print dol_print_date($objecttmp->date_update, 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Status - if (!empty($arrayfields['b.clos']['checked'])) - { + // Status + if (!empty($arrayfields['b.clos']['checked'])) + { print ''.$objecttmp->getLibStatut(5).''; - if (!$i) $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; + } - // Balance - if (!empty($arrayfields['balance']['checked'])) - { + // Balance + if (!empty($arrayfields['balance']['checked'])) + { print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance'; $totalarray['val']['balance'] += $solde; - } + } // 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($objecttmp->id, $arrayofselected)) $selected = 1; - print ''; + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; + print ''; } print ''; if (!$i) $totalarray['nbfield']++; @@ -610,9 +610,9 @@ foreach ($accounts as $key=>$type) // If no record found if (!$found) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } - print ''.$langs->trans("NoRecordFound").''; + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; } // Show total line diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 166d69fdd30..92dd2de75f4 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -93,8 +93,8 @@ if (!$sortfield) $sortfield = "s.nom"; $object = new Account($db); if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + $result = $object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account } @@ -371,15 +371,15 @@ if (empty($numref)) $morehtmlright .= ''; $morehtmlright .= '
'; - $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); - print load_fiche_titre($title, $morehtmlright, ''); + $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + print load_fiche_titre($title, $morehtmlright, ''); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1); print "
"; print ''; print ''; - print '
'; + print '
'; print ''; print ''; print ''; @@ -407,7 +407,7 @@ if (empty($numref)) } // Recherche les ecritures pour le releve - $sql = $sqlrequestforbankline; + $sql = $sqlrequestforbankline; $result = $db->query($sql); if ($result) @@ -441,17 +441,17 @@ if (empty($numref)) print "\n"; // Type and num - if ($objp->fk_type == 'SOLD') { - $type_label = ' '; - } else { - $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; - } - $link = ''; - if ($objp->fk_bordereau > 0) { - $remisestatic->id = $objp->fk_bordereau; - $remisestatic->ref = $objp->ref; - $link = ' '.$remisestatic->getNomUrl(1); - } + if ($objp->fk_type == 'SOLD') { + $type_label = ' '; + } else { + $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; + } + $link = ''; + if ($objp->fk_bordereau > 0) { + $remisestatic->id = $objp->fk_bordereau; + $remisestatic->ref = $objp->ref; + $link = ' '.$remisestatic->getNomUrl(1); + } print ''; // Description @@ -548,9 +548,9 @@ if (empty($numref)) print ')'; } } elseif ($links[$key]['type'] == 'company') { - $societestatic->id = $links[$key]['url_id']; - $societestatic->name = $links[$key]['label']; - print $societestatic->getNomUrl(1, 'company', 24); + $societestatic->id = $links[$key]['url_id']; + $societestatic->name = $links[$key]['label']; + print $societestatic->getNomUrl(1, 'company', 24); $newline = 0; } elseif ($links[$key]['type'] == 'member') { print ''; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 70903f9120f..7e1b7fd0567 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -118,9 +118,9 @@ if ($action == 'add') if (!$error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, $amountto, '', '', $user); if (!($bank_line_id_to > 0)) $error++; - if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); if (!($result > 0)) $error++; - if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); if (!($result > 0)) $error++; if (!$error) @@ -133,7 +133,7 @@ if ($action == 'add') $db->rollback(); } } else { - $error++; + $error++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors'); } } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 03844897a15..6d811233b7a 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -98,15 +98,15 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print dol_get_fiche_end(); - print '
'; + print '
'; $solde = $object->solde(0); if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6; else $colspan = 5; // Show next coming entries - print '
'; - print '
'.$langs->trans("DateOperationShort").''.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'
'; + print '
'; + print '
'; // Ligne de titre tableau des ecritures print ''; @@ -277,13 +277,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // We discard lines with a remainder to pay to 0 if (price2num($total_ttc) != 0) { - // Show line - print ''; - print '"; - print ""; + // Show line + print ''; + print '"; + print ""; if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if ($obj->family == 'invoice') { $mc->getInfo($obj->entity); @@ -292,11 +292,11 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ""; } } - print ""; - if ($obj->total_ttc < 0) { print '"; }; - if ($obj->total_ttc >= 0) { print '"; }; - print ''; - print ""; + print ""; + if ($obj->total_ttc < 0) { print '"; }; + if ($obj->total_ttc >= 0) { print '"; }; + print ''; + print ""; } $i++; @@ -310,7 +310,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { print $hookmanager->resPrint; - $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; + $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } // solde @@ -320,7 +320,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print "
'; - if ($obj->dlr) print dol_print_date($db->jdate($obj->dlr), "day"); - else print $langs->trans("NotDefined"); - print "".$ref."
'; + if ($obj->dlr) print dol_print_date($db->jdate($obj->dlr), "day"); + else print $langs->trans("NotDefined"); + print "".$ref."".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
"; - print "
"; + print "
"; } else { print $langs->trans("ErrorBankAccountNotFound"); } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 1950caa1de3..c1b5b1a06b0 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -120,7 +120,7 @@ if (empty($reshook)) $object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account = $subledger_account; + $object->subledger_account = $subledger_account; $object->sens = GETPOST('sens'); $object->fk_project = GETPOST('fk_project', 'int'); @@ -319,7 +319,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $bankcateg = new BankCateg($db); foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; + $options[$bankcategory->id] = $bankcategory->label; } /* ************************************************************************** */ @@ -361,8 +361,8 @@ if ($action == 'create') // Sens print ''; print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).''; - $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); - print $form->selectarray('sens', $sensarray, $sens); + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + print $form->selectarray('sens', $sensarray, $sens); print ''; // Amount @@ -396,42 +396,42 @@ if ($action == 'create') print ''."\n"; } - // Project - if (!empty($conf->projet->enabled)) - { - $formproject = new FormProjets($db); + // Project + if (!empty($conf->projet->enabled)) + { + $formproject = new FormProjets($db); - // Associated project - $langs->load("projects"); + // Associated project + $langs->load("projects"); - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; - $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); + $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); - print ''; - } + print ''; + } - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Category - if (is_array($options) && count($options) && $conf->categorie->enabled) - { - print ''.$langs->trans("RubriquesTransactions").''; - print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1); - print ''; - } + // Category + if (is_array($options) && count($options) && $conf->categorie->enabled) + { + print ''.$langs->trans("RubriquesTransactions").''; + print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1); + print ''; + } // Accountancy account if (!empty($conf->accounting->enabled)) { // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''.$langs->trans("AccountAccounting").''; - print ''; + print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); - print ''; + print ''; } else // For external software { print ''.$langs->trans("AccountAccounting").''; @@ -439,24 +439,24 @@ if ($action == 'create') print ''; } - // Subledger account - if (!empty($conf->accounting->enabled)) - { - print ''.$langs->trans("SubledgerAccount").'aaaa'; - print ''; - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); - } else { - print ''; - } - print ''; - } else // For external software - { - print ''.$langs->trans("SubledgerAccount").''; - print ''; - print ''; - } + // Subledger account + if (!empty($conf->accounting->enabled)) + { + print ''.$langs->trans("SubledgerAccount").'aaaa'; + print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); + } else { + print ''; + } + print ''; + } else // For external software + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print ''; + } print ''; @@ -576,12 +576,12 @@ if ($id) } print ''; - // Subledger account - print ''; - print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); - print ''; - print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); - print ''; + // Subledger account + print ''; + print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); + print ''; + print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); + print ''; if (!empty($conf->banque->enabled)) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 165c8675960..48da6483152 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -67,7 +67,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) $sortfield = "v.datep,v.rowid"; -if (!$sortorder) $sortorder="DESC,DESC"; +if (!$sortorder) $sortorder = "DESC,DESC"; $filtre = GETPOST("filtre", 'alpha'); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 96299886070..546805e3aaa 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -59,7 +59,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi if ($contextpage == 'takepos') { - $_GET['optioncss'] = 'print'; + $_GET['optioncss'] = 'print'; } // Security check @@ -164,8 +164,8 @@ if ($action == "start") $object->month_close = GETPOST('closemonth', 'int'); $object->year_close = GETPOST('closeyear', 'int'); - $object->opening = price2num(GETPOST('opening', 'alpha')); - $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); $object->posnumber = GETPOST('posnumber', 'alpha'); $db->begin(); @@ -226,32 +226,32 @@ if ($action == "valid") // validate = close "; exit; } - $action = "view"; + $action = "view"; } // Action to delete if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - $object->fetch($id); + $object->fetch($id); - if (!($object->id > 0)) - { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } - $result = $object->delete($user); - //var_dump($result); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".$backurlforlist); - exit; - } else { - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } + $result = $object->delete($user); + //var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } else { + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } } @@ -307,22 +307,22 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($bankid > 0) { - $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".$bankid; - if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; - else dol_print_error('', 'Year not defined'); + $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; - } else dol_print_error($db); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; + } else dol_print_error($db); } else { setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); - $error++; + $error++; } } @@ -370,50 +370,50 @@ if ($action == "create" || $action == "start" || $action == 'close') print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); print ''; - print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; print ''; - } else { - print ''; - } + } else { + print ''; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'; + print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; $disabled = 0; $prefix = 'close'; - print ''; - print ''; - print ''; + print ''; + print ''; + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for ($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = 0; $showempty = 1; + if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') + { + $selectedposnumber = 1; $showempty = 0; + } + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); + //print ''; + print ''; // Year print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; + print '
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - $array = array(); - $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for ($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = 0; $showempty = 1; - if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') - { - $selectedposnumber = 1; $showempty = 0; - } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); - //print ''; - print ''; $retstring = ''; @@ -577,36 +577,36 @@ if ($action == "create" || $action == "start" || $action == 'close') print ''; } - print ''; + print ''; } } if (empty($action) || $action == "view" || $action == "close") { - $result = $object->fetch($id); + $result = $object->fetch($id); - llxHeader('', $langs->trans("CashControl")); + llxHeader('', $langs->trans("CashControl")); - if ($result <= 0) { - print $langs->trans("ErrorRecordNotFound"); - } else { - $head = array(); - $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; - $head[0][1] = $langs->trans("CashControl"); - $head[0][2] = 'cashcontrol'; + if ($result <= 0) { + print $langs->trans("ErrorRecordNotFound"); + } else { + $head = array(); + $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; + $head[0][1] = $langs->trans("CashControl"); + $head[0][2] = 'cashcontrol'; - print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); + print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - $morehtmlref .= '
'; + $morehtmlref = '
'; + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print '
'; print ''; @@ -633,36 +633,36 @@ if (empty($action) || $action == "view" || $action == "close") print ''; print '
'; - print '
'; + print '
'; - print '
'; + print '
'; print '
'; - print ''; + print '
'; - print ''; + print ''; - print '"; - foreach ($arrayofpaymentmode as $key => $val) - { - print '"; - } + print '"; + foreach ($arrayofpaymentmode as $key => $val) + { + print '"; + } print "
'; - print $langs->trans("DateCreationShort"); - print ''; - print dol_print_date($object->date_creation, 'dayhour'); - print '
'; + print $langs->trans("DateCreationShort"); + print ''; + print dol_print_date($object->date_creation, 'dayhour'); + print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans($val).''; - print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; + print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
\n"; - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - if ($action != 'close') { + if ($action != 'close') { print '
'; print ''; @@ -679,22 +679,22 @@ if (empty($action) || $action == "view" || $action == "close") print '
'; if ($contextpage != 'takepos') print '
'; - } else { - print '
'; - print ''; + } else { + print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; - print ''; - } else { - print ''; - } + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; + print ''; + } else { + print ''; + } - /* + /* print '
'; print ''; print ''; @@ -745,127 +745,127 @@ if (empty($action) || $action == "view" || $action == "close") print ''; */ - // Table to see/enter balance - if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') - { - $posmodule = $object->posmodule; - $terminalid = $object->posnumber; + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; - print '
'; + print '
'; - print '
'; - print '
'; + print '
'; + print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - print ''; - print ''; + print ''; + print ''; + print ''; + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - print ''; - // Initial amount - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print '
'.$langs->trans("InitialBankBalance"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans("InitialBankBalance"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'; - print $langs->trans("AmountAtEndOfPeriod"); - print '
'; + print $langs->trans("AmountAtEndOfPeriod"); + print '
'.$langs->trans("Cash"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans($val); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans("Cash"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans($val); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans("NbOfInvoices").''; - print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print '
'.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
'.$langs->trans("TheoricalAmount").''; - print price($initialbalanceforterminal[$terminalid]['cash']).'
'; - print '
'; - if ($key == 'cash') { - $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); - print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; - } else { - print price($theoricalamountforterminal[$terminalid][$key]).'
'; - } - print '
'.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
'; + print '
'; + if ($key == 'cash') { + $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); + print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; + } else { + print price($theoricalamountforterminal[$terminalid][$key]).'
'; + } + print '
'.$langs->trans("RealAmount").''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($action == 'start') print ''; - elseif ($action == 'close') print ''; - print '
'.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
'; - print '
'; - } + print '
'; + print '
'; + } - print ''; - } - } + print ''; + } + } } // End of page diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 0f60be3c3a8..07cffb3bf2c 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -66,8 +66,8 @@ class CashControl extends CommonObject 'cash' =>array('type'=>'price', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), 'cheque' =>array('type'=>'price', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33), 'card' =>array('type'=>'price', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36), - 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), - 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), + 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), + 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60, 'css'=>'center'), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), @@ -94,8 +94,8 @@ class CashControl extends CommonObject public $date_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -311,8 +311,8 @@ class CashControl extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); } /** @@ -357,10 +357,10 @@ class CashControl extends CommonObject * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -381,24 +381,24 @@ class CashControl extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - /* + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c474054b2b4..515067900e3 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -29,8 +29,8 @@ * \brief List of bank transactions */ -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; @@ -52,13 +52,13 @@ $sortorder = 'ASC'; $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), + 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); $syear = $cashcontrol->year_close; @@ -141,10 +141,10 @@ if ($resql) { print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); print "
"; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - $param = ''; + $param = ''; // Fields title print ''; @@ -162,24 +162,24 @@ if ($resql) { $sign = 1; $cash = $bank = $cheque = $other = 0; - $totalarray = array(); - $cachebankaccount = array(); - $amountpertype = array(); - while ($i < $num) { - $objp = $db->fetch_object($resql); + $totalarray = array(); + $cachebankaccount = array(); + $amountpertype = array(); + while ($i < $num) { + $objp = $db->fetch_object($resql); - if (empty($cachebankaccount[$objp->bankid])) { - $bankaccounttmp = new Account($db); - $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid] = $bankaccounttmp; - $bankaccount = $bankaccounttmp; - } else { - $bankaccount = $cachebankaccount[$objp->bankid]; - } + if (empty($cachebankaccount[$objp->bankid])) { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid] = $bankaccounttmp; + $bankaccount = $bankaccounttmp; + } else { + $bankaccount = $cachebankaccount[$objp->bankid]; + } - $invoicetmp->fetch($objp->facid); + $invoicetmp->fetch($objp->facid); - /*if ($first == "yes") + /*if ($first == "yes") { print ''; print ''; @@ -191,19 +191,19 @@ if ($resql) { print ''; // Ref - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; - // Date ope - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Date ope + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Bank account - print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; - // Type - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Type + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Debit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; + // Debit + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; - // Credit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; + $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; + } + print "\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; print ""; @@ -304,7 +304,7 @@ if ($resql) { print ""; - print ''; + print ''; $db->free($resql); } else { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index dae7ca358ac..79182ca89bd 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -104,10 +104,10 @@ print ''; $nav = ''; if ($mode != 'sconly') { - $nav = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); + $nav = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); } else { - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); } if ($year) $param .= '&year='.$year; @@ -135,7 +135,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -200,27 +200,27 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '\n"; // Date payment print ''; - // Type payment - print ''; + // Type payment + print ''; // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } + if (!empty($conf->banque->enabled)) + { + print ''; + } // Paid print ''; - print ''; // A total here has no sense - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print '"; + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print '"; print ""; } else { dol_print_error($db); @@ -276,11 +276,11 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'
'; - print $invoicetmp->getNomUrl(1); - print ''; + print $invoicetmp->getNomUrl(1); + print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print "'; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print "'; + // Bank account + print ''; print $bankaccount->getNomUrl(1); if ($cashcontrol->posmodule == "takepos") { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; @@ -221,36 +221,36 @@ if ($resql) { else $other += $objp->amount; } print "'; - print $objp->code; - if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; - print "'; + print $objp->code; + if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; + print "'; - if ($objp->amount < 0) { - print price($objp->amount * -1); - $totalarray['val']['totaldebfield'] += $objp->amount; - $amountpertype[$objp->code] += $objp->amount; - } - print "'; + if ($objp->amount < 0) { + print price($objp->amount * -1); + $totalarray['val']['totaldebfield'] += $objp->amount; + $amountpertype[$objp->code] += $objp->amount; + } + print "'; - if ($objp->amount > 0) { + // Credit + print ''; + if ($objp->amount > 0) { print price($objp->amount); - $totalarray['val']['totalcredfield'] += $objp->amount; - $amountpertype[$objp->code] -= $objp->amount; - } - print "
'.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''; if ($obj->totalpaye) print price($obj->totalpaye); @@ -232,13 +232,13 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $totalpaye = $totalpaye + $obj->totalpaye; $i++; } - print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'.$langs->trans("Total").'   '.price($totalpaye)."
'; - print ''; + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
'; + print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); @@ -289,72 +289,72 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print "\n"; - $var = 1; - while ($i < $num) - { - $obj = $db->fetch_object($result); + print "\n"; + $var = 1; + while ($i < $num) + { + $obj = $db->fetch_object($result); - $total = $total + $obj->amount; + $total = $total + $obj->amount; - print ''; - print ''."\n"; + print ''; + print ''."\n"; - print "\n"; + print "\n"; - print '"; + print '"; - // Ref payment + // Ref payment $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; - print '\n"; + print '\n"; - // Date - print '\n"; + // Date + print '\n"; - // Type payment - print ''; + // Type payment + print ''; - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } + // Account + if (!empty($conf->banque->enabled)) + { + print ''; + } - // Paid - print '"; - print "\n"; + // Paid + print '"; + print "\n"; - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '"; - print ""; + $i++; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; - print "
'.dol_print_date($db->jdate($obj->dm), 'day').'
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."".$obj->label."'.price($obj->amount)."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'.dol_print_date($db->jdate($obj->dm), 'day')."'; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''.price($obj->amount)."
'.price($obj->amount)."
'.$langs->trans("Total").''.price($total).'    '.price($total)."
'.$langs->trans("Total").''.price($total).'    '.price($total)."
"; - $db->free($result); + print ""; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } } } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 69baf710b95..1a1fd42d21b 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -59,22 +59,22 @@ class Deplacement extends CommonObject public $ismultientitymanaged = 0; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date (dated) - * - * @var integer - */ + /** + * Date (dated) + * + * @var integer + */ public $dated; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** @@ -82,20 +82,20 @@ class Deplacement extends CommonObject */ public $fk_user; - /** - * @var string km value formatted - */ - public $km; + /** + * @var string km value formatted + */ + public $km; - /** - * @var int Thirdparty id - */ + /** + * @var int Thirdparty id + */ public $socid; - /** - * @var int Status 0=draft, 1=validated, 2=Refunded - */ - public $statut; + /** + * @var int Status 0=draft, 1=validated, 2=Refunded + */ + public $statut; public $extraparams = array(); public $statuts = array(); @@ -116,7 +116,7 @@ class Deplacement extends CommonObject */ const STATUS_REFUNDED = 2; - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -125,8 +125,8 @@ class Deplacement extends CommonObject { $this->db = $db; - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); } /** @@ -152,9 +152,9 @@ class Deplacement extends CommonObject return -1; } - $now = dol_now(); + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement ("; $sql .= "datec"; @@ -185,14 +185,14 @@ class Deplacement extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); - // Call trigger - $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers $result = $this->update($user); if ($result > 0) @@ -226,12 +226,12 @@ class Deplacement extends CommonObject // Check parameters if (!is_numeric($this->km)) $this->km = 0; - if (empty($this->date)) - { - $this->error = 'ErrorBadParameter'; - return -1; - } - if (empty($this->type) || $this->type < 0) + if (empty($this->date)) + { + $this->error = 'ErrorBadParameter'; + return -1; + } + if (empty($this->type) || $this->type < 0) { $this->error = 'ErrorBadParameter'; return -1; @@ -270,7 +270,7 @@ class Deplacement extends CommonObject } } - /** + /** * Load an object from database * * @param int $id Id of record to load @@ -312,7 +312,7 @@ class Deplacement extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete @@ -349,7 +349,7 @@ class Deplacement extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -359,7 +359,7 @@ class Deplacement extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -402,15 +402,15 @@ class Deplacement extends CommonObject global $langs; $result = ''; - $label = $langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; - $link = ''; + $link = ''; $linkend = ''; $picto = 'trip'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.$this->ref.$linkend; return $result; @@ -425,31 +425,31 @@ class Deplacement extends CommonObject */ public function listOfTypes($active = 1) { - global $langs; + global $langs; - $ret = array(); + $ret = array(); - $sql = "SELECT id, code, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql = "SELECT id, code, label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; + $sql .= " WHERE active = ".$active; - dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); - $i++; - } - } else { - dol_print_error($this->db); - } + dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); + $i++; + } + } else { + dol_print_error($this->db); + } - return $ret; + return $ret; } /** diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 953ee78a3d6..d6ad82a4cbe 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -30,24 +30,24 @@ include_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php' */ class DeplacementStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** * Constructor * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param mixed $userid Id user for filter or array of user ids + * @param mixed $userid Id user for filter or array of user ids * @return void */ public function __construct($db, $socid = 0, $userid = 0) @@ -55,8 +55,8 @@ class DeplacementStats extends Stats global $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Deplacement($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; @@ -69,7 +69,7 @@ class DeplacementStats extends Stats $this->where .= " AND fk_soc = ".$this->socid; } if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; + elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; } @@ -93,7 +93,7 @@ class DeplacementStats extends Stats * Renvoie le nombre de facture par mois pour une annee donnee * * @param string $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getNbByMonth($year, $format = 0) @@ -103,7 +103,7 @@ class DeplacementStats extends Stats $sql .= " WHERE YEAR(dated) = ".$year; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; @@ -115,7 +115,7 @@ class DeplacementStats extends Stats * Renvoie le montant de facture par mois pour une annee donnee * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getAmountByMonth($year, $format = 0) @@ -145,7 +145,7 @@ class DeplacementStats extends Stats $sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - public function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql .= " FROM ".$this->from; - $sql .= " WHERE ".$this->where; - $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 4768e082431..86d0dd383f1 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -101,9 +101,9 @@ if ($object->id) } - print ''; + print '
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print '"; - print ''; - print ''; - print '
'.$langs->trans("Ref").''; @@ -113,16 +113,16 @@ if ($object->id) // Societe //print "
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print '
'; - $modulepart = 'deplacement'; - $permission = $user->rights->deplacement->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'deplacement'; + $permission = $user->rights->deplacement->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 0cea847f9ce..bcebeb128d0 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -74,20 +74,20 @@ $sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $somme[$objp->type] = $objp->km; - $nb[$objp->type] = $objp->nb; - $totalnb += $objp->nb; - $i++; - } - $db->free($result); + $somme[$objp->type] = $objp->km; + $nb[$objp->type] = $objp->nb; + $totalnb += $objp->nb; + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -106,24 +106,24 @@ print "\n"; $listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) { - print ''; + print ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb ? 0 : 1); - print ''; + print ''; } print ''; @@ -156,46 +156,46 @@ $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var = false; - $num = $db->num_rows($result); + $var = false; + $num = $db->num_rows($result); - $i = 0; + $i = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - $total_ttc = $totalam = $total = 0; + print '
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $total_ttc = $totalam = $total = 0; - $deplacementstatic = new Deplacement($db); - $userstatic = new User($db); - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - $deplacementstatic->ref = $obj->rowid; - $deplacementstatic->id = $obj->rowid; - $userstatic->id = $obj->uid; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $i++; - } - } else { - print ''; - } - print '
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("None").'

'; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print '
'; } else dol_print_error($db); diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index 08c3ca768ee..586eac52ee7 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -52,11 +52,11 @@ if ($id) print dol_get_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); - print '
'; - dol_print_object_info($object); - print '
'; + print '
'; + dol_print_object_info($object); + print '
'; - print '
'; + print ''; } // End of page diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 78c1f32556d..df18b09e2b4 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -99,11 +99,11 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_ref) $sql .= " AND d.rowid=".$search_ref; if ($search_name) { - $sql .= natural_search('u.lastname', $search_name); + $sql .= natural_search('u.lastname', $search_name); } if ($search_company) { - $sql .= natural_search('s.nom', $search_company); + $sql .= natural_search('s.nom', $search_company); } $sql .= dolSqlDateFilter("d.dated", $day, $month, $year); @@ -114,90 +114,90 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); - $i = 0; - print '
'."\n"; - print ''; - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); - print_liste_field_titre(''); - print "\n"; + $i = 0; + print ''."\n"; + print '
'; + print ""; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre(''); + print "\n"; - // Filters lines - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + // Filters lines + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); - $soc = new Societe($db); - if ($obj->socid) $soc->fetch($obj->socid); + $soc = new Societe($db); + if ($obj->socid) $soc->fetch($obj->socid); - print ''; - // Id - print ''; - // Type - print ''; - // Date - print ''; - // User - print ''; + print ''; + // Id + print ''; + // Type + print ''; + // Date + print ''; + // User + print ''; - if ($obj->socid) print ''; - else print ''; + if ($obj->socid) print ''; + else print ''; - print ''; + print ''; - $tripandexpense_static->statut = $obj->fk_statut; - print ''; - print "\n"; + $tripandexpense_static->statut = $obj->fk_statut; + print ''; + print "\n"; - $i++; - } + $i++; + } - print "
'; - print ''; - print ''; - print ' '; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); - print ''; - print ''; - print ''; - print ''; - print ''; - // print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + print ''; + print ''; + print ' '; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print ''; + print ''; + print ''; + print ''; + print ''; + // print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; - $userstatic->id = $obj->fk_user; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print $userstatic->getNomUrl(1); - print '
'.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; + $userstatic->id = $obj->fk_user; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print $userstatic->getNomUrl(1); + print ''.$soc->getNomUrl(1).' '.$soc->getNomUrl(1).' '.$obj->km.''.$obj->km.''.$tripandexpense_static->getLibStatut(5).'
'.$tripandexpense_static->getLibStatut(5).'
"; - print "
\n"; - $db->free($resql); + print ""; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index e9a2a3a93a7..389c8d9408f 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -164,38 +164,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -203,7 +203,7 @@ if (!$mesg) $data = $stats->getAllByYear(); $arrayyears = array(); foreach ($data as $val) { - $arrayyears[$val['year']] = $val['year']; + $arrayyears[$val['year']] = $val['year']; } if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -293,11 +293,11 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); + print $px1->show(); print "
\n"; print $px2->show(); - print "
\n"; - print $px3->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 54234b4a10c..0e971954d56 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -79,9 +79,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -94,9 +94,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -109,9 +109,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 3f85d7ba074..dbc395e5d65 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -110,9 +110,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 5b1daff5913..c07eb3ac2aa 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 539fb89e675..772a3aa680c 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 0d483665e40..22f836e433b 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -191,15 +191,15 @@ if (empty($reshook)) $object->titre = GETPOST('title', 'nohtml'); // deprecated $object->title = GETPOST('title', 'nohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->model_pdf = GETPOST('modelpdf', 'alpha'); + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOST('auto_validate', 'int'); - $object->generate_pdf = GETPOST('generate_pdf', 'int'); + $object->generate_pdf = GETPOST('generate_pdf', 'int'); $object->fk_project = $projectid; $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); @@ -315,7 +315,7 @@ if (empty($reshook)) elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } // Set generate pdf + } // Set generate pdf elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); @@ -1047,12 +1047,12 @@ if ($action == 'create') print ""; } - // Model pdf - print "".$langs->trans('Model').""; - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = ModelePDFFactures::liste_modeles($db); - print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); - print ""; + // Model pdf + print "".$langs->trans('Model').""; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = ModelePDFFactures::liste_modeles($db); + print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); + print ""; print ""; @@ -1327,7 +1327,7 @@ if ($action == 'create') print ''; if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; - } + } print ''; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -1409,30 +1409,30 @@ if ($action == 'create') print ""; print ''; - // Model pdf - print ''; - print ''; - print '
'; - print $langs->trans('Model'); - print ''; - if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) - print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
'; - print ''; - if ($action == 'editmodelpdf') - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = array(); - $models = ModelePDFFactures::liste_modeles($db); - foreach ($models as $k => $model) { - $list[] = str_replace(':', '|', $k).':'.$model; - } - $select = 'select;'.implode(',', $list); - print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); - } else { - print $object->model_pdf; - } - print ""; - print ''; + // Model pdf + print ''; + print ''; + print '
'; + print $langs->trans('Model'); + print ''; + if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) + print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
'; + print ''; + if ($action == 'editmodelpdf') + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = array(); + $models = ModelePDFFactures::liste_modeles($db); + foreach ($models as $k => $model) { + $list[] = str_replace(':', '|', $k).':'.$model; + } + $select = 'select;'.implode(',', $list); + print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); + } else { + print $object->model_pdf; + } + print ""; + print ''; // Other attributes $cols = 2; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 74947b7c591..bd06f9b0967 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -175,19 +175,19 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. - $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $objectutil->socid = $socid; - $result = $objectutil->createFromClone($user, $id); - if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); - exit(); - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + $objectutil->socid = $socid; + $result = $objectutil->createFromClone($user, $id); + if ($result > 0) { + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); + exit(); + } else { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } // Change status of invoice elseif ($action == 'reopen' && $usercancreate) { $result = $object->fetch($id); @@ -352,29 +352,29 @@ if (empty($reshook)) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { - $object->fetch($id); - $object->retained_warranty_fk_cond_reglement = 0; // To clean property - $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); - if ($result < 0) dol_print_error($db, $object->error); + $object->fetch($id); + $object->retained_warranty_fk_cond_reglement = 0; // To clean property + $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); + if ($result < 0) dol_print_error($db, $object->error); - $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; - $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; - if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); + $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; + $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; + if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -419,22 +419,22 @@ if (empty($reshook)) $db->begin(); - if (! $error) { + if (!$error) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { - $error++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - if (! $error) { + if (!$error) { $old_date_lim_reglement = $object->date_lim_reglement; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; $result = $object->update($user); if ($result < 0) { - $error++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } @@ -875,16 +875,16 @@ if (empty($reshook)) // Total credit note and deposit $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".$object->id; - $resql = $db->query($sql); - if (!empty($resql)) { - while ($obj = $db->fetch_object($resql)) { - $total_creditnote_and_deposit += $obj->amount_ttc; - } - } else dol_print_error($db); + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -1086,12 +1086,12 @@ if (empty($reshook)) $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source) > 0) { - if ($facture_source->type == Facture::TYPE_SITUATION) - { - $object->situation_counter = $facture_source->situation_counter; - $object->situation_cycle_ref = $facture_source->situation_cycle_ref; - $facture_source->fetchPreviousNextSituationInvoice(); - } + if ($facture_source->type == Facture::TYPE_SITUATION) + { + $object->situation_counter = $facture_source->situation_counter; + $object->situation_cycle_ref = $facture_source->situation_cycle_ref; + $facture_source->fetchPreviousNextSituationInvoice(); + } } $id = $object->create($user); @@ -1122,84 +1122,84 @@ if (empty($reshook)) if ($facture_source->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($facture_source->tab_previous_situation_invoice)) - { - // search the last standard invoice in cycle and the possible credit note between this last and facture_source - // TODO Move this out of loop of $facture_source->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($facture_source->tab_previous_situation_invoice)) + { + // search the last standard invoice in cycle and the possible credit note between this last and facture_source + // TODO Move this out of loop of $facture_source->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $source_fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + $maxPrevSituationPercent = 0; + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $source_fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) - { - if ($prevLine->fk_prev_id == $source_fk_prev_id) - { - $maxPrevSituationPercent = $prevLine->situation_percent; + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) + { + if ($prevLine->fk_prev_id == $source_fk_prev_id) + { + $maxPrevSituationPercent = $prevLine->situation_percent; - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } - // prorata - $line->situation_percent += $maxPrevSituationPercent; + // prorata + $line->situation_percent += $maxPrevSituationPercent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + } } $line->fk_facture = $object->id; @@ -1282,7 +1282,7 @@ if (empty($reshook)) $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client'); - $object->model_pdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id')); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); @@ -1361,11 +1361,11 @@ if (empty($reshook)) $object->retained_warranty_fk_cond_reglement = 0; } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); $object->fetch_thirdparty(); @@ -1647,7 +1647,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, @@ -1737,7 +1737,7 @@ if (empty($reshook)) if (empty($datefacture)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1745,8 +1745,8 @@ if (empty($reshook)) if (!($_POST['situations'] > 0)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceSituation")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; + setEventMessages($mesg, null, 'errors'); + $action = 'create'; } if (!$error) { @@ -1764,23 +1764,23 @@ if (empty($reshook)) // retained warranty if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $retained_warranty = GETPOST('retained_warranty', 'int'); - if (price2num($retained_warranty) > 0) - { - $object->retained_warranty = price2num($retained_warranty); - } + $retained_warranty = GETPOST('retained_warranty', 'int'); + if (price2num($retained_warranty) > 0) + { + $object->retained_warranty = price2num($retained_warranty); + } - if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) - { - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - } + if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) + { + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - } + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + } foreach ($object->lines as $i => &$line) { @@ -1804,16 +1804,16 @@ if (empty($reshook)) // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { - $discount = new DiscountAbsolute($line->db); - $result = $discount->fetch($line->fk_remise_except); - if ($result > 0) - { - // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) - { - $line->fk_remise_except = 0; - } - } + $discount = new DiscountAbsolute($line->db); + $result = $discount->fetch($line->fk_remise_except); + if ($result > 0) + { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) + { + $line->fk_remise_except = 0; + } + } } } } @@ -2263,20 +2263,20 @@ if (empty($reshook)) if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { - // in case of situation credit note - if (GETPOST('progress') >= 0) - { - $mesg = $langs->trans("CantBeNullOrPositive"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result - { - $mesg = $langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } + // in case of situation credit note + if (GETPOST('progress') >= 0) + { + $mesg = $langs->trans("CantBeNullOrPositive"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result + { + $mesg = $langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } } elseif (GETPOST('progress') < $percent) { $mesg = '
'.$langs->trans("CantBeLessThanMinPercent").'
'; @@ -2422,13 +2422,13 @@ if (empty($reshook)) if (!$object->fetch($id) > 0) dol_print_error($db); if (GETPOST('all_progress') != "") { - $all_progress = GETPOST('all_progress', 'int'); + $all_progress = GETPOST('all_progress', 'int'); foreach ($object->lines as $line) { $percent = $line->get_prev_progress($object->id); if (floatval($all_progress) < floatval($percent)) { - $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); + $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); $result = -1; } else $object->update_percent($line, $_POST['all_progress']); } @@ -2439,192 +2439,192 @@ if (empty($reshook)) } // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate) { - $object->fetch($id, '', '', '', true); + $object->fetch($id, '', '', '', true); - if ($object->statut == Facture::STATUS_VALIDATED - && $object->type == Facture::TYPE_SITUATION - && $usercancreate - && !$objectidnext - && $object->is_last_in_cycle() - && $usercanunvalidate - ) - { - $outingError = 0; - $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle - if ($newCycle > 1) - { - // Search credit notes - $lastCycle = $object->situation_cycle_ref; - $lastSituationCounter = $object->situation_counter; - $linkedCreditNotesList = array(); + if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION + && $usercancreate + && !$objectidnext + && $object->is_last_in_cycle() + && $usercanunvalidate + ) + { + $outingError = 0; + $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle + if ($newCycle > 1) + { + // Search credit notes + $lastCycle = $object->situation_cycle_ref; + $lastSituationCounter = $object->situation_counter; + $linkedCreditNotesList = array(); - if (count($object->tab_next_situation_invoice) > 0) { - foreach ($object->tab_next_situation_invoice as $next_invoice) { - if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE - && $next_invoice->situation_counter == $object->situation_counter - && $next_invoice->fk_facture_source == $object->id - ) - { - $linkedCreditNotesList[] = $next_invoice->id; - } - } - } + if (count($object->tab_next_situation_invoice) > 0) { + foreach ($object->tab_next_situation_invoice as $next_invoice) { + if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE + && $next_invoice->situation_counter == $object->situation_counter + && $next_invoice->fk_facture_source == $object->id + ) + { + $linkedCreditNotesList[] = $next_invoice->id; + } + } + } - $object->situation_cycle_ref = $newCycle; - $object->situation_counter = 1; - $object->situation_final = 0; - if ($object->update($user) > 0) - { - $errors = 0; - if (count($linkedCreditNotesList) > 0) - { - // now, credit note must follow - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql .= ' SET situation_cycle_ref='.$newCycle; - $sql .= ' , situation_final=0'; - $sql .= ' , situation_counter='.$object->situation_counter; - $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; + $object->situation_cycle_ref = $newCycle; + $object->situation_counter = 1; + $object->situation_final = 0; + if ($object->update($user) > 0) + { + $errors = 0; + if (count($linkedCreditNotesList) > 0) + { + // now, credit note must follow + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; + $sql .= ' SET situation_cycle_ref='.$newCycle; + $sql .= ' , situation_final=0'; + $sql .= ' , situation_counter='.$object->situation_counter; + $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; - $resql = $db->query($sql); - if (!$resql) $errors++; + $resql = $db->query($sql); + if (!$resql) $errors++; - // Change each progression persent on each lines - foreach ($object->lines as $line) - { - // no traitement for special product - if ($line->product_type == 9) continue; + // Change each progression persent on each lines + foreach ($object->lines as $line) + { + // no traitement for special product + if ($line->product_type == 9) continue; - if (!empty($object->tab_previous_situation_invoice)) - { - // search the last invoice in cycle - $lineIndex = count($object->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($object->tab_previous_situation_invoice)) + { + // search the last invoice in cycle + $lineIndex = count($object->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $line->fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - } - } + $maxPrevSituationPercent = 0; + foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $line->fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + } + } - $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; + $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - if ($line->update() < 0) $errors++; - } - } - } + if ($line->update() < 0) $errors++; + } + } + } - if (!$errors) - { - setEventMessages($langs->trans('Updated'), '', 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); - } - } + if (!$errors) + { + setEventMessages($langs->trans('Updated'), '', 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); + } + } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $usercancreate - && $object->statut == Facture::STATUS_DRAFT - && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) + && $usercancreate + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - if ($object->type == Facture::TYPE_SITUATION) { - $situation_percent = 0; - } else { - $situation_percent = 100; - } - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + if ($object->type == Facture::TYPE_SITUATION) { + $situation_percent = 0; + } else { + $situation_percent = 100; + } + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } // Actions when printing a doc from card @@ -2885,7 +2885,7 @@ if ($action == 'create') $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
'; } @@ -3161,26 +3161,26 @@ if ($action == 'create') print '
'; } } else { - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - print '
'; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
'; + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + print '
'; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; - print '
'; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
'; - } + print '
'; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; + } - print '
'; + print '
'; $tmp = ' '; $text = ' '; $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; @@ -3263,8 +3263,8 @@ if ($action == 'create') print '
    0 ? 'checked' : '').' /> "; print '
'; - print '
'; - } + print '
'; + } } else { print '
'; if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; @@ -3291,17 +3291,17 @@ if ($action == 'create') if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { - // Add auto select default document model - $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); - $jsListType = ''; - foreach ($listtType as $type) - { - $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; - } + // Add auto select default document model + $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); + $jsListType = ''; + foreach ($listtType as $type) + { + $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; + $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; + } - print ''."\n"; } - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print '
'; - print '
'; - print $langs->trans("Type").':   '; - print '
'; - print ''; - print '   '; - print ''; - print '
'; - print "
\n"; + print '
'; + print '
'; + print $langs->trans("Type").':   '; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print "
\n"; - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label if ($refund == 1) { @@ -268,14 +268,14 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) + { print ''; - } + print ''; + } - // Type payment + // Type payment print '\n"; @@ -286,22 +286,22 @@ if ($action == 'create') print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ''."\n"; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - print '
'.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
'.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); - print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); + print '
'.$langs->trans("Amount").'
'.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available - print '
'.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); print "
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; - print '
'; + print ''; } // View mode diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 5f661609e52..b767e78294d 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -56,45 +56,45 @@ class Tva extends CommonObject public $num_payment; /** - * @var string label - */ - public $label; + * @var string label + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; $error = 0; $now = dol_now(); @@ -123,7 +123,7 @@ class Tva extends CommonObject $sql .= "fk_bank,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -136,41 +136,41 @@ class Tva extends CommonObject $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); - // Call trigger - $result = $this->call_trigger('TVA_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('TVA_CREATE', $user); + if ($result < 0) $error++; + // End call triggers - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { $this->db->rollback(); return -1; - } - } else { + } + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; @@ -188,7 +188,7 @@ class Tva extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " tms='".$this->db->idate($this->tms)."',"; $sql .= " datep='".$this->db->idate($this->datep)."',"; $sql .= " datev='".$this->db->idate($this->datev)."',"; @@ -198,46 +198,46 @@ class Tva extends CommonObject $sql .= " fk_bank=".$this->fk_bank.","; $sql .= " fk_user_creat=".$this->fk_user_creat.","; $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('TVA_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('TVA_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.tms,"; @@ -255,20 +255,20 @@ class Tva extends CommonObject $sql .= " b.fk_type,"; $sql .= " b.rappro"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); @@ -283,23 +283,23 @@ class Tva extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ public function delete($user) { global $conf, $langs; @@ -328,11 +328,11 @@ class Tva extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { @@ -350,154 +350,154 @@ class Tva extends CommonObject } - /** - * Balance of VAT - * - * @param int $year Year - * @return double Amount - */ - public function solde($year = 0) - { + /** + * Balance of VAT + * + * @param int $year Year + * @return double Amount + */ + public function solde($year = 0) + { - $reglee = $this->tva_sum_reglee($year); + $reglee = $this->tva_sum_reglee($year); - $payee = $this->tva_sum_payee($year); - $collectee = $this->tva_sum_collectee($year); + $payee = $this->tva_sum_payee($year); + $collectee = $this->tva_sum_collectee($year); - $solde = $reglee - ($collectee - $payee); + $solde = $reglee - ($collectee - $payee); - return $solde; - } + return $solde; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT from invoices emitted by the thirdparty. - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_collectee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT from invoices emitted by the thirdparty. + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_collectee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { - $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.tva) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; + if ($year) + { + $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_payee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_payee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.total_tva) as total_tva"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { - $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.total_tva) as total_tva"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + if ($year) + { + $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->total_tva; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->total_tva; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_reglee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_reglee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql = "SELECT sum(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; - if ($year) - { - $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; - } + if ($year) + { + $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - /** - * Create in database - * + /** + * Create in database + * * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK - */ - public function addPayment($user) - { - global $conf, $langs; + */ + public function addPayment($user) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); $this->note = trim($this->note); $this->num_payment = trim($this->num_payment); $this->fk_bank = (int) $this->fk_bank; @@ -505,81 +505,81 @@ class Tva extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; if (empty($this->datec)) $this->datec = dol_now(); - // Check parameters + // Check parameters if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -4; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -5; - } + if ($this->amount == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -4; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -5; + } - // Insert into llx_tva - $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; - $sql .= "datec"; - $sql .= ", datep"; - $sql .= ", datev"; + // Insert into llx_tva + $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; + $sql .= "datec"; + $sql .= ", datep"; + $sql .= ", datev"; $sql .= ", amount"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; - $sql .= ", fk_user_creat"; + if ($this->label) $sql .= ", label"; + $sql .= ", fk_user_creat"; $sql .= ", fk_bank"; $sql .= ", entity"; $sql .= ") "; - $sql .= " VALUES ("; - $sql .= " '".$this->db->idate($this->datec)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= " VALUES ("; + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", ".$this->amount; - $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; + if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", NULL"; $sql .= ", ".$conf->entity; - $sql .= ")"; + $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' - // Call trigger - //XXX: Should be done just befor commit no ? - $result = $this->call_trigger('TVA_ADDPAYMENT', $user); - if ($result < 0) - { - $this->id = 0; - $ok = 0; - } - // End call triggers + // Call trigger + //XXX: Should be done just befor commit no ? + $result = $this->call_trigger('TVA_ADDPAYMENT', $user); + if ($result < 0) + { + $this->id = 0; + $ok = 0; + } + // End call triggers - if ($this->id > 0) - { - $ok = 1; + if ($this->id > 0) + { + $ok = 1; if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); + $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); @@ -589,23 +589,23 @@ class Tva extends CommonObject $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user); } - // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction - if ($bank_line_id > 0) + // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction + if ($bank_line_id > 0) { - $this->update_fk_bank($bank_line_id); - } else { + $this->update_fk_bank($bank_line_id); + } else { $this->error = $acc->error; $ok = 0; } - // Update links - $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { - $this->error = $acc->error; - $ok = 0; - } - } + // Update links + $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) + { + $this->error = $acc->error; + $ok = 0; + } + } if ($ok) { @@ -615,27 +615,27 @@ class Tva extends CommonObject $this->db->rollback(); return -3; } - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between payment tva and line generate into llx_bank - * - * @param int $id_bank Id bank account + * + * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK - */ + */ public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; $sql .= ' WHERE rowid = '.(int) $this->id; $result = $this->db->query($sql); @@ -653,8 +653,8 @@ class Tva extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss More CSS + * @param int $notooltip 1=Disable tooltip + * @param string $morecss More CSS * @return string Chaine with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') @@ -669,23 +669,23 @@ class Tva extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; - $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; $picto = 'payment'; @@ -698,34 +698,34 @@ class Tva extends CommonObject } /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'paiementcharge'; - $field = 'fk_charge'; + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'paiementcharge'; + $field = 'fk_charge'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) $amount = $obj->amount ? $obj->amount : 0; - $this->db->free($resql); - return $amount; - } else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } /** * Informations of vat payment object @@ -780,10 +780,10 @@ class Tva extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -791,11 +791,11 @@ class Tva extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - return ''; - } + return ''; + } } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index a91d637c39d..cd0bbdd6c7a 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -53,10 +53,10 @@ $year = GETPOST("year", "int"); if (empty($year)) { $year_current = $current_date['year']; - $year_start = $year_current; + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); @@ -64,35 +64,35 @@ $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endda if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); - $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat - if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { - if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year - $year_start--; - } - } else { - if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year - $year_start--; - } - } - $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); - $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; - } - } - } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } - } + if (empty($q)) + { + if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } + } + } else { + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + } } $min = price2num(GETPOST("min", "alpha")); @@ -130,12 +130,12 @@ $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } $special_report = false; if (isset($_REQUEST['extra_report']) && $_REQUEST['extra_report'] == 1) { - $special_report = true; + $special_report = true; } llxHeader('', $langs->trans("VATReport"), '', '', 0, 0, '', '', $morequerystring); @@ -158,18 +158,18 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '. $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { - $prevquarter--; + $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { - $nextquarter++; + $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $builddate = dol_now(); @@ -178,7 +178,7 @@ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->t if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description .= '
'.$langs->trans("DepositsAreNotIncluded"); + $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); @@ -186,15 +186,15 @@ if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs $description .= ($description ? '
' : '').$fsearch; if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) { - $description .= '
'; - $description .= ' '; - $description .= $langs->trans('SimpleReport'); - $description .= ''; - $description .= '
'; - $description .= ' '; - $description .= $langs->trans('AddExtraReport'); - $description .= ''; - $description .= '
'; + $description .= '
'; + $description .= ' '; + $description .= $langs->trans('SimpleReport'); + $description .= ''; + $description .= '
'; + $description .= ' '; + $description .= $langs->trans('AddExtraReport'); + $description .= ''; + $description .= '
'; } $elementcust = $langs->trans("CustomersInvoices"); @@ -202,13 +202,13 @@ $productcust = $langs->trans("Description"); $namerate = $langs->trans("VATRate"); $amountcust = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatcust .= ' ('.$langs->trans("StatusToPay").')'; + $vatcust .= ' ('.$langs->trans("StatusToPay").')'; } $elementsup = $langs->trans("SuppliersInvoices"); $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatsup .= ' ('.$langs->trans("ToGetBack").')'; + $vatsup .= ' ('.$langs->trans("ToGetBack").')'; } report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); @@ -231,529 +231,529 @@ $x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'bu if (!is_array($x_coll) || !is_array($x_paye)) { - $langs->load("errors"); - if ($x_coll == -1) { - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - } elseif ($x_coll == -2) { - print ''.$langs->trans("FeatureNotYetAvailable").''; - } else { - print ''.$langs->trans("Error").''; - } + $langs->load("errors"); + if ($x_coll == -1) { + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + } elseif ($x_coll == -2) { + print ''.$langs->trans("FeatureNotYetAvailable").''; + } else { + print ''.$langs->trans("Error").''; + } } else { - $x_both = array(); - //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_thirdpartyid) - { - $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; - $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; - $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; - $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; - $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; - $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { - $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; - $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; - $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; - $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); - $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], - 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], - 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], - 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], - 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) - ); - } - } - // tva paid - foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { - $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; - $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; - if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { - $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; - $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; - } - $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; - $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach (array_keys($x_coll) as $my_coll_thirdpartyid) + { + $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; + $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; + $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; + $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; + $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; + $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); + foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; + $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; + $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_customer->getNomUrl(1, '', 12) + ); + } + } + // tva paid + foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { + $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; + $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; + if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { + $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; + $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; + } + $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; + $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) - { - // ExpenseReport - if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') - { - $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') + { + $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) - ); - } else { - $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], - 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) - ); - } - } - } - //now we have an array (x_both) indexed by rates for coll and paye + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$expensereport->getNomUrl(1) + ); + } else { + $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye - //print table headers for this quadri - incomes first + //print table headers for this quadri - incomes first - $x_coll_sum = 0; - $x_coll_ht = 0; - $x_paye_sum = 0; - $x_paye_ht = 0; + $x_coll_sum = 0; + $x_coll_ht = 0; + $x_paye_sum = 0; + $x_paye_ht = 0; - $span = $columns; - if ($modetax != 1) $span += 2; + $span = $columns; + if ($modetax != 1) $span += 2; - //print ''..')'; + //print ''..')'; - // Customers invoices - print ''; - print ''.$elementcust.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namerate.''; - print ''.$productcust.''; - if ($modetax != 1) - { - print ''.$amountcust.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealReceived").''; - print ''.$vatcust.''; - print ''; + // Customers invoices + print ''; + print ''.$elementcust.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namerate.''; + print ''.$productcust.''; + if ($modetax != 1) + { + print ''.$amountcust.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealReceived").''; + print ''.$vatcust.''; + print ''; - $action = "tvadetail"; - $parameters["mode"] = $modetax; - $parameters["start"] = $date_start; - $parameters["end"] = $date_end; - $parameters["type"] = 'vat'; + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $parameters["type"] = 'vat'; - $object = array(&$x_coll, &$x_paye, &$x_both); - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - foreach (array_keys($x_coll) as $thirdparty_id) { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + foreach (array_keys($x_coll) as $thirdparty_id) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) - { - if (is_array($x_both[$thirdparty_id]['coll']['detail'])) - { - // VAT Rate - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) + { + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) + { + // VAT Rate + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Rate - print ''.$fields['drate'].''; + // Rate + print ''.$fields['drate'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) { - print ''; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) { - $payment_static->id = $fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { + $payment_static->id = $fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // Total collected - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // Total collected + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; - } - } + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; + } + } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Blank line - print ' '; + // Blank line + print ' '; - // Print table headers for this quadri - expenses now - print ''; - print ''.$elementsup.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namesup.''; - print ''.$productsup.''; - if ($modetax != 1) { - print ''.$amountsup.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealPaid").''; - print ''.$vatsup.''; - print ''."\n"; + // Print table headers for this quadri - expenses now + print ''; + print ''.$elementsup.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namesup.''; + print ''.$productsup.''; + if ($modetax != 1) { + print ''.$amountsup.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealPaid").''; + print ''.$vatsup.''; + print ''."\n"; - foreach (array_keys($x_paye) as $thirdparty_id) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + foreach (array_keys($x_paye) as $thirdparty_id) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { - if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Company name - print ''.$fields['company_link'].''; + // Company name + print ''.$fields['company_link'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id = $fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id = $fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // VAT paid - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // VAT paid + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - // Total suppliers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; - print ''; - } - } + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + // Total suppliers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''; + } + } - if (count($x_paye) == 0) { // Show a total line if nothing shown - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Total to pay - print ''; + // Total to pay + print ''; - $diff = $x_coll_sum - $x_paye_sum; - print ''; - print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; - print ''.price(price2num($diff, 'MT'))."\n"; - print "\n"; + $diff = $x_coll_sum - $x_paye_sum; + print ''; + print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; + print ''.price(price2num($diff, 'MT'))."\n"; + print "\n"; - $i++; + $i++; } print ''; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 10efd84288c..e310e61fcb8 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -36,8 +36,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -58,7 +58,7 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { - $page = 0; + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -82,10 +82,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); - $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); } @@ -104,9 +104,9 @@ if ($object->id) { $alreadypayed = $object->getSommePaiement(); - $head = vat_prepare_head($object); + $head = vat_prepare_head($object); - print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); + print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
'; // Label of social contribution @@ -123,33 +123,33 @@ if ($object->id) print '
'; print '
'; - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - print ''; + print '
'; - print ''; - print ''; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print '
'; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $permission = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->fournisseur->facture->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $permission = $user->rights->tax->charges->creer; + $permtoedit = $user->rights->fournisseur->facture->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index a4fd1293b4d..4a16d996ab8 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -108,100 +108,100 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs; + global $conf, $bc, $langs; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $totalclaimed = 0; - $totalpaid = 0; - $amountclaimed = 0; - $amountpaid = 0; - $previousmonth = ''; - $previousmode = ''; - $mode = ''; + $totalclaimed = 0; + $totalpaid = 0; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; + $mode = ''; - while ($i < $num) { - $obj = $db->fetch_object($result); - $mode = $obj->mode; + while ($i < $num) { + $obj = $db->fetch_object($result); + $mode = $obj->mode; - //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - if ($obj->mode == 'claimed') - { - $amountclaimed = $obj->mm; - $totalclaimed = $totalclaimed + $amountclaimed; - } - if ($obj->mode == 'paid') - { - $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaid; - } + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } - if ($obj->mode == 'paid') - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - $previousmode = ''; - $previousmonth = ''; - } else { - $previousmode = $obj->mode; - $previousmonth = $obj->dm; - } + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } else { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } - $i++; - } + $i++; + } - if ($mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + if ($mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - print ''; - print ''; - print ''; - print ''; - print ""; + print ''; + print ''; + print ''; + print ''; + print ""; - print "
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; + print ""; - $db->free($result); - } else { - dol_print_error($db); - } + $db->free($result); + } else { + dol_print_error($db); + } } @@ -392,144 +392,144 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } //now we have an array (x_both) indexed by rates for coll and paye - $action = "tva"; - $object = array(&$x_coll, &$x_paye, &$x_both); - $parameters["mode"] = $modetax; - $parameters["year"] = $y; - $parameters["month"] = $m; - $parameters["type"] = 'vat'; + $action = "tva"; + $object = array(&$x_coll, &$x_paye, &$x_both); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + $parameters["type"] = 'vat'; - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { - $langs->load("errors"); - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) - { - print ''.$langs->trans("FeatureNotYetAvailable").''; - break; - } + if (!is_array($x_coll) && $coll_listbuy == -1) + { + $langs->load("errors"); + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + break; + } + if (!is_array($x_paye) && $coll_listbuy == -2) + { + print ''.$langs->trans("FeatureNotYetAvailable").''; + break; + } - print ''; - print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; + print ''; + print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; - $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - print ''.price(price2num($x_coll_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ''.price(price2num($x_coll_sum, 'MT')).''; - $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - print ''.price(price2num($x_paye_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ''.price(price2num($x_paye_sum, 'MT')).''; - $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = price2num($subtotal + $diff, 'MT'); + $diff = $x_coll_sum - $x_paye_sum; + $total = $total + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print ''.price(price2num($diff, 'MT')).''."\n"; - print " \n"; - print "\n"; + print ''.price(price2num($diff, 'MT')).''."\n"; + print " \n"; + print "\n"; - $i++; $m++; - if ($i > 2) - { - print ''; - print ''.$langs->trans("SubTotal").':'; - print ''.price(price2num($subtotalcoll, 'MT')).''; - print ''.price(price2num($subtotalpaye, 'MT')).''; - print ''.price(price2num($subtotal, 'MT')).''; - print ' '; - $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; - } + $i++; $m++; + if ($i > 2) + { + print ''; + print ''.$langs->trans("SubTotal").':'; + print ''.price(price2num($subtotalcoll, 'MT')).''; + print ''.price(price2num($subtotalpaye, 'MT')).''; + print ''.price(price2num($subtotal, 'MT')).''; + print ' '; + $i = 0; + $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + } } print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; print " \n"; @@ -578,37 +578,37 @@ if (!empty($conf->global->MAIN_FEATURES_LEVEL)) * Recap */ - print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - $sql1 = "SELECT SUM(amount) as mm"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; - $sql1 .= " WHERE f.entity = ".$conf->entity; - $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; - $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; + $sql1 = "SELECT SUM(amount) as mm"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql1 .= " WHERE f.entity = ".$conf->entity; + $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; + $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; - $result = $db->query($sql1); - if ($result) { - $obj = $db->fetch_object($result); - print ''; + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print '
'; - print ""; - print ''; - print ''; - print "\n"; + print ""; + print ''; + print ''; + print "\n"; - print ""; - print ''; - print '\n"; - print "\n"; + print ""; + print ''; + print '\n"; + print "\n"; - $restopay = $total - $obj->mm; - print ""; - print ''; - print ''; - print "\n"; + $restopay = $total - $obj->mm; + print ""; + print ''; + print ''; + print "\n"; - print '
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'; - } + print ''; + } } print '
'; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 554143e7a7e..a142518279f 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -44,26 +44,26 @@ $langs->loadLangs(array('compta', 'bills')); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist'; $search_ref = GETPOST('search_ref', 'alpha'); -$search_label = GETPOST('search_label', 'alpha'); -$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); -$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); -$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); -$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); -$search_type = GETPOST('search_type', 'int'); -$search_cheque = GETPOST('search_cheque', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); +$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); +$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); +$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); +$search_type = GETPOST('search_type', 'int'); +$search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -357,13 +357,13 @@ while ($i < min($num, $limit)) { } // Label - if (!empty($arrayfields['t.label']['checked'])) { + if (!empty($arrayfields['t.label']['checked'])) { print ''.dol_trunc($obj->label, 40).''; if (!$i) $totalarray['nbfield']++; } // Date end period - if (!empty($arrayfields['t.datev']['checked'])) { + if (!empty($arrayfields['t.datev']['checked'])) { print ''.dol_print_date($db->jdate($obj->datev), 'day').''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 8fb4c32bf72..ba12b08b3b0 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -159,16 +159,16 @@ $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $description .= $fsearch; $builddate = dol_now(); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 95ec50be24f..2aeb2e4e2a1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -67,17 +67,17 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -110,19 +110,19 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $actioncode = ''; - $search_agenda_label = ''; - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } } @@ -140,138 +140,138 @@ llxHeader('', $title, $help_url); if ($socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); + $objsoc = new Societe($db); + $objsoc->fetch($socid); } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if (empty($object->error) && $id) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { $object = new Contact($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } - } + // Confirm deleting contact + if ($user->rights->societe->contact->supprimer) + { + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } - /* + /* * Onglets */ - $head = array(); - if ($id > 0) - { - // Si edition contact deja existant - $object = new Contact($db); - $res = $object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res = $object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + $head = array(); + if ($id > 0) + { + // Si edition contact deja existant + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { dol_print_error($db, $object->error); exit; } + $res = $object->fetch_optionals(); + if ($res < 0) { dol_print_error($db, $object->error); exit; } - // Show tabs - $head = contact_prepare_head($object); + // Show tabs + $head = contact_prepare_head($object); - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - } + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); - /* + /* * Fiche en mode visualisation */ - dol_htmloutput_errors($error, $errors); + dol_htmloutput_errors($error, $errors); - print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; + print '
'; - $object->info($id); - dol_print_object_info($object, 1); + $object->info($id); + dol_print_object_info($object, 1); - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - // Actions buttons + // Actions buttons - $objcon = $object; - $object->fetch_thirdparty(); - $objthirdparty = $object->thirdparty; + $objcon = $object; + $object->fetch_thirdparty(); + $objthirdparty = $object->thirdparty; - $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) + { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); - } + } - $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) - { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); - } - } + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) + { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + print '
'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); - //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); + print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } - } + show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } + } } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 415d9e47790..f6f6fa0b45e 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsContactCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -55,14 +55,14 @@ abstract class ActionsContactCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - /*$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + /*$ret = $this->getInstanceDao(); if (is_object($this->object) && method_exists($this->object,'fetch')) { @@ -70,39 +70,39 @@ abstract class ActionsContactCardCommon } else {*/ - $object = new Contact($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Contact($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) - { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) + { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') - { - if ($conf->use_javascript_ajax) + if ($action == 'create' || $action == 'edit') + { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) + { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) - { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; - if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; + if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Public or private - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); - } + // Public or private + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { - // Emailing - if (!empty($conf->mailing->enabled)) + if ($action == 'view' || $action == 'edit' || $action == 'delete') + { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Linked element - $this->tpl['contact_element'] = array(); - $i = 0; + // Linked element + $this->tpl['contact_element'] = array(); + $i = 0; - $this->object->load_ref_elements(); + $this->object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); - $i++; - } - if (!empty($conf->propal->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); - $i++; - } - if (!empty($conf->contrat->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); - $i++; - } - if (!empty($conf->facture->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - $i++; - } + if (!empty($conf->commande->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); + $i++; + } + if (!empty($conf->propal->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); + $i++; + } + if (!empty($conf->contrat->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); + $i++; + } + if (!empty($conf->facture->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + $i++; + } - // Dolibarr user - if ($this->object->user_id) + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') - { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') + { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) + { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); + $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') - { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') + { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->socid = $_POST["socid"]; - $this->object->lastname = $_POST["name"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->poste = $_POST["poste"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_pro = $_POST["phone_pro"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->fax = $_POST["fax"]; - $this->object->email = $_POST["email"]; - $this->object->jabberid = $_POST["jabberid"]; - $this->object->priv = $_POST["priv"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->socid = $_POST["socid"]; + $this->object->lastname = $_POST["name"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->poste = $_POST["poste"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_pro = $_POST["phone_pro"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->fax = $_POST["fax"]; + $this->object->email = $_POST["email"]; + $this->object->jabberid = $_POST["jabberid"]; + $this->object->priv = $_POST["priv"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - } else { - dol_print_error($this->db); - } - $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - } - } + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) + { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + } else { + dol_print_error($this->db); + } + $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + } + } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 099c973b0a4..d399584b48d 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -29,22 +29,22 @@ include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class */ class ActionsContactCardDefault extends ActionsContactCardCommon { - /** - * Constructor - * - * @param DoliDB $db Handler acces base de donnees - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) - */ - public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + /** + * Constructor + * + * @param DoliDB $db Handler acces base de donnees + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -76,50 +76,50 @@ class ActionsContactCardDefault extends ActionsContactCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = contact_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = contact_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->societe->contact->supprimer) - { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->societe->contact->supprimer) + { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,13 +129,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { + // phpcs:enable + global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); - } + $this->list_datas = array(); + } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index b4406207977..956c78c1679 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1249,14 +1249,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - // Select mail models is same action as presend - if (GETPOST('modelselected', 'alpha')) { - $action = 'presend'; - } + // Select mail models is same action as presend + if (GETPOST('modelselected', 'alpha')) { + $action = 'presend'; + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); // View mode diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 10c844f3149..cd058bd716c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -142,63 +142,63 @@ class Contact extends CommonObject public $state_code; // Code of department public $state; // Label of department - public $poste; // Position + public $poste; // Position public $socid; // fk_soc public $statut; // 0=inactif, 1=actif public $code; - /** - * Email - * @var string - */ + /** + * Email + * @var string + */ public $email; - /** - * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings + /** + * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings * @var int - */ + */ public $no_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; /** - * Twitter username - * @var string - * @deprecated - */ + * Twitter username + * @var string + * @deprecated + */ public $twitter; /** - * Facebook username - * @var string - * @deprecated - */ + * Facebook username + * @var string + * @deprecated + */ public $facebook; /** - * Linkedin username - * @var string - * @deprecated - */ - public $linkedin; + * Linkedin username + * @var string + * @deprecated + */ + public $linkedin; - /** - * Jabber username - * @var string - * @deprecated - */ + /** + * Jabber username + * @var string + * @deprecated + */ public $jabberid; public $photo; @@ -227,10 +227,10 @@ class Contact extends CommonObject // END MODULEBUILDER PROPERTIES - /** - * Old copy - * @var Contact - */ + /** + * Old copy + * @var Contact + */ public $oldcopy; // To contains a clone of this when we need to save old properties of object public $roles = array(); @@ -292,7 +292,7 @@ class Contact extends CommonObject }*/ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * @@ -300,7 +300,7 @@ class Contact extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -310,14 +310,14 @@ class Contact extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $clause = "AND"; } $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; + if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; $resql = $this->db->query($sql); if ($resql) @@ -352,9 +352,9 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); - $this->firstname = trim($this->firstname); + $this->firstname = trim($this->firstname); $this->setUpperOrLowerCase(); - if (empty($this->socid)) $this->socid = 0; + if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -363,11 +363,11 @@ class Contact extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql .= " datec"; $sql .= ", fk_soc"; - $sql .= ", lastname"; - $sql .= ", firstname"; - $sql .= ", fk_user_creat"; + $sql .= ", lastname"; + $sql .= ", firstname"; + $sql .= ", fk_user_creat"; $sql .= ", priv"; - $sql.= ", fk_stcommcontact"; + $sql .= ", fk_stcommcontact"; $sql .= ", statut"; $sql .= ", canvas"; $sql .= ", entity"; @@ -381,7 +381,7 @@ class Contact extends CommonObject $sql .= "'".$this->db->escape($this->firstname)."',"; $sql .= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "null").","; $sql .= " ".$this->db->escape($this->priv).","; - $sql.= " 0,"; + $sql .= " 0,"; $sql .= " ".$this->db->escape($this->statut).","; $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; $sql .= " ".$this->db->escape($this->entity).","; @@ -397,41 +397,41 @@ class Contact extends CommonObject if (!$error) { - $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } + $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) - { - $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + { + $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - // Call trigger - $result = $this->call_trigger('CONTACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error) + { + // Call trigger + $result = $this->call_trigger('CONTACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -2; - } + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); @@ -494,7 +494,7 @@ class Contact extends CommonObject $sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); @@ -518,22 +518,22 @@ class Contact extends CommonObject $result = $this->db->query($sql); if ($result) { - unset($this->country_code); - unset($this->country); - unset($this->state_code); - unset($this->state); + unset($this->country_code); + unset($this->country); + unset($this->state_code); + unset($this->state); - $action = 'update'; + $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (!$error) { $result = $this->updateRoles(); @@ -640,14 +640,14 @@ class Contact extends CommonObject } } else { $this->error = $this->db->lasterror().' sql='.$sql; - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -659,7 +659,7 @@ class Contact extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; @@ -669,8 +669,8 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Initialise tableau info (tableau des attributs LDAP) * @@ -678,12 +678,12 @@ class Contact extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; - $info = array(); + $info = array(); - // Object classes + // Object classes $info["objectclass"] = explode(',', $conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname = $this->getFullName($langs); @@ -712,8 +712,8 @@ class Contact extends CommonObject if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; - if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; + if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') @@ -745,22 +745,22 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * * @param int $id Id of contact * @param User $user User asking to change alert or birthday * @param int $notrigger 0=no, 1=yes - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function update_perso($id, $user = null, $notrigger = 0) { - // phpcs:enable - $error = 0; - $result = false; + // phpcs:enable + $error = 0; + $result = false; - $this->db->begin(); + $this->db->begin(); // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; @@ -791,8 +791,8 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } else { $result = true; @@ -803,27 +803,27 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -$error; + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -$error; } } @@ -833,9 +833,9 @@ class Contact extends CommonObject * * @param int $id Id of contact * @param User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact - * @param string $ref_ext External reference, not given by Dolibarr - * @param string $email Email - * @param int $loadalsoroles Load also roles + * @param string $ref_ext External reference, not given by Dolibarr + * @param string $email Email + * @param int $loadalsoroles Load also roles * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ public function fetch($id, $user = null, $ref_ext = '', $email = '', $loadalsoroles = 0) @@ -859,9 +859,9 @@ class Contact extends CommonObject $sql .= " c.birthday,"; $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; $sql .= " c.socialnetworks,"; - $sql .= " c.photo,"; + $sql .= " c.photo,"; $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql.= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; + $sql .= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " c.import_key,"; $sql .= " c.datec as date_creation, c.tms as date_modification,"; $sql .= " co.label as country, co.code as country_code,"; @@ -873,7 +873,7 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; if ($id) $sql .= " WHERE c.rowid = ".((int) $id); else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; @@ -907,7 +907,7 @@ class Contact extends CommonObject $this->civility_code = $obj->civility_code; $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; - $this->lastname = $obj->lastname; + $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; @@ -931,11 +931,11 @@ class Contact extends CommonObject $this->fk_prospectlevel = $obj->fk_prospectcontactlevel; - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcommcontact); - $libelle=($transcode!='StatusProspect'.$obj->fk_stcommcontact?$transcode:$obj->stcomm); - $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial - $this->statut_commercial = $libelle; // libelle statut commercial - $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial + $transcode = $langs->trans('StatusProspect'.$obj->fk_stcommcontact); + $libelle = ($transcode != 'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial + $this->statut_commercial = $libelle; // libelle statut commercial + $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); @@ -1049,7 +1049,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1057,11 +1057,11 @@ class Contact extends CommonObject * ref_commande (for order and/or shipments) * ref_propale * - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function load_ref_elements() { - // phpcs:enable + // phpcs:enable // Compte les elements pour lesquels il est contact $sql = "SELECT tc.element, count(ec.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1187,18 +1187,18 @@ class Contact extends CommonObject } // Removed extrafields - if (!$error) { - // For avoid conflicts if trigger used + if (!$error) { + // For avoid conflicts if trigger used $result = $this->deleteExtraFields(); if ($result < 0) $error++; } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) @@ -1291,7 +1291,7 @@ class Contact extends CommonObject * @param string $option Where the link point to * @param int $maxlen Max length of * @param string $moreparam Add more param into URL - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip * @return string String with URL */ @@ -1309,40 +1309,40 @@ class Contact extends CommonObject } $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; - $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); - //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; - $label .= '
'.$langs->trans("EMail").': '.$this->email; - $phonelist = array(); - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); - $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); - $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); + //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code + if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; + $label .= '
'.$langs->trans("EMail").': '.$this->email; + $phonelist = array(); + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); + $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); - $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $url .= $moreparam; + $url .= $moreparam; - $linkclose = ""; + $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowContact"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowContact"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; - /* + /* $hookmanager->initHooks(array('contactdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1402,7 +1402,7 @@ class Contact extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1412,7 +1412,7 @@ class Contact extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; $labelStatus = array( @@ -1438,7 +1438,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * @@ -1447,7 +1447,7 @@ class Contact extends CommonObject */ public function LibPubPriv($status) { - // phpcs:enable + // phpcs:enable global $langs; if ($status == '1') return $langs->trans('ContactPrivate'); else return $langs->trans('ContactPublic'); @@ -1455,11 +1455,11 @@ class Contact extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return int >0 if ok + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return int >0 if ok */ public function initAsSpecimen() { @@ -1528,10 +1528,10 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); if ($result) { - // Call trigger - $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); + if ($result < 0) { $error++; } + // End call triggers } if ($error) @@ -1552,7 +1552,7 @@ class Contact extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1765,15 +1765,15 @@ class Contact extends CommonObject { global $langs; - $sql = "SELECT id, code, libelle as label, picto FROM " . MAIN_DB_PREFIX . "c_stcommcontact"; - if ($active >= 0) $sql .= " WHERE active = " . $active; + $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; + if ($active >= 0) $sql .= " WHERE active = ".$active; $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_" . strtoupper($obj->code)) == "ST_" . strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_" . strtoupper($obj->code)), 'picto' => $obj->picto); + $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto); $i++; } return 1; @@ -1799,9 +1799,9 @@ class Contact extends CommonObject { global $langs; - $lib = $langs->trans("ProspectLevel" . $fk_prospectlevel); + $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse - if ($lib == $langs->trans("ProspectLevel" . $fk_prospectlevel)) + if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } @@ -1853,13 +1853,13 @@ class Contact extends CommonObject if ($mode == 2) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } if ($mode == 3) @@ -1870,18 +1870,18 @@ class Contact extends CommonObject elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto); elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto); } } if ($mode == 4) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index d3992296aec..da00374cc2a 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -62,10 +62,10 @@ $year = GETPOST('year', 'int'); // Clean up on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sref = ''; - $sprod_fulldescr = ''; - $year = ''; - $month = ''; + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); @@ -113,11 +113,11 @@ $linkback = ''; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc->fetch($socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + $objsoc->fetch($socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } $morehtmlref .= ''; @@ -148,7 +148,7 @@ if ($object->thirdparty->fournisseur) { $thirdTypeArray['supplier'] = $langs->trans("supplier"); if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']= $langs->transnoentitiesnoconv('SuppliersOrders'); + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); // There no contact type for supplier proposals // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); @@ -172,9 +172,9 @@ if ($type_element == 'fichinter') $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'fichinterdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number = 'f.ref'; @@ -184,10 +184,10 @@ if ($type_element == 'fichinter') $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facturedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $where = " WHERE f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -198,10 +198,10 @@ if ($type_element == 'fichinter') $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'propaldet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('propal').')'; $datePrint = 'c.datep'; $doc_number = 'c.ref'; @@ -212,10 +212,10 @@ if ($type_element == 'fichinter') $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commandedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('order').')'; $dateprint = 'c.date_commande'; $doc_number = 'c.ref'; @@ -226,10 +226,10 @@ if ($type_element == 'fichinter') $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -254,10 +254,10 @@ elseif ($type_element == 'supplier_order') $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -269,10 +269,10 @@ elseif ($type_element == 'supplier_order') $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'contratdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -293,16 +293,16 @@ if (!empty($sql_select)) $sql .= " "; if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; $sql .= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from; - // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql .= $where; $sql .= dolSqlDateFilter($dateprint, 0, $month, $year); if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sprod_fulldescr) { - $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; - $sql .= ")"; + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= ")"; } $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); @@ -314,8 +314,8 @@ if (!empty($sql_select)) $disabled = 0; $showempty = 2; if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdparty->fournisseur) { - $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled = 1; + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; } // Define type of elements @@ -340,7 +340,7 @@ if ($sql_select) $num = $db->num_rows($resql); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if ($sref) $param .= "&sref=".urlencode($sref); @@ -348,48 +348,48 @@ if ($sql_select) if ($year) $param .= "&year=".urlencode($year); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - // Filters - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // Filters + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; $i = 0; @@ -478,7 +478,7 @@ if ($sql_select) elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; - print ''; + print ''; if ($objp->description) { if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) @@ -576,7 +576,7 @@ if ($sql_select) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -588,25 +588,25 @@ if ($sql_select) } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print '
'; - print ''; - print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); - print ''; - print ''; - print ''; - print ''; // TODO: Add filters ! - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + print ''; + print ''; // date + print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + print ''; + print ''; + print ''; + print ''; // TODO: Add filters ! + print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.$langs->trans('Total').''.$total_qty.''.price($total_ht).''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).'
'."\n"; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + print '
'."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; print ''; print "
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
"; } else { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print ''."\n"; + print '
'."\n"; print ''; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 8a70ec6e2df..2065ab772e6 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -45,9 +45,9 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check @@ -96,43 +96,43 @@ llxHeader('', $title, $helpurl); if ($object->id) { - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - print dol_get_fiche_head($head, 'documents', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'documents', $title, -1, 'contact'); - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; - print '
'.$langs->trans("FeatureNotYetAvailable").'
'; + print '
'; + print '
'; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -151,26 +151,26 @@ if ($object->id) } }*/ - // Civility - print ''; + // Civility + print ''; - print ''; - print ''; - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contact'; - $permission = $user->rights->societe->contact->creer; - $permtoedit = $user->rights->societe->contact->creer; - $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contact'; + $permission = $user->rights->societe->contact->creer; + $permtoedit = $user->rights->societe->contact->creer; + $param = '&id='.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 68d810967ad..78934c5857e 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -174,7 +174,7 @@ if ($result > 0) //var_dump($records); // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { if (!is_array($records)) { diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 478288046e1..ae32ef5c95e 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -67,46 +67,46 @@ llxHeader('', $title, $help_url); if ($id > 0) { - /* + /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); - print dol_get_fiche_head($head, 'note', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'note', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - $cssclass = 'titlefield'; - //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; - //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + $cssclass = 'titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; - print '
'; - print '
'; + print '
'; + print '
'; print ''; - // Civility - print ''; + // Civility + print ''; - print "
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
"; + print ""; $cssclass = "titlefield"; @@ -114,7 +114,7 @@ if ($id > 0) print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index bbaf013efa1..d8d7b709736 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -66,7 +66,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- if ($file_OK) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; if (GETPOST('deletephoto')) { $fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo; @@ -86,8 +86,8 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { - // Create thumbs - $object->addThumbs($newfile); + // Create thumbs + $object->addThumbs($newfile); } } } else { @@ -130,119 +130,119 @@ $head = contact_prepare_head($object); if ($action == 'edit') { - /* + /* * Fiche en mode edition */ - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head($head, 'perso', $title, 0, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, 0, 'contact'); - print ''; + print '
'; - // Ref - print ''; + // Ref + print ''; - // Photo - print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").''; - print $object->id; - print '
'.$langs->trans("Ref").''; + print $object->id; + print ''; - print $form->showphoto('contact', $object)."\n"; - if ($object->photo) print "
\n"; + // Photo + print '
'; + print $form->showphoto('contact', $object)."\n"; + if ($object->photo) print "
\n"; - print ''; + print '
'; - if ($object->photo) print ''; - print ''; - print ''; - print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + if ($object->photo) print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; - print ''; + print ''; - // Name - print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; - print ''.$langs->trans("Firstname").''.$object->firstname.''; + // Name + print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; - } else { - print ''.$langs->trans("ThirdParty").''; - print $langs->trans("ContactNotLinkedToCompany"); - print ''; - } - } + print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; + } else { + print ''.$langs->trans("ThirdParty").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + } - // Civility - print ''.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print ''; + // Civility + print ''.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print ''; - // Date To Birth - print ''.$langs->trans("DateOfBirth").''; - $form = new Form($db); - print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); - print ''; + // Date To Birth + print ''.$langs->trans("DateOfBirth").''; + $form = new Form($db); + print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); + print ''; - print ''.$langs->trans("Alert").': '; - if (!empty($object->birthday_alert)) - { - print ''; - } else { - print ''; - } - print ''; + print ''.$langs->trans("Alert").': '; + if (!empty($object->birthday_alert)) + { + print ''; + } else { + print ''; + } + print ''; - print ""; + print ""; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print "
"; + print ""; } else { - // View mode + // View mode - print dol_get_fiche_head($head, 'perso', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -261,59 +261,59 @@ if ($action == 'edit') } }*/ - // Civility - print ''; + // Civility + print ''; - // Date To Birth - print ''; - if (!empty($object->birthday)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // Date To Birth + print ''; + if (!empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - print ''; - } else { - print ''; - } - print ""; + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''; + } else { + print ''; + } + print ""; - print "
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); + print ''.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); - print '   '; - //var_dump($birthdatearray); - $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; - $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + print '   '; + //var_dump($birthdatearray); + $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; + $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); - print ''.$langs->trans("DateOfBirth").'
'.$langs->trans("DateOfBirth").'
"; + print ""; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if ($action != 'edit') { - // Barre d'actions - if ($user->socid == 0) - { - print '
'; + // Barre d'actions + if ($user->socid == 0) + { + print '
'; - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Modify').''; - } + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } - print "
"; - } + print "
"; + } } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index ee325317033..05426db19a6 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -66,7 +66,7 @@ $v->setPhoneNumber($contact->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($contact->fax, "TYPE=WORK;FAX"); -$country = $contact->country_code ? $contact->country : '' ; +$country = $contact->country_code ? $contact->country : ''; $v->setAddress("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK"); @@ -79,9 +79,9 @@ $v->setTitle($contact->poste); if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + if (!$contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + if (!$contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); // when company e-mail is empty, use only contact e-mail if (empty(trim($company->email))) @@ -124,7 +124,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 1187571d2d0..be97a83115a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -409,13 +409,13 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $error++; - } + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $error++; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -684,9 +684,9 @@ if (empty($reshook)) $objectline->pa_ht = $pa_ht; if ($fk_unit > 0) { - $objectline->fk_unit = GETPOST('unit'); + $objectline->fk_unit = GETPOST('unit'); } else { - $objectline->fk_unit = null; + $objectline->fk_unit = null; } // Extrafields @@ -877,11 +877,11 @@ if (empty($reshook)) $old_ref = $object->ref; - $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'editref'; - } else { + $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editref'; + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -896,13 +896,13 @@ if (empty($reshook)) } } - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + } else { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -1233,8 +1233,8 @@ if ($action == 'create') $result = $object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed if ($result < 0) { - dol_print_error($db, $object->error); - } + dol_print_error($db, $object->error); + } $nbofservices = count($object->lines); @@ -1249,55 +1249,55 @@ if ($action == 'create') $head = contract_prepare_head($object); - $hselected = 0; - $formconfirm = ''; + $hselected = 0; + $formconfirm = ''; - print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); - if ($action == 'delete') { - //Confirmation de la suppression du contrat - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); - } elseif ($action == 'valid') { - //Confirmation de la validation - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { - $numref = $object->getNextNumRef($object->thirdparty); - } else { - $numref = $object->ref; - } - $text = $langs->trans('ConfirmValidateContract', $numref); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); - } elseif ($action == 'close') { - // Confirmation de la fermeture - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); - } elseif ($action == 'activate') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); - } elseif ($action == 'clone') { - // Clone confirmation - $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + if ($action == 'delete') { + //Confirmation de la suppression du contrat + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); + } elseif ($action == 'valid') { + //Confirmation de la validation + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { + $numref = $object->getNextNumRef($object->thirdparty); + } else { + $numref = $object->ref; + } + $text = $langs->trans('ConfirmValidateContract', $numref); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); + } elseif ($action == 'close') { + // Confirmation de la fermeture + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); + } elseif ($action == 'activate') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); + } elseif ($action == 'clone') { + // Clone confirmation + $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - // Call Hook formConfirm - $parameters = array( - 'formConfirm' => $formconfirm, - 'id' => $id, - //'lineid' => $lineid, - ); - // Note that $action and $object may have been modified by hook - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array( + 'formConfirm' => $formconfirm, + 'id' => $id, + //'lineid' => $lineid, + ); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Print form confirm - print $formconfirm; + // Print form confirm + print $formconfirm; - /* + /* * Contrat */ if (!empty($object->brouillon) && $user->rights->contrat->creer) @@ -1489,7 +1489,7 @@ if ($action == 'create') if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; // Label if ($objp->fk_product > 0) @@ -1622,7 +1622,7 @@ if ($action == 'create') $line = new ContratLigne($db); $line->id = $objp->rowid; $line->fetch_optionals(); - print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven','style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); + print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven', 'style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); } } // Line in mode update @@ -1734,7 +1734,7 @@ if ($action == 'create') if ($object->statut > 0) { $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; print '
'; print "\n"; @@ -1850,12 +1850,12 @@ if ($action == 'create') // Si active et en cours if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); } // Si desactive if ($objp->date_debut_reelle && $objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); print '  -  '; print $langs->trans("DateEndReal").': '; print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); @@ -2092,7 +2092,7 @@ if ($action == 'create') //} } - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) { if ($action == 'showclosedlines') print ''; else print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f31901c5ccd..acc4c8323dd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -62,27 +62,27 @@ class Contrat extends CommonObject */ public $fk_element = 'fk_contrat'; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'contract'; - /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - public $ismultientitymanaged = 1; + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; - /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer - */ - public $restrictiononfksoc = 1; + /** + * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * @var integer + */ + public $restrictiononfksoc = 1; /** * {@inheritdoc} @@ -101,11 +101,11 @@ class Contrat extends CommonObject */ public $ref_supplier; - /** - * Entity of the contract - * @var int - */ - public $entity; + /** + * Entity of the contract + * @var int + */ + public $entity; /** * Client id linked to the contract @@ -310,7 +310,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -323,7 +323,7 @@ class Contrat extends CommonObject */ public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); if ($result < 0) { @@ -334,7 +334,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -346,7 +346,7 @@ class Contrat extends CommonObject */ public function close_line($user, $line_id, $date_end, $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { @@ -362,8 +362,8 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int|string $date_start Date start (now if empty) - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see () */ @@ -416,8 +416,8 @@ class Contrat extends CommonObject * Close all lines of a contract * * @param User $user Object User making action - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see activateAll() */ @@ -436,7 +436,7 @@ class Contrat extends CommonObject { // Close lines not already closed if ($contratline->statut != ContratLigne::STATUS_CLOSED) - { + { $contratline->date_cloture = $now; $contratline->fk_user_cloture = $user->id; $contratline->statut = ContratLigne::STATUS_CLOSED; @@ -448,7 +448,7 @@ class Contrat extends CommonObject $this->errors = $contratline->errors; break; } - } + } } if (!$error && $this->statut == 0) @@ -457,14 +457,14 @@ class Contrat extends CommonObject if ($result < 0) $error++; } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -472,7 +472,7 @@ class Contrat extends CommonObject * * @param User $user Objet User * @param string $force_number Reference to force on contract (not implemented yet) - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ public function validate(User $user, $force_number = '', $notrigger = 0) @@ -506,7 +506,7 @@ class Contrat extends CommonObject } else { $num = $this->ref; } - $this->newref = dol_sanitizeFileName($num); + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -526,15 +526,15 @@ class Contrat extends CommonObject // Trigger calls if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTRACT_VALIDATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) @@ -557,16 +557,16 @@ class Contrat extends CommonObject if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -598,7 +598,7 @@ class Contrat extends CommonObject * Unvalidate a contract * * @param User $user Object User - * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ public function reopen($user, $notrigger = 0) @@ -671,7 +671,7 @@ class Contrat extends CommonObject $sql = "SELECT rowid, statut, ref, fk_soc,"; $sql .= " ref_supplier, ref_customer,"; $sql .= " ref_ext,"; - $sql .= " entity,"; + $sql .= " entity,"; $sql .= " date_contrat as datecontrat,"; $sql .= " fk_user_author,"; $sql .= " fk_projet as fk_project,"; @@ -713,7 +713,7 @@ class Contrat extends CommonObject $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; - $this->entity = $obj->entity; + $this->entity = $obj->entity; $this->statut = $obj->statut; $this->date_contrat = $this->db->jdate($obj->datecontrat); @@ -765,7 +765,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed @@ -801,7 +801,7 @@ class Contrat extends CommonObject $extrafields->fetch_name_optionals_label($line->table_element, true); $this->lines = array(); - $pos = 0; + $pos = 0; // Selects contract lines related to a product $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref, p.fk_product_type as product_type,"; @@ -858,7 +858,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; - $line->type = $objp->type; + $line->type = $objp->type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -871,8 +871,8 @@ class Contrat extends CommonObject $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Product Ref - $line->product_type = $objp->product_type; // Product Type - $line->product_desc = $objp->product_desc; // Product Description + $line->product_type = $objp->product_type; // Product Type + $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label $line->description = $objp->description; @@ -896,11 +896,11 @@ class Contrat extends CommonObject $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; @@ -914,8 +914,8 @@ class Contrat extends CommonObject if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; $total_ttc += $objp->total_ttc; // TODO Not saved into database - $total_vat += $objp->total_tva; - $total_ht += $objp->total_ht; + $total_vat += $objp->total_tva; + $total_ht += $objp->total_ht; $i++; $pos++; @@ -927,9 +927,9 @@ class Contrat extends CommonObject } $this->nbofservices = count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; } @@ -1027,15 +1027,15 @@ class Contrat extends CommonObject // Insert business contacts ('SALESREPSIGN','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); + if ($result < 0) $error++; } // Insert business contacts ('SALESREPFOLL','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); + if ($result < 0) $error++; } if (!$error) @@ -1046,78 +1046,78 @@ class Contrat extends CommonObject } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - } + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } + } - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object - { - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - $originidforcontact = $value->id; - break; // We take first one - } - } - } + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object + { + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) + { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) + { + $originforcontact = 'commande'; + $originidforcontact = $value->id; + break; // We take first one + } + } + } - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) + { + while ($objcontact = $this->db->fetch_object($resqlcontact)) + { + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } else dol_print_error($resqlcontact); - } + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } else dol_print_error($resqlcontact); + } } if (!$error) { - // Call trigger - $result = $this->call_trigger('CONTRACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1158,10 +1158,10 @@ class Contrat extends CommonObject $this->db->begin(); - // Call trigger - $result = $this->call_trigger('CONTRACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1225,7 +1225,7 @@ class Contrat extends CommonObject } if (!$error) - { + { // Delete contratdet extrafields $main = MAIN_DB_PREFIX.'contratdet'; $ef = $main."_extrafields"; @@ -1346,7 +1346,7 @@ class Contrat extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; @@ -1468,7 +1468,7 @@ class Contrat extends CommonObject if (empty($pu_ttc)) $pu_ttc = 0; if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; if ($price_base_type == 'HT') { @@ -1515,7 +1515,7 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin @@ -1582,13 +1582,13 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_INSERT', $user); - if ($result < 0) - { - $error++; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_INSERT', $user); + if ($result < 0) + { + $error++; + } + // End call triggers } if ($error) @@ -1694,11 +1694,11 @@ class Contrat extends CommonObject $price = price2num(round($pu, 2)); if (dol_strlen($remise_percent) > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -1763,14 +1763,14 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -3; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -3; + } + // End call triggers $this->db->commit(); return 1; @@ -1803,14 +1803,14 @@ class Contrat extends CommonObject if ($this->statut >= 0) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_DELETE', $user); - if ($result < 0) return -1; - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_DELETE', $user); + if ($result < 0) return -1; + // End call triggers - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE rowid=".$idline; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); @@ -1848,7 +1848,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1858,7 +1858,7 @@ class Contrat extends CommonObject */ public function update_statut($user) { - // phpcs:enable + // phpcs:enable dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) @@ -1867,11 +1867,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); - // $newstatut=1; - // foreach($this->lines as $key => $contractline) - // { - // // if ($contractline) // Loop on each service - // } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1888,7 +1888,7 @@ class Contrat extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi label of a given contrat status * @@ -1898,7 +1898,7 @@ class Contrat extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -1947,11 +1947,11 @@ class Contrat extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length of ref - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user, $hookmanager; @@ -1967,35 +1967,35 @@ class Contrat extends CommonObject if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} - $label = ''; + $label = ''; - if ($user->rights->contrat->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; - $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); - $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - } + if ($user->rights->contrat->lire) { + $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; + $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); + $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); + $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; + if (!empty($this->total_ht)) { + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + } - $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowOrder"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->contrat->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } $linkstart = ''; @@ -2059,7 +2059,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of line rowid * @@ -2068,7 +2068,7 @@ class Contrat extends CommonObject */ public function array_detail($status = -1) { - // phpcs:enable + // phpcs:enable $tab = array(); $sql = "SELECT cd.rowid"; @@ -2132,17 +2132,17 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @param string $mode "inactive" pour services a activer, "expired" pour services expires - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param string $mode "inactive" pour services a activer, "expired" pour services expires + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user, $mode) + public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; @@ -2167,13 +2167,13 @@ class Contrat extends CommonObject $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; } elseif ($mode == 'active') { - $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql .= $this->from; - $sql .= " WHERE c.statut = 1"; - $sql .= " AND c.rowid = cd.fk_contrat"; - $sql .= " AND cd.statut = 4"; - //$datetouse = dol_now(); - //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; + $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; + //$datetouse = dol_now(); + //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; } $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; @@ -2192,10 +2192,10 @@ class Contrat extends CommonObject $labelShort = $langs->trans("BoardNotActivatedServicesShort"); $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; } elseif ($mode == 'expired') { - $warning_delay = $conf->contrat->services->expires->warning_delay; - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; - $label = $langs->trans("BoardExpiredServices"); - $labelShort = $langs->trans("BoardExpiredServicesShort"); + $warning_delay = $conf->contrat->services->expires->warning_delay; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; + $label = $langs->trans("BoardExpiredServices"); + $labelShort = $langs->trans("BoardExpiredServicesShort"); } else { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; @@ -2229,7 +2229,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @@ -2237,7 +2237,7 @@ class Contrat extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $conf, $user; $this->nb = array(); @@ -2261,7 +2261,7 @@ class Contrat extends CommonObject { $this->nb["contracts"] = $obj->nb; } - $this->db->free($resql); + $this->db->free($resql); return 1; } else { dol_print_error($this->db); @@ -2295,17 +2295,17 @@ class Contrat extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { global $user, $langs, $conf; - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -2362,10 +2362,10 @@ class Contrat extends CommonObject $line->date_end = dol_now() + 500000; $line->date_end_real = dol_now() - 100000; if ($num_prods > 0) - { + { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; - } + } $this->lines[$xnbp] = $line; $xnbp++; } @@ -2390,7 +2390,7 @@ class Contrat extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2440,8 +2440,8 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - public function createFromClone(User $user, $socid = 0, $notrigger = 0) - { + public function createFromClone(User $user, $socid = 0, $notrigger = 0) + { global $db, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); @@ -2452,7 +2452,7 @@ class Contrat extends CommonObject // Load dest object $clonedObj = clone $this; - $clonedObj->socid = $socid; + $clonedObj->socid = $socid; $this->db->begin(); @@ -2503,13 +2503,13 @@ class Contrat extends CommonObject $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { - // copy external contacts if same company - if ($this->socid == $clonedObj->socid) { - if ($clonedObj->copy_linked_contact($this, 'external') < 0) { - $error++; - } - } - } + // copy external contacts if same company + if ($this->socid == $clonedObj->socid) { + if ($clonedObj->copy_linked_contact($this, 'external') < 0) { + $error++; + } + } + } if (!$error) { foreach ($this->lines as $line) { @@ -2555,12 +2555,12 @@ class Contrat extends CommonObject */ class ContratLigne extends CommonObjectLine { - /** + /** * @var string ID to identify managed object */ public $element = 'contratdet'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'contratdet'; @@ -2578,13 +2578,13 @@ class ContratLigne extends CommonObjectLine public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_contrat; /** - * @var int ID - */ + * @var int ID + */ public $fk_product; public $statut; // 0 inactive, 4 active, 5 closed @@ -2607,7 +2607,7 @@ class ContratLigne extends CommonObjectLine */ public $description; - public $product_type; // 0 for product, 1 for service + public $product_type; // 0 for product, 1 for service public $product_ref; public $product_label; @@ -2632,8 +2632,8 @@ class ContratLigne extends CommonObjectLine public $remise; /** - * @var int ID - */ + * @var int ID + */ public $fk_remise_except; public $subprice; // Unit price HT @@ -2654,8 +2654,8 @@ class ContratLigne extends CommonObjectLine public $total_ttc; /** - * @var int ID - */ + * @var int ID + */ public $fk_fournprice; public $pa_ht; @@ -2663,18 +2663,18 @@ class ContratLigne extends CommonObjectLine public $info_bits; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_ouverture; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_cloture; public $commentaire; @@ -2686,9 +2686,9 @@ class ContratLigne extends CommonObjectLine /** - * Constructor - * - * @param DoliDb $db Database handler + * Constructor + * + * @param DoliDb $db Database handler */ public function __construct($db) { @@ -2707,7 +2707,7 @@ class ContratLigne extends CommonObjectLine return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2719,26 +2719,26 @@ class ContratLigne extends CommonObjectLine */ public static function LibStatut($status, $mode, $expired = -1, $moreatt = '') { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); - if ($status == self::STATUS_INITIAL) { - $labelStatus = $langs->trans("ServiceStatusInitial"); - $labelStatusShort = $langs->trans("ServiceStatusInitial"); - } elseif ($status == self::STATUS_OPEN && $expired == -1) { - $labelStatus = $langs->trans("ServiceStatusRunning"); - $labelStatusShort = $langs->trans("ServiceStatusRunning"); - } elseif ($status == self::STATUS_OPEN && $expired == 0) { - $labelStatus = $langs->trans("ServiceStatusNotLate"); - $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); - } elseif ($status == self::STATUS_OPEN && $expired == 1) { - $labelStatus = $langs->trans("ServiceStatusLate"); - $labelStatusShort = $langs->trans("ServiceStatusLateShort"); - } elseif ($status == self::STATUS_CLOSED) { - $labelStatus = $langs->trans("ServiceStatusClosed"); - $labelStatusShort = $langs->trans("ServiceStatusClosed"); - } + if ($status == self::STATUS_INITIAL) { + $labelStatus = $langs->trans("ServiceStatusInitial"); + $labelStatusShort = $langs->trans("ServiceStatusInitial"); + } elseif ($status == self::STATUS_OPEN && $expired == -1) { + $labelStatus = $langs->trans("ServiceStatusRunning"); + $labelStatusShort = $langs->trans("ServiceStatusRunning"); + } elseif ($status == self::STATUS_OPEN && $expired == 0) { + $labelStatus = $langs->trans("ServiceStatusNotLate"); + $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + } elseif ($status == self::STATUS_OPEN && $expired == 1) { + $labelStatus = $langs->trans("ServiceStatusLate"); + $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + } elseif ($status == self::STATUS_CLOSED) { + $labelStatus = $langs->trans("ServiceStatusClosed"); + $labelStatusShort = $langs->trans("ServiceStatusClosed"); + } $statusType = 'status'.$status; if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; @@ -2758,22 +2758,22 @@ class ContratLigne extends CommonObjectLine * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $maxlength = 0) + */ + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; $result = ''; - $label = $langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label = $this->description; + $label = $langs->trans("ShowContractOfService").': '.$this->label; + if (empty($label)) $label = $this->description; - $link = ''; + $link = ''; $linkend = ''; $picto = 'service'; if ($this->type == 0) $picto = 'product'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; return $result; @@ -2786,7 +2786,7 @@ class ContratLigne extends CommonObjectLine * @param string $ref Ref of contract line * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters if (empty($id) && empty($ref)) return -1; @@ -2981,7 +2981,7 @@ class ContratLigne extends CommonObjectLine $this->total_localtax1 = $tabprice[9]; $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -2999,7 +2999,7 @@ class ContratLigne extends CommonObjectLine $this->oldcopy = new ContratLigne($this->db); $this->oldcopy->fetch($this->id); - $this->oldcopy->fetch_optionals(); + $this->oldcopy->fetch_optionals(); // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; @@ -3087,18 +3087,18 @@ class ContratLigne extends CommonObjectLine } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + } + // End call triggers } if (!$error) { - $this->db->commit(); + $this->db->commit(); return 1; } else { $this->db->rollback(); @@ -3108,7 +3108,7 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process @@ -3117,7 +3117,7 @@ class ContratLigne extends CommonObjectLine */ public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base @@ -3224,7 +3224,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3236,7 +3236,7 @@ class ContratLigne extends CommonObjectLine */ public function active_line($user, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $error = 0; @@ -3281,19 +3281,19 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ public function close_line($user, $date_end, $comment = '', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; // Update object diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 4f69d5a2c56..24b0ff54bf6 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -60,11 +60,11 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -87,7 +87,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db, $object->error); } @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); $hselected = 1; @@ -138,13 +138,13 @@ if ($id > 0 || !empty($ref)) // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ @@ -158,67 +158,67 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= '
'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print ''; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; + // Date + print ''; print ''; - print ''; - print ''; - print "\n"; - } - if ($status == 4 && !$bool) $bool = true; - else $bool = false; + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } + if ($status == 4 && !$bool) $bool = true; + else $bool = false; } if (!empty($conf->use_javascript_ajax)) { - print ''; + print ''; } $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - if ($status == 4 && !$bool) $bool = true; - else $bool = false; - print "\n"; - } + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + if ($status == 4 && !$bool) $bool = true; + else $bool = false; + print "\n"; + } } //if ($totalinprocess != $total) //print ''; @@ -424,15 +424,15 @@ if ($resql) print ''; print ''; + print ''; print ''; print ''; + print ''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 0368340bffd..c9000c4fb0d 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -72,101 +72,101 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); - $hselected = 2; + $hselected = 2; - print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); - // Contract card + // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ - $morehtmlref .= '
'; - // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); - // Ref supplier - $morehtmlref .= '
'; - $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); - // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= '
'; + $morehtmlref .= '
'; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); + // Ref supplier + $morehtmlref .= '
'; + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); + // Thirdparty + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) { - print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - } else { - print $langs->trans("CompanyHasNoRelativeDiscount"); - } - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'; print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); print ''; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 759c2080930..b68da3170ed 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -179,20 +179,20 @@ if ($object->id) print '
'; print '
'; - print ''; - print ''; - print ''; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; - print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contract'; - $permission = $user->rights->contrat->creer; - $permtoedit = $user->rights->contrat->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contract'; + $permission = $user->rights->contrat->creer; + $permtoedit = $user->rights->contrat->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 7fe88d03c3d..5ea558c9689 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -80,21 +80,21 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search contract - if (!empty($conf->contrat->enabled)) - { - print '
'; - print ''; + // Search contract + if (!empty($conf->contrat->enabled)) + { + print ''; + print ''; print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'.$langs->trans("Contract").':
\n"; - print "
"; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'.$langs->trans("Contract").':
\n"; + print "
"; + } } @@ -131,11 +131,11 @@ if ($resql) { $nb[$obj->status] = $obj->nb; if ($obj->status != 5) - { - $vals[$obj->status] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; + { + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; } $i++; } @@ -159,24 +159,24 @@ if ($resql) { $num = $db->num_rows($resql); - // 0 inactive, 4 active, 5 closed - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $nb[$obj->status.true] = $obj->nb; - if ($obj->status != 5) - { - $vals[$obj->status.true] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; - } - $i++; - } - $db->free($resql); + // 0 inactive, 4 active, 5 closed + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $nb[$obj->status.true] = $obj->nb; + if ($obj->status != 5) + { + $vals[$obj->status.true] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; + } + $i++; + } + $db->free($resql); } else { dol_print_error($db); } @@ -191,51 +191,51 @@ print '
'.$langs->trans("Statistics").' - $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); - if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; - if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; - if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; - if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; + $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); + if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; + if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; + if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; + if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; - if (empty($conf->use_javascript_ajax)) - { - print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'; + print '
'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$langs->trans("Total").' ('.$langs->trans("ServicesRunning").')'.$totalinprocess.'
'; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; @@ -500,17 +500,17 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } - print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; @@ -576,15 +576,15 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 04329a63145..18b47b7102a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -363,7 +363,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), ); if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -579,13 +579,13 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['c.datec']['checked'])) { - print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['c.tms']['checked'])) { - print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['lower_planned_end_date']['checked'])) { - print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); @@ -634,7 +634,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'
'; + print '
'; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; - print ''; - print ''; + // Date + print ''; + print ''; + print ''; print "
'.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'; - print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); - print ''; - print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); - print '
'; + print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); + print ''; + print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); + print '
"; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 7279ab98781..67b605d657f 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -245,30 +245,30 @@ if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract) if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; -$filter_dateouvertureprevue_start=dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); -$filter_dateouvertureprevue_end=dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = ' BETWEEN '; -$filter_date1_start =dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); -$filter_date1_end =dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); +$filter_date1_start = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); +$filter_date1_end = dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); if ($filter_date1_start != '' && $filter_op1 == -1) $filter_op1 = ' BETWEEN '; -$filter_date2_start=dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); -$filter_date2_end=dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); +$filter_date2_start = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); +$filter_date2_end = dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); if ($filter_date2_start != '' && $filter_op2 == -1) $filter_op2 = ' BETWEEN '; -$filter_datecloture_start=dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); -$filter_datecloture_end=dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_start = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_end = dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); if ($filter_datecloture_start != '' && $filter_opcloture == -1) $filter_opcloture = ' BETWEEN '; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql.= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; -if (! empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; -if (! empty($filter_op1) && $filter_op1==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date1_end)."'"; -if (! empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; -if (! empty($filter_op2) && $filter_op2==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date2_end)."'"; -if (! empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; -if (! empty($filter_opcloture) && $filter_opcloture==' BETWEEN ') $sql.= " AND '".$db->idate($filter_datecloture_end)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; +if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; +if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date1_end)."'"; +if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; +if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date2_end)."'"; +if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; +if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -581,7 +581,7 @@ while ($i < min($num, $limit)) print ''; print $contractstatic->getNomUrl(1, 16); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Service if (!empty($arrayfields['p.description']['checked'])) @@ -601,7 +601,7 @@ while ($i < min($num, $limit)) if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.qty']['checked'])) @@ -609,39 +609,39 @@ while ($i < min($num, $limit)) print ''; print $obj->qty; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; print price($obj->total_ht); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; - $totalarray['val']['cd.total_ht'] += $obj->total_ht; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; + $totalarray['val']['cd.total_ht'] += $obj->total_ht; + } if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; print price($obj->total_tva); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; - $totalarray['val']['cd.total_tva'] += $obj->total_tva; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; + $totalarray['val']['cd.total_tva'] += $obj->total_tva; + } if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; print price2num($obj->tva_tx).'%'; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; print price($obj->subprice); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } @@ -651,7 +651,7 @@ while ($i < min($num, $limit)) print ''; print $companystatic->getNomUrl(1, 'customer', 28); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Start date @@ -663,12 +663,12 @@ while ($i < min($num, $limit)) print ' '.img_picto($langs->trans("Late"), "warning"); else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.date_ouverture']['checked'])) { print ''.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : ' ').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // End date if (!empty($arrayfields['cd.date_fin_validite']['checked'])) @@ -681,13 +681,13 @@ while ($i < min($num, $limit)) print img_warning($textlate); } else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Close date (real end date) if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields @@ -715,16 +715,16 @@ while ($i < min($num, $limit)) // Status if (!empty($arrayfields['status']['checked'])) { - print ''; - if ($obj->cstatut == 0) - { + print ''; + if ($obj->cstatut == 0) + { // If contract is draft, we say line is also draft - print $contractstatic->LibStatut(0, 5); - } else { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); - } - print ''; - if (!$i) $totalarray['nbfield']++; + print $contractstatic->LibStatut(0, 5); + } else { + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 57b885f24d2..339f51db22c 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -39,10 +39,10 @@ $langs->load("contracts"); $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> trans("Contract"); ?> @@ -58,7 +58,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) $totalcontrat = 0; foreach ($objectlink->lines as $linecontrat) { $totalcontrat = $totalcontrat + $linecontrat->total_ht; - $total = $total + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; } echo price($totalcontrat); } ?> diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 20bd19625cc..4ae83829fa4 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -34,102 +34,102 @@ if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $pe // Build doc if ($action == 'builddoc' && $permissiontoadd) { - if (is_numeric(GETPOST('model', 'alpha'))) - { - $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); - } else { + if (is_numeric(GETPOST('model', 'alpha'))) + { + $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); + } else { // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - /*if (empty($object->id) || ! $object->id > 0) + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + /*if (empty($object->id) || ! $object->id > 0) { dol_print_error('Object must have been loaded by a fetch'); exit; }*/ - // Save last template used to generate document - if (GETPOST('model', 'alpha')) - { - $object->setDocModel($user, GETPOST('model', 'alpha')); - } + // Save last template used to generate document + if (GETPOST('model', 'alpha')) + { + $object->setDocModel($user, GETPOST('model', 'alpha')); + } - // Special case to force bank account - //if (property_exists($object, 'fk_bank')) - //{ - if (GETPOST('fk_bank', 'int')) { - // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (!empty($object->fk_account)) { - $object->fk_bank = $object->fk_account; - } - //} + // Special case to force bank account + //if (property_exists($object, 'fk_bank')) + //{ + if (GETPOST('fk_bank', 'int')) { + // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank', 'int'); + } elseif (!empty($object->fk_account)) { + $object->fk_bank = $object->fk_account; + } + //} - $outputlangs = $langs; - $newlang = ''; + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" - { - setEventMessages($langs->trans("FileGenerated"), null); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" + { + setEventMessages($langs->trans("FileGenerated"), null); - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop - header('Location: '.$urltoredirect.'#builddoc'); - exit; - } - } - } + header('Location: '.$urltoredirect.'#builddoc'); + exit; + } + } + } } // Delete file in doc form if ($action == 'remove_file' && $permissiontoadd) { if (!empty($upload_dir)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || !$object->id > 0) - { - // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - } + if (empty($object->id) || !$object->id > 0) + { + // Reload to get all modified line records and be ready for hooks + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + } - $langs->load("other"); - $filetodelete = GETPOST('file', 'alpha'); - $file = $upload_dir.'/'.$filetodelete; - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + $langs->load("other"); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); - // Make a redirect to avoid to keep the remove_file into the url that create side effects - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); + // Make a redirect to avoid to keep the remove_file into the url that create side effects + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); - header('Location: '.$urltoredirect); - exit; + header('Location: '.$urltoredirect); + exit; } else { setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors'); } diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index f4e7f01d234..4daf53891cf 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -30,17 +30,17 @@ // Save selection if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') { - $tabparam = array(); + $tabparam = array(); - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result = dol_set_user_param($db, $conf, $user, $tabparam); + $result = dol_set_user_param($db, $conf, $user, $tabparam); - //$action='list'; - //var_dump($tabparam);exit; + //$action='list'; + //var_dump($tabparam);exit; } diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 079f207b4a4..f590adee197 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -57,19 +57,19 @@ if ($action == 'addcomment') } if ($action === 'updatecomment') { - if ($comment->fetch($idcomment) >= 0) - { - $comment->description = GETPOST('comment_description', 'restricthtml'); - if ($comment->update($user) > 0) - { - setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); - header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); - exit; - } else { - setEventMessages($comment->error, $comment->errors, 'errors'); - $action = ''; - } - } + if ($comment->fetch($idcomment) >= 0) + { + $comment->description = GETPOST('comment_description', 'restricthtml'); + if ($comment->update($user) > 0) + { + setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); + exit; + } else { + setEventMessages($comment->error, $comment->errors, 'errors'); + $action = ''; + } + } } if ($action == 'deletecomment') { diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 46a6a31c202..c8c4f4db5d0 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -42,7 +42,7 @@ if ($action == 'add') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -52,156 +52,156 @@ if ($action == 'add') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; + } + if ($type == 'varchar' && $extrasize > $maxsizestring) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'create'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'create'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'create'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'create'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'create'; + } + if ($type == 'link' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); + $action = 'create'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'create'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } + } } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'create'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'create'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'create'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'create'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'create'; - } - if ($type == 'link' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForLinkType"); - $action = 'create'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'create'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } - } - } - if (!$error) - { - // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) - { - // Construct array for parameter (value of select list) - $default_value = GETPOST('default_value', 'alpha'); - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + // attrname must be alphabetical and lower case only + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) + { + // Construct array for parameter (value of select list) + $default_value = GETPOST('default_value', 'alpha'); + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); if ($type == 'separate') $visibility = 3; - $result = $extrafields->addExtraField( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - GETPOST('pos', 'int'), - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $default_value, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->addExtraField( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + GETPOST('pos', 'int'), + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $default_value, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile', 'alpha'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile', 'alpha'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + $action = 'create'; + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -210,7 +210,7 @@ if ($action == 'update') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -220,147 +220,147 @@ if ($action == 'update') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'edit'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'edit'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'edit'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'edit'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'edit'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'edit'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } - } - } + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'edit'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'edit'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'edit'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'edit'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'edit'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'edit'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } + } + } - if (!$error) - { - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) - { - $pos = GETPOST('pos', 'int'); - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) + { + $pos = GETPOST('pos', 'int'); + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility = 3; + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); + if ($type == 'separate') $visibility = 3; - $result = $extrafields->update( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $pos, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->update( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $pos, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('default_value', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('default_value', 'alpha'), + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -369,14 +369,14 @@ if ($action == 'delete') { if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result = $extrafields->delete($_GET["attrname"], $elementtype); - if ($result >= 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else $mesg = $extrafields->error; + $result = $extrafields->delete($_GET["attrname"], $elementtype); + if ($result >= 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else $mesg = $extrafields->error; } else { - $error++; + $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index d4cdbb66a21..c881b335f18 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -34,20 +34,20 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask' { $ret = $object->fetch($id, $ref); if ($ret > 0) - { - $object->fetch_thirdparty(); - $id = $object->id; - } else { - if (empty($object->error) && !count($object->errors)) - { - if ($ret < 0) // if $ret == 0, it means not found. - { - setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - $action = ''; - } + { + $object->fetch_thirdparty(); + $id = $object->id; + } else { + if (empty($object->error) && !count($object->errors)) + { + if ($ret < 0) // if $ret == 0, it means not found. + { + setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; + } } } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 3a8e37a6c2b..2912d772a62 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { - if (!empty($_FILES)) + if (!empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; else $userfiles = array($_FILES['userfile']['tmp_name']); @@ -192,7 +192,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/'; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory $filenameto .= '.noexe'; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c2f0a314445..356eb36a04b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -114,11 +114,11 @@ if (!$error && $massaction == 'confirm_presend') } } - $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; - } - } - } + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; + } + } + } // Check mandatory parameters if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) @@ -261,9 +261,9 @@ if (!$error && $massaction == 'confirm_presend') $sendto = $fuser->email; } elseif ($objectobj->element == 'holiday') { - $fuser = new User($db); - $fuser->fetch($objectobj->fk_user); - $sendto = $fuser->email; + $fuser = new User($db); + $fuser->fetch($objectobj->fk_user); + $sendto = $fuser->email; } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); @@ -396,7 +396,7 @@ if (!$error && $massaction == 'confirm_presend') $looparray = $listofqualifiedobj; foreach ($looparray as $key => $objecttmp) { - $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object + $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { $objectforloop = new $objectclass($db); @@ -404,9 +404,9 @@ if (!$error && $massaction == 'confirm_presend') $looparray[0] = $objectforloop; } //var_dump($looparray);exit; - dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); - //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); - 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 + dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); + //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); + 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)) @@ -430,10 +430,10 @@ if (!$error && $massaction == 'confirm_presend') complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); - $subjectreplaced = make_substitutions($subject, $substitutionarray); - $messagereplaced = make_substitutions($message, $substitutionarray); + $subjectreplaced = make_substitutions($subject, $substitutionarray); + $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty @@ -461,20 +461,20 @@ if (!$error && $massaction == 'confirm_presend') // Define the trackid when emails sent from the mass action if ($oneemailperrecipient) { - $trackid = 'thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; + $trackid = 'thi'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; } else { - $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; - if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; - if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; - if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; - if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; - if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; - if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; + $trackid = strtolower(get_class($objecttmp)); + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; - $trackid .= $objecttmp->id; + $trackid .= $objecttmp->id; } //var_dump($filepath); //var_dump($trackid);exit; @@ -483,8 +483,8 @@ if (!$error && $massaction == 'confirm_presend') if (empty($sendcontext)) $sendcontext = 'standard'; // Send mail (substitutionarray must be done just before this) - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); if ($mailfile->error) { $resaction .= '
'.$mailfile->error.'
'; @@ -497,11 +497,11 @@ if (!$error && $massaction == 'confirm_presend') $error = 0; // Insert logs into agenda - foreach ($listofqualifiedobj as $objid2 => $objectobj2) + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { - if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level - dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); + dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; @@ -514,18 +514,18 @@ if (!$error && $massaction == 'confirm_presend') if ($message) { if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); + $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); } $actionmsg2 = ''; - // Initialisation donnees - $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); - $objectobj2->actionmsg = $actionmsg; // Long text - $objectobj2->actionmsg2 = $actionmsg2; // Short text - $objectobj2->fk_element = $objid2; - $objectobj2->elementtype = $objectobj2->element; + // Initialisation donnees + $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); + $objectobj2->actionmsg = $actionmsg; // Long text + $objectobj2->actionmsg2 = $actionmsg2; // Short text + $objectobj2->fk_element = $objid2; + $objectobj2->elementtype = $objectobj2->element; $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; @@ -619,13 +619,13 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($datefacture)) { - $datefacture = dol_now(); + $datefacture = dol_now(); } $objecttmp->date = $datefacture; @@ -676,7 +676,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // If we build one invoice for several order, we must put the invoice of order on the line if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } if ($lines[$i]->subprice < 0) @@ -807,7 +807,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // Call action to build doc $savobject = $object; - $object = $objecttmp; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $object = $savobject; } @@ -818,7 +818,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders if (!$error) { $db->commit(); - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; @@ -1063,7 +1063,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); } else { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } } @@ -1143,34 +1143,34 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) // Closed records if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissiontoclose) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $result = $objecttmp->cloture($user, 3); - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->cloture($user, 3); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) { - if ($nbok > 1) - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } //var_dump($_POST);var_dump($massaction);exit; @@ -1213,9 +1213,9 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; } else $nbok++; } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); @@ -1239,56 +1239,56 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' // @todo : propose model selection if (!$error && $massaction == 'generate_doc' && $permissiontoread) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) - { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { - $outputlangs = $langs; - $newlang = ''; + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + if ($result <= 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } $parameters['toselect'] = $toselect; diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 3137c93a9c5..3838e6963ab 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -33,7 +33,7 @@ if ($action == 'print_file' && $user->rights->printing->read) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; $objectprint = new PrintingDriver($db); $list = $objectprint->listDrivers($db, 10); - $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); if (!empty($list)) { $errorprint = 0; $printerfound = 0; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 05be4a31d18..1cc9a55deb2 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -38,11 +38,11 @@ if ($action == 'update' && is_array($arrayofparameters)) if (GETPOSTISSET($key)) { $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result < 0) - { - $ok = false; - break; - } + if ($result < 0) + { + $ok = false; + break; + } } } @@ -59,58 +59,58 @@ if ($action == 'update' && is_array($arrayofparameters)) // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { - $db->begin(); + $db->begin(); - // Process common param fields - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $reg = array(); - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... - { - $param = GETPOST("param".$reg[1], 'alpha'); - $value = GETPOST("value".$reg[1], 'alpha'); - if ($param) - { - $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - } - } - } - } + // Process common param fields + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $reg = array(); + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + { + $param = GETPOST("param".$reg[1], 'alpha'); + $value = GETPOST("value".$reg[1], 'alpha'); + if ($param) + { + $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + } + } + } + } - // Process upload fields - if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach ($listofdir as $key=>$tmpdir) - { - $tmpdir = trim($tmpdir); - $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (!$tmpdir) { - unset($listofdir[$key]); continue; - } - if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - else { - $upload_dir = $tmpdir; - } - } - if ($upload_dir) - { - $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); - if ($result <= 0) $error++; - } - } + // Process upload fields + if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); + foreach ($listofdir as $key=>$tmpdir) + { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { + unset($listofdir[$key]); continue; + } + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else { + $upload_dir = $tmpdir; + } + } + if ($upload_dir) + { + $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); + if ($result <= 0) $error++; + } + } - if (!$error) - { - $db->commit(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index f8d54f2b40b..b9dd4194268 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -33,7 +33,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES|ENT_HTML5, 'UTF-8', 1), '_public'); + $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public'); if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) @@ -63,6 +63,6 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', // Set public note if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES|ENT_HTML5), '_private'); + $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 620643da8f2..e6fd1e000cb 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -83,10 +83,10 @@ if ($modulepart == 'ecm') // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) { - dol_syslog("Refused to deliver file ".$original_file); - // Do no show plain path in shown error message - dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); - exit; + dol_syslog("Refused to deliver file ".$original_file); + // Do no show plain path in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); + exit; } // Check permissions @@ -120,11 +120,11 @@ if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); $current_ecmdir_id = -1; foreach ($sqltree as $keycursor => $val) { - //print $val['fullrelativename']." == ".$selecteddir; - if ($val['fullrelativename'] == $selecteddir) - { - $current_ecmdir_id = $keycursor; - } + //print $val['fullrelativename']." == ".$selecteddir; + if ($val['fullrelativename'] == $selecteddir) + { + $current_ecmdir_id = $keycursor; + } } if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 2b03eb858e1..cc27ca11844 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -58,7 +58,7 @@ if ($boxid > 0 && $zone != '' && $userid > 0) $nbboxonright = substr_count($tmp[1], ','); print $nbboxonleft.'-'.$nbboxonright; if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list - else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list + else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list } // Registering the location of boxes after a move @@ -70,10 +70,10 @@ if ($boxorder && $zone != '' && $userid > 0) $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) { - $langs->load("boxes"); - if (!GETPOST('closing')) - { - setEventMessages($langs->trans("BoxAdded"), null); - } + $langs->load("boxes"); + if (!GETPOST('closing')) + { + setEventMessages($langs->trans("BoxAdded"), null); + } } } diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 60d3b1d29a7..a6134b05bdc 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -18,7 +18,7 @@ */ if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); @@ -47,7 +47,7 @@ if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); require '../../main.inc.php'; //$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late -$time=dol_now(); +$time = dol_now(); $action = GETPOST('action', 'aZ09'); $listofreminderids = GETPOST('listofreminderids', 'aZ09'); @@ -105,7 +105,7 @@ $eventfound = array(); // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate. if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int')) { - /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined + /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined if (!empty($_SESSION['auto_check_events_not_before'])) { // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer), @@ -124,51 +124,51 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto $_SESSION['auto_check_events_not_before'] = $time + $time_update; */ - // Force save of the session change we did. - // WARNING: Any change in sessions after that will not be saved ! - session_write_close(); + // Force save of the session change we did. + // WARNING: Any change in sessions after that will not be saved ! + session_write_close(); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); + dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); - $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; - $sql .= ' AND ('; - $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - $sql .= ' )'; - } else { - $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - } - $sql .= $db->order('datep', 'ASC'); - $sql .= ' LIMIT 10'; // Avoid too many notification at once + $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; + $sql .= ' AND ('; + $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + $sql .= ' )'; + } else { + $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + } + $sql .= $db->order('datep', 'ASC'); + $sql .= ' LIMIT 10'; // Avoid too many notification at once - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) - { - // Message must be formated and translated to be used with javascript directly - $event = array(); - $event['type'] = 'agenda'; - $event['id_reminder'] = $obj->id_reminder; - $event['id_agenda'] = $obj->id_agenda; - $event['id_user'] = $obj->id_user_reminder; - $event['code'] = $obj->code; - $event['label'] = $obj->label; - $event['location'] = $obj->location; - $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); - $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) + { + // Message must be formated and translated to be used with javascript directly + $event = array(); + $event['type'] = 'agenda'; + $event['id_reminder'] = $obj->id_reminder; + $event['id_agenda'] = $obj->id_agenda; + $event['id_user'] = $obj->id_user_reminder; + $event['code'] = $obj->code; + $event['label'] = $obj->label; + $event['location'] = $obj->location; + $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); + $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); - $eventfound[$obj->id_agenda] = $event; - } - } else { - dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); - } + $eventfound[$obj->id_agenda] = $event; + } + } else { + dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); + } } print json_encode(array('pastreminders'=>$eventfound, 'nextreminder'=>'')); diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 710759e10bb..a530bea092f 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -31,7 +31,7 @@ if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // T require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -$action = GETPOST('action', 'aZ09'); // set or del +$action = GETPOST('action', 'aZ09'); // set or del $name = GETPOST('name', 'alpha'); diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index 6b476a8f59a..e56b8689e0d 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -27,7 +27,7 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../../main.inc.php'; -$id = GETPOST('id', 'int'); // id of thirdparty +$id = GETPOST('id', 'int'); // id of thirdparty $action = GETPOST('action', 'aZ09'); $htmlname = GETPOST('htmlname', 'alpha'); $showempty = GETPOST('showempty', 'int'); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 69dd65b868e..877379b54ad 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -26,21 +26,21 @@ if (!isset($usedbyinclude) || empty($usedbyinclude)) { - if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal - if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); - if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); - if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); - if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); + if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal + if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); + if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); + if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); - $res = @include '../../main.inc.php'; - if ($res == 'ERROR_NOT_LOGGED') - { - $langs->load("other"); - $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); - print json_encode($arrayresult); - if (is_object($db)) $db->close(); - exit; - } + $res = @include '../../main.inc.php'; + if ($res == 'ERROR_NOT_LOGGED') + { + $langs->load("other"); + $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); + exit; + } } include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; @@ -110,11 +110,11 @@ if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARC { $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || ! empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } @@ -131,7 +131,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST } // Vendor payments -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintovendorpayments'] = array( 'position'=>175, @@ -189,8 +189,8 @@ if (empty($reshook)) // This pushes a search entry to the top if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { - $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; - if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; + $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; + if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; } // Sort on position @@ -199,6 +199,6 @@ $arrayresult = dol_sort_array($arrayresult, 'position'); // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include if (!isset($usedbyinclude) || empty($usedbyinclude)) { - print json_encode($arrayresult); - if (is_object($db)) $db->close(); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); } diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 76c3fa5eb47..0a12324fab6 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -32,77 +32,77 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_last_manual_entries extends ModeleBoxes { - public $boxcode = "accountancy_last_manual_entries"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxLastManualEntries"; - public $depends = array("accounting"); + public $boxcode = "accountancy_last_manual_entries"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxLastManualEntries"; + public $depends = array("accounting"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($this->db); + $bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); - if ($user->rights->accounting->mouvements->lire) - { - $sql = "SELECT DISTINCT b.piece_num"; - $sql .= ", b.doc_date as date_movement"; - $sql .= ", b.label_operation"; - $sql .= ", b.montant as amount"; - $sql .= ", b.code_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.fk_doc = 0"; - $sql .= " AND b.entity = ".$conf->entity; - $sql .= " ORDER BY b.piece_num DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->accounting->mouvements->lire) + { + $sql = "SELECT DISTINCT b.piece_num"; + $sql .= ", b.doc_date as date_movement"; + $sql .= ", b.label_operation"; + $sql .= ", b.montant as amount"; + $sql .= ", b.code_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.fk_doc = 0"; + $sql .= " AND b.entity = ".$conf->entity; + $sql .= " ORDER BY b.piece_num DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_movement); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_movement); $journal = $objp->code_journal; - $label = $objp->label_operation; + $label = $objp->label_operation; $amount = $objp->amount; $bookkeepingstatic->id = $objp->id; @@ -114,11 +114,11 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', @@ -132,34 +132,34 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedManualEntries") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedManualEntries") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -169,8 +169,8 @@ class box_accountancy_last_manual_entries extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 639ce1ebc23..653f49d2bd9 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -32,57 +32,57 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_suspense_account extends ModeleBoxes { - public $boxcode = "accountancy_suspense_account"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxSuspenseAccount"; - public $depends = array("accounting"); + public $boxcode = "accountancy_suspense_account"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxSuspenseAccount"; + public $depends = array("accounting"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @return void - */ - public function loadBox() - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @return void + */ + public function loadBox() + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - //$bookkeepingstatic = new BookKeeping($this->db); + //$bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); - if ($user->rights->accounting->mouvements->lire) - { + if ($user->rights->accounting->mouvements->lire) + { $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; - if (!empty($suspenseAccount) && $suspenseAccount > 0) - { + if (!empty($suspenseAccount) && $suspenseAccount > 0) + { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.numero_compte = ".$suspenseAccount; @@ -112,13 +112,13 @@ class box_accountancy_suspense_account extends ModeleBoxes 'text' => ''.$langs->trans("SuspenseAccountNotDefined").'' ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + ); + } + } /** * Method to show box @@ -128,8 +128,8 @@ class box_accountancy_suspense_account extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index eeebb520ab1..f010dc2dede 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -77,20 +77,20 @@ class box_actions extends ModeleBoxes $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($this->db); - $actionstatic = new ActionComm($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; - $sql .= ", ta.code"; - $sql .= ", ta.libelle as type_label"; - $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; + $sql .= ", ta.code"; + $sql .= ", ta.libelle as type_label"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; @@ -261,5 +261,5 @@ class box_actions extends ModeleBoxes else print $out; return ''; - } + } } diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index e6d032d41f8..f0a5c8d61bb 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays extends ModeleBoxes { - public $boxcode = "birthdays"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; - public $depends = array("user"); + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; + public $depends = array("user"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic = new User($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { @@ -103,25 +103,25 @@ class box_birthdays extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $userstatic->id = $objp->rowid; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $userstatic->id = $objp->rowid; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $userstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $userstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $userstatic->LibStatut($objp->status, 3) );*/ @@ -134,15 +134,15 @@ class box_birthdays extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -155,8 +155,8 @@ class box_birthdays extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index e49d21ba387..02a315ea836 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays_members extends ModeleBoxes { - public $boxcode = "birthdays_members"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleMemberNextBirthdays"; - public $depends = array("adherent"); + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays_members extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays_members extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + $memberstatic = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { @@ -89,8 +89,8 @@ class box_birthdays_members extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql .= " AND u.statut = 1"; - $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); @@ -104,25 +104,25 @@ class box_birthdays_members extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $memberstatic->id = $objp->rowid; - $memberstatic->firstname = $objp->firstname; - $memberstatic->lastname = $objp->lastname; - $memberstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $memberstatic->id = $objp->rowid; + $memberstatic->firstname = $objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $memberstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $memberstatic->LibStatut($objp->status, 3) );*/ @@ -135,15 +135,15 @@ class box_birthdays_members extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -156,8 +156,8 @@ class box_birthdays_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index c75c4c24e8f..6a2554bcde0 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -32,147 +32,147 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_boms extends ModeleBoxes { - public $boxcode = "lastboms"; - public $boximg = "object_bom"; - public $boxlabel = "BoxTitleLatestModifiedBoms"; - public $depends = array("bom"); + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $bomstatic = new Bom($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); - if ($user->rights->bom->read) - { - $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - $sql .= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); - $bomstatic->id = $objp->rowid; - $bomstatic->ref = $objp->ref; - $bomstatic->id = $objp->socid; - $bomstatic->status = $objp->status; + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; - $productstatic->status = $objp->tobuy; - $productstatic->status_buy = $objp->tosell; + $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tobuy; + $productstatic->status_buy = $objp->tosell; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $bomstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $bomstatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -182,8 +182,8 @@ class box_boms extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index c81e226decb..795eaeccf36 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -28,20 +28,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_bookmarks extends ModeleBoxes { - public $boxcode = "bookmarks"; - public $boximg = "bookmark"; - public $boxlabel = "BoxMyLastBookmarks"; - public $depends = array("bookmark"); + public $boxcode = "bookmarks"; + public $boximg = "bookmark"; + public $boxlabel = "BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,18 +52,18 @@ class box_bookmarks extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bookmark->lire); + $this->hidden = !($user->rights->bookmark->lire); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -73,10 +73,10 @@ class box_bookmarks extends ModeleBoxes $this->max = $max; $this->info_box_head = array( - 'text' => $langs->trans("BoxMyLastBookmarks", $max), - 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', - ); - if ($user->rights->bookmark->creer) { + 'text' => $langs->trans("BoxMyLastBookmarks", $max), + 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', + ); + if ($user->rights->bookmark->creer) { $this->info_box_head['subpicto'] = 'bookmark'; $this->info_box_head['subtext'] = $langs->trans("BookmarksManagement"); } else { @@ -89,7 +89,7 @@ class box_bookmarks extends ModeleBoxes $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE fk_user = ".$user->id; - $sql .= " AND b.entity = ".$conf->entity; + $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); @@ -100,63 +100,63 @@ class box_bookmarks extends ModeleBoxes $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $objp->title, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $objp->title, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); - $line++; - } + $line++; + } - if ($num == 0) { - $mytxt = $langs->trans("NoRecordedBookmarks"); - if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="2"', - 'tooltip' => $mytxt, - 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, - ); - } + if ($num == 0) { + $mytxt = $langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="2"', + 'tooltip' => $mytxt, + 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + ); + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 00cad787e0b..816facc3ee4 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_clients extends ModeleBoxes { - public $boxcode = "lastcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastCustomers"; - public $depends = array("societe"); + public $boxcode = "lastcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -67,10 +67,10 @@ class box_clients extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -79,23 +79,23 @@ class box_clients extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.client"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.code_compta"; - $sql .= ", s.code_compta_fournisseur"; - $sql .= ", s.logo"; - $sql .= ", s.email"; - $sql .= ", s.datec, s.tms, s.status, s.entity"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 3)"; @@ -117,33 +117,33 @@ class box_clients extends ModeleBoxes $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; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; $thirdpartystatic->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); $line++; } @@ -156,15 +156,15 @@ class box_clients extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -177,8 +177,8 @@ class box_clients extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 90729b96017..c94353f1d5c 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,168 +32,168 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - public $boxcode = "lastcustomerorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLastCustomerOrders"; - public $depends = array("commande"); + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->commande->lire); - } + $this->hidden = !($user->rights->commande->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->load('orders'); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load('orders'); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $commandestatic = new Commande($this->db); - $societestatic = new Societe($this->db); - $userstatic = new User($this->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)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); - if ($user->rights->commande->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", c.ref, c.tms"; - $sql .= ", c.rowid"; - $sql .= ", c.date_commande"; - $sql .= ", c.ref_client"; - $sql .= ", c.fk_statut"; - $sql .= ", c.fk_user_valid"; - $sql .= ", c.facture"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 .= $this->db->plimit($max, 0); + if ($user->rights->commande->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + 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 .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $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; - $commandestatic->total_ht = $objp->total_ht; - $commandestatic->total_tva = $objp->total_tva; - $commandestatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + while ($line < $num) { + $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; + $commandestatic->total_ht = $objp->total_ht; + $commandestatic->total_tva = $objp->total_tva; + $commandestatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $commandestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $commandestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -203,8 +203,8 @@ class box_commandes extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index b3f23817712..53be2725680 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,28 +33,28 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - public $boxcode = "currentaccounts"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -73,7 +73,7 @@ class box_comptes extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,109 +83,109 @@ class box_comptes extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); - if ($user->rights->banque->lire) { + if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; $sql .= ", b.domiciliation, b.proprio, b.owner_address"; $sql .= ", b.account_number, b.currency_code"; $sql .= ", b.min_allowed, b.min_desired, comment"; - $sql .= ', b.fk_accountancy_journal'; - $sql .= ', aj.code as accountancy_journal'; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql .= " ORDER BY label"; $sql .= $this->db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; - $solde_total = array(); + $line = 0; + $solde_total = array(); - $account_static = new Account($this->db); - while ($line < $num) { - $objp = $this->db->fetch_object($result); + $account_static = new Account($this->db); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $account_static->id = $objp->rowid; + $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; - $account_static->label = $objp->label; - $account_static->number = $objp->number; - $account_static->account_number = $objp->account_number; - $account_static->currency_code = $objp->currency_code; - $account_static->accountancy_journal = $objp->accountancy_journal; - $solde = $account_static->solde(0); + $account_static->label = $objp->label; + $account_static->number = $objp->number; + $account_static->account_number = $objp->account_number; + $account_static->currency_code = $objp->currency_code; + $account_static->accountancy_journal = $objp->accountancy_journal; + $solde = $account_static->solde(0); - $solde_total[$objp->currency_code] += $solde; + $solde_total[$objp->currency_code] += $solde; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $account_static->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $account_static->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $objp->number, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $objp->number, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) + ); - $line++; - } + $line++; + } - // Total - foreach ($solde_total as $key=>$solde) { - $this->info_box_contents[$line][] = array( - 'tr' => 'class="liste_total"', - 'td' => 'class="liste_total left"', - 'text' => $langs->trans('Total').' '.$key, - ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right"', - 'text' => ' ' - ); + // Total + foreach ($solde_total as $key=>$solde) { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total left"', + 'text' => $langs->trans('Total').' '.$key, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => ' ' + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $key) - ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $key) + ); + $line++; + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 7141728c23d..c3756bfd86c 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - public $boxcode = "lastcontacts"; - public $boximg = "object_contact"; - public $boxlabel = "BoxLastContacts"; - public $depends = array("societe"); + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,18 +59,18 @@ class box_contacts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -121,7 +121,7 @@ class box_contacts extends ModeleBoxes $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->email = $objp->spemail; + $contactstatic->email = $objp->spemail; $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; @@ -130,7 +130,7 @@ class box_contacts extends ModeleBoxes $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; - $societestatic->email = $objp->semail; + $societestatic->email = $objp->semail; $societestatic->name_alias = $objp->name_alias; $societestatic->code_client = $objp->code_client; $societestatic->code_fournisseur = $objp->code_fournisseur; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 75fbc207134..9350bae2da9 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,158 +31,158 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - public $boxcode = "lastcontracts"; - public $boximg = "object_contract"; - public $boxlabel = "BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); - if ($user->rights->contrat->lire) - { - $contractstatic = new Contrat($this->db); - $thirdpartytmp = new Societe($this->db); + if ($user->rights->contrat->lire) + { + $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.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->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 .= $this->db->plimit($max, 0); + $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.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->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + 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 .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $now = dol_now(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $now = dol_now(); - $line = 0; + $line = 0; - $langs->load("contracts"); + $langs->load("contracts"); - while ($line < $num) - { - $objp = $this->db->fetch_object($resql); + while ($line < $num) + { + $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 = ''; + $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(); + $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; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - // fin_validite is no more on contract but on services - // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } + // fin_validite is no more on contract but on services + // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'text2'=> $late, - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'text2'=> $late, + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => $contractstatic->getLibStatut(7), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => $contractstatic->getLibStatut(7), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedContracts"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedContracts"), + ); - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -192,8 +192,8 @@ class box_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d5cc859eaa7..949f6ac1382 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,45 +34,45 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - public $boxcode = "lastrssinfos"; - public $boximg = "object_rss"; - public $boxlabel = "BoxLastRssInfos"; - public $depends = array("externalrss"); + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; + public $depends = array("externalrss"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { $this->db = $db; $this->paramdef = $param; - } + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @param int $cachedelay Delay we accept for cache file - * @return void - */ - public function loadBox($max = 5, $cachedelay = 3600) - { - global $user, $langs, $conf; - $langs->load("boxes"); + * @param int $cachedelay Delay we accept for cache file + * @return void + */ + public function loadBox($max = 5, $cachedelay = 3600) + { + global $user, $langs, $conf; + $langs->load("boxes"); $this->max = $max; @@ -90,42 +90,42 @@ class box_external_rss extends ModeleBoxes // Get RSS feed $url = $conf->global->$keyforparamurl; - $rssparser = new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel $description = $rssparser->getDescription(); $link = $rssparser->getLink(); - $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || !empty($rssparser->error)) - { - // Show warning - $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); - if ($rssparser->error) $errormessage .= " - ".$rssparser->error; - $title .= " ".img_error($errormessage); - $this->info_box_head = array('text' => $title, 'limit' => 0); - } else { - $this->info_box_head = array( - 'text' => $title, - 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), - 'subpicto'=>'globe', - 'target'=>'_blank', - ); + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) + { + // Show warning + $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); + if ($rssparser->error) $errormessage .= " - ".$rssparser->error; + $title .= " ".img_error($errormessage); + $this->info_box_head = array('text' => $title, 'limit' => 0); + } else { + $this->info_box_head = array( + 'text' => $title, + 'sublink' => $link, + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), + 'subpicto'=>'globe', + 'target'=>'_blank', + ); } // INFO on items $items = $rssparser->getItems(); - //print '
'.print_r($items,true).'
'; + //print '
'.print_r($items,true).'
'; $nbitems = count($items); - for ($line = 0; $line < $max && $line < $nbitems; $line++) - { - $item = $items[$line]; + for ($line = 0; $line < $max && $line < $nbitems; $line++) + { + $item = $items[$line]; // Feed common fields - $href = $item['link']; - $title = urldecode($item['title']); + $href = $item['link']; + $title = urldecode($item['title']); $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { @@ -145,46 +145,46 @@ class box_external_rss extends ModeleBoxes if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"] = "$title"; + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; - $tooltip = $title; - $description = !empty($item['description']) ? $item['description'] : ''; - $isutf8 = utf8_check($description); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); - $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description = preg_replace("/^\s+/", "", $description); - $description = str_replace("\r\n", "", $description); - $tooltip .= '
'.$description; + $tooltip = $title; + $description = !empty($item['description']) ? $item['description'] : ''; + $isutf8 = utf8_check($description); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
'.$description; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $href, - 'tooltip' => $tooltip, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $href, + 'tooltip' => $tooltip, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $title, - 'url' => $href, - 'tooltip' => $tooltip, - 'maxlength' => 64, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $title, + 'url' => $href, + 'tooltip' => $tooltip, + 'maxlength' => 64, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right nowrap"', - 'text' => $date, - ); - } - } + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right nowrap"', + 'text' => $date, + ); + } + } /** @@ -195,8 +195,8 @@ class box_external_rss extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index ebaff31268d..6a824849212 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - public $boxcode = "lastcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastCustomerBills"; - public $depends = array("facture"); + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -73,13 +73,13 @@ class box_factures extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); - $langs->load("bills"); + $langs->load("bills"); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( @@ -87,14 +87,14 @@ class box_factures extends ModeleBoxes 'limit'=> dol_strlen($text) ); - if ($user->rights->facture->lire) { - $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.datef as df"; + if ($user->rights->facture->lire) { + $sql = "SELECT f.rowid as facid"; + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -103,8 +103,8 @@ class box_factures extends ModeleBoxes $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 "; + 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 .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,90 +116,90 @@ class box_factures extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datelimite = $this->db->jdate($objp->datelimite); - $date = $this->db->jdate($objp->df); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $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->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->tva_intra = $objp->tva_intra; - $societestatic->email = $objp->email; - $societestatic->idprof1 = $objp->idprof1; - $societestatic->idprof2 = $objp->idprof2; - $societestatic->idprof3 = $objp->idprof3; - $societestatic->idprof4 = $objp->idprof4; - $societestatic->idprof5 = $objp->idprof5; - $societestatic->idprof6 = $objp->idprof6; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->tva_intra = $objp->tva_intra; + $societestatic->email = $objp->email; + $societestatic->idprof1 = $objp->idprof1; + $societestatic->idprof2 = $objp->idprof2; + $societestatic->idprof3 = $objp->idprof3; + $societestatic->idprof4 = $objp->idprof4; + $societestatic->idprof5 = $objp->idprof5; + $societestatic->idprof6 = $objp->idprof6; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax200"', - 'text' => $societestatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => $societestatic->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -209,8 +209,8 @@ class box_factures extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 30f3cd503c2..7053acb9e97 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - public $boxcode = "lastsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,18 +55,18 @@ class box_factures_fourn extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -75,10 +75,10 @@ class box_factures_fourn extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $facturestatic = new FactureFournisseur($this->db); - $thirdpartytmp = new Fournisseur($this->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,12 +87,12 @@ 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, s.email,"; - $sql .= " s.logo,"; + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; - $sql .= " f.total_ht,"; - $sql .= " f.total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut,"; $sql .= ' f.datef as df,'; $sql .= ' f.datec as datec,'; @@ -104,8 +104,8 @@ class box_factures_fourn extends ModeleBoxes $sql .= " AND f.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 "; + 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 .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,96 +116,96 @@ class box_factures_fourn extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { + while ($line < $num) { $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; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->ref_supplier = $objp->ref_supplier; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->date_echeance = $datelimite; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->ref_supplier = $objp->ref_supplier; - $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; + $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; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $fac = new FactureFournisseur($this->db); - $fac->fetch($objp->facid); - $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $fac = new FactureFournisseur($this->db); + $fac->fetch($objp->facid); + $alreadypaid = $fac->getSommePaiement(); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoModifiedSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoModifiedSupplierBills"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->transnoentities("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->transnoentities("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -215,8 +215,8 @@ class box_factures_fourn extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index c2b5e7c705e..938505caab4 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures_fourn_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -85,9 +85,9 @@ class box_factures_fourn_imp extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; $sql .= " f.datef as df,"; - $sql .= " f.total_ht as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.type"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; @@ -109,7 +109,7 @@ class box_factures_fourn_imp extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { @@ -127,71 +127,71 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoUnpaidSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoUnpaidSupplierBills"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -201,8 +201,8 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index f5fe3e76dde..e1b6a39b529 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidCustomerBills"; - public $depends = array("facture"); + public $boxcode = "oldestunpaidcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,18 +57,18 @@ class box_factures_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -77,10 +77,10 @@ class box_factures_imp extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -89,14 +89,14 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; - $sql .= " s.code_client,"; - $sql .= " s.logo,"; + $sql .= " s.code_client,"; + $sql .= " s.logo,"; $sql .= " f.ref, f.date_lim_reglement as datelimite,"; - $sql .= " f.type,"; + $sql .= " f.type,"; $sql .= " f.datef as df,"; - $sql .= " f.total as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -128,54 +128,54 @@ class box_factures_imp extends ModeleBoxes { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->client = 1; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->client = 1; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1, '', 44), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1, '', 44), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), + ); $line++; } @@ -187,17 +187,17 @@ class box_factures_imp extends ModeleBoxes $this->db->free($result); } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -209,8 +209,8 @@ class box_factures_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 2c104bea729..fc9fcc9fc17 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - public $boxcode = "ficheinter"; - public $boximg = "object_intervention"; - public $boxlabel = "BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,11 +55,11 @@ class box_ficheinter extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -67,7 +67,7 @@ class box_ficheinter extends ModeleBoxes * * @param int $max Maximum number of records to load * @return void - */ + */ public function loadBox($max = 10) { global $user, $langs, $conf; @@ -120,26 +120,26 @@ class box_ficheinter extends ModeleBoxes $companystatic->email = $objp->semail; $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $ficheinterstatic->getNomUrl(1), - 'asis' => 1, + 'td' => 'class="nowraponall"', + 'text' => $ficheinterstatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $companystatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowrap right"', - 'text' => $ficheinterstatic->getLibStatut(3), - 'asis' => 1, + 'td' => 'class="nowrap right"', + 'text' => $ficheinterstatic->getLibStatut(3), + 'asis' => 1, ); $i++; @@ -153,15 +153,15 @@ class box_ficheinter extends ModeleBoxes $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -174,8 +174,8 @@ class box_ficheinter extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 44dd891bfb8..4be895f769c 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -32,129 +32,129 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_fournisseurs extends ModeleBoxes { - public $boxcode = "lastsuppliers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastSuppliers"; - public $depends = array("fournisseur"); + public $boxcode = "lastsuppliers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastSuppliers"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && empty($user->socid)); - } + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); - if ($user->rights->societe->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; - $sql .= " s.code_fournisseur, s.email as semail,"; - $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.fournisseur = 1"; - $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " ORDER BY s.tms DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; + $sql .= " s.code_fournisseur, s.email as semail,"; + $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.fournisseur = 1"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) - { - $objp = $this->db->fetch_object($result); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); + $line = 0; + while ($line < $num) + { + $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->email = $objp->semail; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->logo = $objp->logo; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartytmp->entity = $objp->entity; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->semail; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedSuppliers"), - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedSuppliers"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -164,8 +164,8 @@ class box_fournisseurs extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 66497c2e94f..7efecc4001c 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,27 +33,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - public $boxcode = "goodcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxGoodCustomers"; - public $depends = array("societe"); + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -69,10 +69,10 @@ class box_goodcustomers extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -81,10 +81,10 @@ class box_goodcustomers extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { @@ -119,24 +119,24 @@ class box_goodcustomers extends ModeleBoxes $nbimpaye = $objp->nbfact - $objp->nbfactpaye; $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') + 'td' => 'class="right"', + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) ); $line++; @@ -150,14 +150,14 @@ class box_goodcustomers extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); } @@ -171,8 +171,8 @@ class box_goodcustomers extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 9d5aeda7b36..d1fb6dd4114 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode = "invoicespermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCustomersInvoicesPerMonth"; - public $depends = array("facture"); + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -141,9 +141,9 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; $legend = array(); while ($i <= $endyear) @@ -186,7 +186,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -269,8 +269,8 @@ class box_graph_invoices_permonth extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -283,8 +283,8 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index b9fde24b759..1490f5ea6e9 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode = "invoicessupplierpermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxSuppliersInvoicesPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -130,7 +130,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; @@ -138,12 +138,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -183,7 +183,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -263,16 +263,16 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -285,8 +285,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 2ff1a579798..d9c26620553 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode = "orderspermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxCustomersOrdersPerMonth"; - public $depends = array("commande"); + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -97,9 +97,9 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->rights->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -133,7 +133,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$endyear.'.png'; @@ -144,7 +144,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -176,7 +176,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$endyear.'.png'; @@ -260,22 +260,22 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_orders_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index fb40ee1f68f..765c6324516 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode = "orderssupplierpermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxSuppliersOrdersPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -96,9 +96,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -259,22 +259,22 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -287,8 +287,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 957277005e7..407c66177b5 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,20 +29,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode = "productdistribution"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductDistribution"; - public $depends = array("product|service", "facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -58,7 +58,7 @@ class box_graph_product_distribution extends ModeleBoxes $this->db = $db; $this->hidden = !( - (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); @@ -68,7 +68,7 @@ class box_graph_product_distribution extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -138,7 +138,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { - $langs->load("propal"); + $langs->load("propal"); include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -197,7 +197,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { - $langs->load("orders"); + $langs->load("orders"); include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -315,8 +315,8 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($nbofgraph)) { - $langs->load("errors"); - $mesg = $langs->trans("ReadPermissionNotAllowed"); + $langs->load("errors"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { @@ -388,13 +388,13 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'maxlength'=>500, 'text' => $mesg ); @@ -409,8 +409,8 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 4231638948a..de1a1f8de83 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode = "propalpermonth"; - public $boximg = "object_propal"; - public $boxlabel = "BoxProposalsPerMonth"; - public $depends = array("propal"); + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; + public $depends = array("propal"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_propales_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -191,7 +191,7 @@ class box_graph_propales_permonth extends ModeleBoxes { if ($startmonth != 1) { - $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { $legend[] = $i; } @@ -260,22 +260,22 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength' => 500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength' => 500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index f6bbbb76854..2950eb9cfd8 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -31,179 +31,179 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_modified_ticket extends ModeleBoxes { - public $boxcode = "box_last_modified_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_modified_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; $langs->load("boxes"); $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastModifiedTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("BoxLastModifiedTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastModifiedTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastModifiedTicketContent"), + ); - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - while ($i < $num) { - $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 = ''; + while ($i < $num) { + $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); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][0] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1, - ); - $r++; + // Ticket + $this->info_box_contents[$i][0] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1, + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowrap"', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour') - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour') + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3) - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3) + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), - ); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 252141db9eb..9ada300901c 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -31,177 +31,177 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_ticket extends ModeleBoxes { - public $boxcode = "box_last_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; - $langs->load("boxes"); - $this->db = $db; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes"); + $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text), - ); + $text = $langs->trans("BoxLastTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastTicketContent"), + ); - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - //$sql.= " AND t.fk_statut > 9"; + //$sql.= " AND t.fk_statut > 9"; - $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - while ($i < $num) { - $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 = ''; + while ($i < $num) { + $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); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1 - ); - $r++; + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1 + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour'), - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour'), + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3), - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3), + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array('td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array('td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 6af4468c669..b45986387a8 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,75 +30,75 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - public $boxcode = "lastlogin"; - public $boximg = "object_user"; - public $boxlabel = 'BoxLoginInformation'; - public $depends = array("user"); + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; + public $depends = array("user"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $conf; - $this->db = $db; - } + $this->db = $db; + } - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $textHead = $langs->trans("BoxLoginInformation"); - $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - ); + $textHead = $langs->trans("BoxLoginInformation"); + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); - $line = 0; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $langs->trans("User"), - ); - $this->info_box_contents[$line][1] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $user->getNomUrl(-1), - 'asis' => 1 - ); + $line = 0; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $langs->trans("User"), + ); + $this->info_box_contents[$line][1] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $user->getNomUrl(-1), + 'asis' => 1 + ); - $line = 1; - $this->info_box_contents[$line][0] = array( - 'td' => '', - 'text' => $langs->trans("PreviousConnexion"), - ); - if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp = $langs->trans("Unknown"); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $tmp, - ); - } + $line = 1; + $this->info_box_contents[$line][0] = array( + 'td' => '', + 'text' => $langs->trans("PreviousConnexion"), + ); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $tmp, + ); + } /** @@ -109,8 +109,8 @@ class box_lastlogin extends ModeleBoxes * @param int $nooutput No print, only return string * @return void */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2ca1fb3ae25..72bc088ae6c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,28 +32,28 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - public $boxcode = "lastmembers"; - public $boximg = "object_user"; - public $boxlabel = "BoxLastMembers"; - public $depends = array("adherent"); + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_members extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -81,8 +81,8 @@ class box_members extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); @@ -110,12 +110,12 @@ class box_members extends ModeleBoxes $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; - $memberstatic->photo = $objp->photo; - $memberstatic->gender = $objp->gender; - $memberstatic->email = $objp->email; - $memberstatic->morphy = $objp->morphy; - $memberstatic->company = $objp->company; + $memberstatic->ref = $objp->rowid; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; + $memberstatic->company = $objp->company; if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -125,52 +125,52 @@ class box_members extends ModeleBoxes $memberstatic->name = $objp->company; } - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->getNomUrl(-1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->getNomUrl(-1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->company, - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->company, + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -180,8 +180,8 @@ class box_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index ec21d5d00cf..dde8294f80b 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -32,143 +32,143 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_mos extends ModeleBoxes { - public $boxcode = "lastmos"; - public $boximg = "object_mrp"; - public $boxlabel = "BoxTitleLatestModifiedMos"; - public $depends = array("mrp"); + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $mostatic = new Mo($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); - if ($user->rights->mrp->read) - { - $sql = "SELECT p.ref as product_ref"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - //$sql.= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); - $mostatic->id = $objp->rowid; - $mostatic->ref = $objp->ref; - $mostatic->id = $objp->socid; - $mostatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $mostatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $mostatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -178,8 +178,8 @@ class box_mos extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 52591fa5292..06808ab2518 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - public $boxcode = "lastproducts"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProducts"; - public $depends = array("produit"); + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,21 +57,21 @@ class box_produits extends ModeleBoxes */ public function __construct($db, $param) { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -94,9 +94,9 @@ class box_produits extends ModeleBoxes // Add where from hooks if (is_object($hookmanager)) { - $parameters = array('boxproductlist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } $sql .= $this->db->order('p.datec', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -128,33 +128,33 @@ class box_produits extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $objp->label, - ); - $price = ''; - $price_base_type = ''; - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $objp->label, + ); + $price = ''; + $price_base_type = ''; + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -163,69 +163,69 @@ class box_produits extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price, - ); + 'td' => 'class="right"', + 'text' => $price, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="nowrap"', - 'text' => $price_base_type, - ); + 'td' => 'class="nowrap"', + 'text' => $price_base_type, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 - ); + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', + 'asis' => 1 + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProducts"), - ); + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProducts"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 6845cb2db5f..893bb2273ab 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode = "productsalertstock"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductsAlertStock"; - public $depends = array("produit"); + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,21 +59,21 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -99,16 +99,16 @@ class box_produits_alerte_stock extends ModeleBoxes if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks - if (is_object($hookmanager)) - { - $parameters = array('boxproductalertstocklist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $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.barcode, p.seuil_stock_alerte, p.entity,"; - $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; - $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; - $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + if (is_object($hookmanager)) + { + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $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.barcode, p.seuil_stock_alerte, p.entity,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; + $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); @@ -118,11 +118,11 @@ class box_produits_alerte_stock extends ModeleBoxes $langs->load("stocks"); $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); - $price = ''; - $price_base_type = ''; + $price = ''; + $price_base_type = ''; // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -141,10 +141,10 @@ class box_produits_alerte_stock extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $productstatic->barcode = $objp->barcode; $productstatic->status = $objp->tosell; @@ -156,27 +156,27 @@ class box_produits_alerte_stock extends ModeleBoxes $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $objp->label, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $objp->label, + ); - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) - { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) + { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -185,58 +185,58 @@ class box_produits_alerte_stock extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => $price, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price_base_type, - ); + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, - 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 + 'td' => 'class="right nowraponall"', + 'text' => $price, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $price_base_type, + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoTooLowStockProducts"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', + 'asis' => 1 + ); + + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoTooLowStockProducts"), + ); $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -248,8 +248,8 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index e8b056322da..1afbdfc6837 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -31,174 +31,174 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - public $boxcode = "project"; - public $boximg = "object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode = "project"; + public $boximg = "object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "OpenedProjects"; + $this->db = $db; + $this->boxlabel = "OpenedProjects"; - $this->hidden = !($user->rights->projet->lire); - } + $this->hidden = !($user->rights->projet->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask = 0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask = 0; - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid = 0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid = 0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql .= " AND p.fk_statut = 1"; // Only open projects - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + 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.= $this->db->plimit($max, 0); + $sql .= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < min($num, $max)) { - $objp = $this->db->fetch_object($result); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); - $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; - $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 = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", - ); - else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $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 = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", + ); + else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - } + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 331ff54cb8d..bbfa2f6fb19 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -33,155 +33,155 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_propales extends ModeleBoxes { - public $boxcode = "lastpropals"; - public $boximg = "object_propal"; - public $boxlabel = "BoxLastProposals"; - public $depends = array("propal"); // conf->propal->enabled + public $boxcode = "lastpropals"; + public $boximg = "object_propal"; + public $boxlabel = "BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->propale->lire); - } + $this->hidden = !($user->rights->propale->lire); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $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($this->db); - $societestatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $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)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; - $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 .= $this->db->plimit($max, 0); + if ($user->rights->propale->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; + $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + 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 .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $now = dol_now(); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $now = dol_now(); - $line = 0; + $line = 0; - while ($line < $num) { - $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; - $propalstatic->total_tva = $objp->total_tva; - $propalstatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; + while ($line < $num) { + $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; + $propalstatic->total_tva = $objp->total_tva; + $propalstatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + $societestatic->email = $objp->email; $societestatic->entity = $objp->entity; - $late = ''; - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { - $late = img_warning($langs->trans("Late")); - } + $late = ''; + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + $late = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $propalstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $propalstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProposals"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -191,8 +191,8 @@ class box_propales extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 1024ef1d4ec..10a8698aaf9 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,27 +34,27 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - public $boxcode = "lastprospects"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastProspects"; - public $depends = array("societe"); + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_prospect extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -88,10 +88,10 @@ class box_prospect extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid"; $sql .= ", s.code_client"; - $sql .= ", s.client, s.email"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.logo"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -115,58 +115,58 @@ class box_prospect extends ModeleBoxes $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=> $langs->trans("NoRecordedProspects"), - ); - } + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=> $langs->trans("NoRecordedProspects"), + ); + } - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -178,8 +178,8 @@ class box_prospect extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index a5a1c4bea8a..c4a713a03b5 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - public $boxcode = "lastproductsincontract"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProductsInContract"; - public $depends = array("service", "contrat"); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,18 +56,18 @@ class box_services_contracts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,10 +83,10 @@ class box_services_contracts extends ModeleBoxes if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic = new Contrat($this->db); - $contractlinestatic = new ContratLigne($this->db); - $thirdpartytmp = new Societe($this->db); - $productstatic = new Product($this->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,"; @@ -182,31 +182,31 @@ class box_services_contracts extends ModeleBoxes $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $s, - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $s, + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => dol_print_date($datem, 'day'), + 'td' => '', + 'text' => dol_print_date($datem, 'day'), 'text2'=> $late, - ); + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right" width="18"', + 'td' => 'class="right" width="18"', 'text' => $contractlinestatic->getLibStatut(3) ); @@ -220,15 +220,15 @@ class box_services_contracts extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -241,8 +241,8 @@ class box_services_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index d7b3433f6d2..7a65fd0a9d2 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,160 +30,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - public $boxcode = "expiredservices"; // id of box - public $boximg = "object_contract"; - public $boxlabel = "BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $now = dol_now(); + $now = dol_now(); - $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); - if ($user->rights->contrat->lire) - { - // Select contracts with at least one expired service + if ($user->rights->contrat->lire) + { + // Select contracts with at least one expired service $sql = "SELECT "; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; $sql .= " 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 .= " 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->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $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->socid) $sql .= ' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $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 .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql .= " ORDER BY date_line ASC"; - $sql .= $this->db->plimit($max, 0); + $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->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $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->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $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 .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - $thirdpartytmp = new Societe($this->db); - $contract = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); + $contract = new Contrat($this->db); - while ($i < $num) - { - $late = ''; + while ($i < $num) + { + $late = ''; - $objp = $this->db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $contract->id = $objp->rowid; - $contract->ref = $objp->ref; - $contract->statut = $objp->fk_statut; - $contract->ref_customer = $objp->ref_customer; - $contract->ref_supplier = $objp->ref_supplier; + $contract->id = $objp->rowid; + $contract->ref = $objp->ref; + $contract->statut = $objp->fk_statut; + $contract->ref_customer = $objp->ref_customer; + $contract->ref_supplier = $objp->ref_supplier; $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( - 'td' => 'class="nowraponall"', - 'text' => $contract->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contract->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', - 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', + 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateline, 'day'), - 'text2'=> $late, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center nowraponall"', + 'text' => dol_print_date($dateline, 'day'), + 'text2'=> $late, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objp->nb_services, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objp->nb_services, + ); - $i++; - } + $i++; + } - if ($num == 0) - { - $langs->load("contracts"); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nohover opacitymedium center"', - 'text' => $langs->trans("NoExpiredServices"), - ); - } + if ($num == 0) + { + $langs->load("contracts"); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nohover opacitymedium center"', + 'text' => $langs->trans("NoExpiredServices"), + ); + } $this->db->free($resql); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -193,8 +193,8 @@ class box_services_expired extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 8574b7ce01b..1b3c865f5a1 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -32,152 +32,152 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_shipments extends ModeleBoxes { - public $boxcode = "lastcustomershipments"; - public $boximg = "sending"; - public $boxlabel = "BoxLastCustomerShipments"; - public $depends = array("expedition"); + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; + public $depends = array("expedition"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->expedition->lire); - } + $this->hidden = !($user->rights->expedition->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->loadLangs(array('orders', 'sendings')); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $shipmentstatic = new Expedition($this->db); - $orderstatic = new Commande($this->db); - $societestatic = new Societe($this->db); + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); - if ($user->rights->expedition->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", e.ref, e.tms"; - $sql .= ", e.rowid"; - $sql .= ", e.ref_customer"; - $sql .= ", e.fk_statut"; - $sql .= ", e.fk_user_valid"; - $sql .= ", c.ref as commande_ref"; - $sql .= ", c.rowid as commande_id"; - $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; - else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->expedition->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $shipmentstatic->id = $objp->rowid; - $shipmentstatic->ref = $objp->ref; - $shipmentstatic->ref_customer = $objp->ref_customer; + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id = $objp->commande_id; - $orderstatic->ref = $objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $shipmentstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $orderstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedShipments") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedShipments") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -187,8 +187,8 @@ class box_shipments extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index cdc1dd51440..6c5dd4379d3 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -31,160 +31,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders extends ModeleBoxes { - public $boxcode = "latestsupplierorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrders"; - public $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->lire); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_client, s.code_fournisseur,"; - $sql .= " s.logo, s.email,"; - $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; - $sql .= " c.total_ht,"; - $sql .= " c.tva as total_tva,"; - $sql .= " c.total_ttc,"; - $sql .= " c.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - 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 .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + 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 .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); + $line = 0; + while ($line < $num) { + $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; $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; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), + ); - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 8701c67d711..7abe2369a68 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -31,41 +31,41 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode = "projettask"; - public $boximg = "object_projecttask"; - public $boxlabel; - public $depends = array("projet"); + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; + public $boxlabel; + public $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; // enable because fixed ;-). + public $param; + public $enabled = 1; // enable because fixed ;-). - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel = "Tasks"; - $this->db = $db; + $this->boxlabel = "Tasks"; + $this->db = $db; - $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); - } + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); + } /** * Load data for box to show them later @@ -94,7 +94,7 @@ class box_task extends ModeleBoxes if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { $filterValue = GETPOST($cookie_name); } elseif (!empty($_COOKIE[$cookie_name])) { - $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data + $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data } if ($filterValue == 'im_task_contact') { @@ -175,33 +175,33 @@ class box_task extends ModeleBoxes $i = 1; if ($result) { $num = $this->db->num_rows($result); - while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id = $objp->rowid; - $taskstatic->ref = $objp->ref; - $taskstatic->label = $objp->label; - $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; - $taskstatic->date_end = $this->db->jdate($objp->datee); - $taskstatic->planned_workload = $objp->planned_workload; - $taskstatic->duration_effective = $objp->duration_effective; + while ($objp = $this->db->fetch_object($result)) { + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; + $taskstatic->progress = $objp->progress; + $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->date_end = $this->db->jdate($objp->datee); + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; - $projectstatic->id = $objp->project_id; - $projectstatic->ref = $objp->project_ref; - $projectstatic->title = $objp->project_title; + $projectstatic->id = $objp->project_id; + $projectstatic->ref = $objp->project_ref; + $projectstatic->title = $objp->project_title; - $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); + $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => $boxcontent, - ); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { - dol_print_error($this->db); - } + dol_print_error($this->db); + } } } diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index b4eddf5f18d..87f0664ecb9 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -31,95 +31,95 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_validated_projects extends ModeleBoxes { - public $boxcode="validated_project"; - public $boximg="object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode="validated_project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - public $enabled = 1; + public $enabled = 1; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "ProjectsWithTask"; + $this->db = $db; + $this->boxlabel = "ProjectsWithTask"; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = ! ($user->rights->projet->lire); if ($conf->global->MAIN_FEATURES_LEVEL < 2) $this->enabled = 0; - } + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max=$max; + $this->max=$max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask=0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; - $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid=0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid=0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. - // Count of tasks without time spent for tasks we are assigned too or - // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? - $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; - $sql.= " COUNT(DISTINCT t.rowid) as tasknumber"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; - // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; - $sql.= " WHERE p.fk_statut = 1"; // Only open projects - if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed + // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. + // Count of tasks without time spent for tasks we are assigned too or + // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? + $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; + $sql.= " COUNT(DISTINCT t.rowid) as tasknumber"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; $sql.= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; - $sql.= " ORDER BY p.dateo ASC"; + $sql.= " ORDER BY p.dateo ASC"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => "Reference projet", @@ -138,67 +138,67 @@ class box_validated_projects extends ModeleBoxes ); $i++; - while ($i < min($num+1, $max+1)) { - $objp = $this->db->fetch_object($result); + while ($i < min($num+1, $max+1)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - if ($objp->fk_soc > 0) { - $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; - $resql = $this->db->query($sql); - //$socstatic = new Societe($this->db); - $obj2 = $this->db->fetch_object($resql); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $obj2->name, - 'asis' => 1, - 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid - ); - } - else { - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => '', - 'asis' => 1, - 'url' => '' - ); - } + if ($objp->fk_soc > 0) { + $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; + $resql = $this->db->query($sql); + //$socstatic = new Societe($this->db); + $obj2 = $this->db->fetch_object($resql); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $obj2->name, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid + ); + } + else { + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => '', + 'asis' => 1, + 'url' => '' + ); + } - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->startDate, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->startDate, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), 'asis' => 1, - ); - $i++; - } - }else { - dol_print_error($this->db); + ); + $i++; + } + }else { + dol_print_error($this->db); } - } - } + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php index 1df09500173..d7c383138b6 100644 --- a/htdocs/core/boxes/intracommreport_box.php +++ b/htdocs/core/boxes/intracommreport_box.php @@ -22,7 +22,7 @@ * \brief This file is a sample box definition file * Put some comments here */ -include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -30,59 +30,59 @@ include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; class intracommreportbox extends ModeleBoxes { - public $boxcode = "mybox"; - public $boximg = "intracommreport"; - public $boxlabel; - public $depends = array("intracommreport"); - public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "mybox"; + public $boximg = "intracommreport"; + public $boxlabel; + public $depends = array("intracommreport"); + public $db; + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - */ - public function __construct() - { - global $langs; - $langs->load("boxes"); + /** + * Constructor + */ + public function __construct() + { + global $langs; + $langs->load("boxes"); - $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs, $db; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs, $db; - $this->max = $max; + $this->max = $max; - //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; + //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; - $text = $langs->trans("MyBoxDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("MyBoxDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("MyBoxContent")); - } + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("MyBoxContent")); + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void - */ - public function showBox($head = null, $contents = null) - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + public function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d68d8b4dc3b..a4d9aca57fd 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -113,7 +113,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -156,7 +156,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if ($obj) { $this->id = $obj->id; - $this->rowid = $obj->id; // For backward compatibility + $this->rowid = $obj->id; // For backward compatibility $this->box_id = $obj->box_id; $this->position = $obj->position; $this->box_order = $obj->box_order; @@ -184,180 +184,180 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if (!empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission) - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite - $cachetime = 900; // 900 : 15mn - $cachedir = DOL_DATA_ROOT.'/boxes/temp'; - $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; - $filename = '/box-'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $out = ''; + $cachetime = 900; // 900 : 15mn + $cachedir = DOL_DATA_ROOT.'/boxes/temp'; + $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; + $filename = '/box-'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $out = ''; - if ($refresh) { - dol_syslog(get_class($this).'::showBox'); + if ($refresh) { + dol_syslog(get_class($this).'::showBox'); - // Define nbcol and nblines of the box to show - $nbcol = 0; - if (isset($contents[0])) $nbcol = count($contents[0]); - $nblines = count($contents); + // Define nbcol and nblines of the box to show + $nbcol = 0; + if (isset($contents[0])) $nbcol = count($contents[0]); + $nblines = count($contents); - $out .= "\n\n"; + $out .= "\n\n"; - $out .= '
'."\n"; + $out .= '
'."\n"; - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= ''."\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= '
'."\n"; + } - // Show box title - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) - { - $out .= ''; - $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } - $out .= '>'; - if (!empty($conf->use_javascript_ajax)) - { - //$out.= '
'; + // Show box title + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) + { + $out .= ''; + $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } + $out .= '>'; + if (!empty($conf->use_javascript_ajax)) + { + //$out.= '
'; - $out .= '
'; - } - if (!empty($head['text'])) - { - $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); - $out .= $s; - } - if (!empty($conf->use_javascript_ajax)) - { - $out .= '
'; - } - //$out.= '
'; - if (!empty($conf->use_javascript_ajax)) - { - $sublink = ''; - if (!empty($head['sublink'])) $sublink .= ''; - if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); - if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($conf->use_javascript_ajax)) + { + $sublink = ''; + if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); + if (!empty($head['sublink'])) $sublink .= ''; - //$out.= '
'; + $out .= '
'; + } + if (!empty($head['text'])) + { + $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); + $out .= $s; + } + if (!empty($conf->use_javascript_ajax)) + { + $out .= '
'; + } + //$out.= '
'; - $out .= '
'; - $out .= $sublink; - // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); - $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); - $label = $head['text']; - //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; - if (!empty($head['graph'])) $label .= ' '; - $out .= ''; - //$out.= '
'; - $out .= '
'; - } + //$out.= ''; + $out .= '
'; + $out .= $sublink; + // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object + $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); + $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); + $label = $head['text']; + //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; + if (!empty($head['graph'])) $label .= ' '; + $out .= ''; + //$out.= ''; + $out .= '
'; + } - $out .= ""; - $out .= "\n"; - } + $out .= ""; + $out .= "\n"; + } - // Show box lines - if ($nblines) - { - // Loop on each record - for ($i = 0, $n = $nblines; $i < $n; $i++) - { - if (isset($contents[$i])) - { - // TR - if (isset($contents[$i][0]['tr'])) $out .= ''; - else $out .= ''; + // Show box lines + if ($nblines) + { + // Loop on each record + for ($i = 0, $n = $nblines; $i < $n; $i++) + { + if (isset($contents[$i])) + { + // TR + if (isset($contents[$i][0]['tr'])) $out .= ''; + else $out .= ''; - // Loop on each TD - $nbcolthisline = count($contents[$i]); - for ($j = 0; $j < $nbcolthisline; $j++) { - // Define tdparam - $tdparam = ''; - if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; + // Loop on each TD + $nbcolthisline = count($contents[$i]); + for ($j = 0; $j < $nbcolthisline; $j++) { + // Define tdparam + $tdparam = ''; + if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; - $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; - $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); - $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; - $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); + $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; + $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); + $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; + $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); - $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; - //$out.= "xxx $textwithnotags y"; - if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; - $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; + $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; + //$out.= "xxx $textwithnotags y"; + if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; + $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; - $out .= ''."\n"; + $out .= ''."\n"; - // Url - if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) - { - $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; - } - //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" - $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; - $out .= '>'; - } + // Url + if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) + { + $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; + } + //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" + $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; + $out .= '>'; + } - // Logo - if (!empty($contents[$i][$j]['logo'])) - { - $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); - $out .= ''; - $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); - } + // Logo + if (!empty($contents[$i][$j]['logo'])) + { + $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); + $out .= ''; + $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); + } - $maxlength = $MAXLENGTHBOX; - if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; + $maxlength = $MAXLENGTHBOX; + if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; - if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); - if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning - else $out .= $textwithnotags; // show text with html cleaning + if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); + if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning + else $out .= $textwithnotags; // show text with html cleaning - // End Url - if (!empty($contents[$i][$j]['url'])) $out .= ''; + // End Url + if (!empty($contents[$i][$j]['url'])) $out .= ''; - if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning - else $out .= $text2withnotags; // show text with html cleaning + if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning + else $out .= $text2withnotags; // show text with html cleaning - if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; + if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; - $out .= "\n"; - } + $out .= "\n"; + } - $out .= "\n"; - } - } - } + $out .= "\n"; + } + } + } - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= "\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= "\n"; + } - // If invisible box with no contents - if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; + // If invisible box with no contents + if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; - $out .= "
\n"; + $out .= "\n"; - $out .= "\n\n"; - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $out); - } - } else { - dol_syslog(get_class($this).'::showBoxCached'); - $out = ""; - $out .= dol_readcachefile($cachedir, $filename); - } + $out .= "\n\n"; + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $out); + } + } else { + dol_syslog(get_class($this).'::showBoxCached'); + $out = ""; + $out .= dol_readcachefile($cachedir, $filename); + } - if ($nooutput) return $out; - else print $out; + if ($nooutput) return $out; + else print $out; - return ''; + return ''; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 7f51b47d0b6..65c017e3dad 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -294,13 +294,13 @@ class CMailFile $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); - $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } @@ -653,19 +653,19 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; - $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; - $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; - $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; - $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; - $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 4f1959d2707..62257e79447 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -34,7 +34,7 @@ */ class CSMSFile { - /** + /** * @var string Error code (or message) */ public $error = ''; @@ -76,21 +76,21 @@ class CSMSFile // If ending method not defined if (empty($conf->global->MAIN_SMS_SENDMODE)) { - $this->error = 'No SMS Engine defined'; - return -1; + $this->error = 'No SMS Engine defined'; + return -1; } dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".count($msg), LOG_DEBUG); dol_syslog("CSMSFile::CSMSFile: deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG); // Action according to choosed sending method - $this->addr_from = $from; - $this->addr_to = $to; - $this->deferred = $deferred; - $this->priority = $priority; - $this->class = $class; - $this->message = $msg; - $this->nostop = false; + $this->addr_from = $from; + $this->addr_to = $to; + $this->deferred = $deferred; + $this->priority = $priority; + $this->class = $class; + $this->message = $msg; + $this->nostop = false; } @@ -108,17 +108,17 @@ class CSMSFile $res = false; - dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); - dol_syslog("CSMSFile::sendfile message=\n".$this->message); + dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); + dol_syslog("CSMSFile::sendfile message=\n".$this->message); - $this->message = stripslashes($this->message); + $this->message = stripslashes($this->message); - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) { - // Action according to choosed sending method - if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated + // Action according to choosed sending method + if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated { dol_include_once('/ovh/class/ovhsms.class.php'); $sms = new OvhSms($this->db); @@ -127,14 +127,14 @@ class CSMSFile $sms->message = $this->message; $sms->deferred = $this->deferred; $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->nostop = $this->nostop; + $sms->class = $this->class; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); if ($res <= 0) { @@ -146,42 +146,42 @@ class CSMSFile if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); } } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' - { - $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); - $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); - dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); - try { - $classname = ucfirst($classfile); - $sms = new $classname($this->db); - $sms->expe = $this->addr_from; - $sms->dest = $this->addr_to; - $sms->deferred = $this->deferred; - $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->message = $this->message; - $sms->nostop = $this->nostop; + { + $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); + $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); + dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); + try { + $classname = ucfirst($classfile); + $sms = new $classname($this->db); + $sms->expe = $this->addr_from; + $sms->dest = $this->addr_to; + $sms->deferred = $this->deferred; + $sms->priority = $this->priority; + $sms->class = $this->class; + $sms->message = $this->message; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->fk_project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->fk_project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); - $this->error = $sms->error; - $this->errors = $sms->errors; - if ($res <= 0) - { - dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); - } else { - dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); - //var_dump($res); // 1973128 - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); - } - } catch (Exception $e) - { - dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); - } - } else { + $this->error = $sms->error; + $this->errors = $sms->errors; + if ($res <= 0) + { + dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); + } else { + dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); + //var_dump($res); // 1973128 + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); + } + } catch (Exception $e) + { + dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); + } + } else { // Send sms method not correctly defined // -------------------------------------- @@ -198,17 +198,17 @@ class CSMSFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms request into a dump file (mode = all) - * Used for debugging. - * - * @return void - */ - public function dump_sms() - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms request into a dump file (mode = all) + * Used for debugging. + * + * @return void + */ + public function dump_sms() + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { @@ -229,29 +229,29 @@ class CSMSFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms result into a dump file (mode = all) - * Used for debugging. - * - * @param int $result Result of sms sending - * @return void - */ - public function dump_sms_result($result) - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms result into a dump file (mode = all) + * Used for debugging. + * + * @param int $result Result of sms sending + * @return void + */ + public function dump_sms_result($result) + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; - if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir - { - $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; - $fp = fopen($outputfile, "a+"); + if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir + { + $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; + $fp = fopen($outputfile, "a+"); - fputs($fp, "\nResult id=".$result); + fputs($fp, "\nResult id=".$result); - fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } - } + fclose($fp); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + } + } } diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index f897ae46a62..e6bd24ad016 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -45,9 +45,9 @@ class AntiVir public $output; /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * Constructor @@ -59,7 +59,7 @@ class AntiVir $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -70,24 +70,24 @@ class AntiVir */ public function dol_avscan_file($file) { - // phpcs:enable + // phpcs:enable global $conf; $return = 0; if (preg_match('/\.virus$/i', $file)) { - $this->errors[] = 'File has an extension saying file is a virus'; - return -97; + $this->errors[] = 'File has an extension saying file is a virus'; + return -97; } $fullcommand = $this->getCliCommand($file); //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; - $fullcommand .= ' 2>&1'; // This is to get error output + $fullcommand .= ' 2>&1'; // This is to get error output $output = array(); $return_var = 0; - $safemode = ini_get("safe_mode"); + $safemode = ini_get("safe_mode"); // Create a clean fullcommand dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off")); // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% @@ -95,7 +95,7 @@ class AntiVir if (is_null($output)) $output = array(); - //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; + //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; /* $outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id(); @@ -181,7 +181,7 @@ class AntiVir $ret = $command.' '.$param; //$ret=$command.' '.$param.' 2>&1'; - //print "xx".$ret."xx";exit; + //print "xx".$ret."xx";exit; return $ret; } diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 80c6ff1b7a6..91157f52ba0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -29,9 +29,9 @@ class Canvas { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,16 +45,16 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -75,11 +75,11 @@ class Canvas */ private function _cleanaction($action) { - $newaction = $action; - if ($newaction == 'add') $newaction = 'create'; - if ($newaction == 'update') $newaction = 'edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; - return $newaction; + $newaction = $action; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; + return $newaction; } @@ -96,45 +96,45 @@ class Canvas global $conf, $langs; // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas - $this->targetmodule = $module; - $this->canvas = $canvas; - $this->card = $card; - $this->dirmodule = $module; - // Correct values if canvas is into an external module + $this->targetmodule = $module; + $this->canvas = $canvas; + $this->card = $card; + $this->dirmodule = $module; + // Correct values if canvas is into an external module if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { - $this->canvas = $regs[1]; - $this->dirmodule = $regs[2]; + $this->canvas = $regs[1]; + $this->dirmodule = $regs[2]; } // For compatibility - if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { - // Include actions class (controller) - $this->control_file = $controlclassfile; - require_once $controlclassfile; + // Include actions class (controller) + $this->control_file = $controlclassfile; + require_once $controlclassfile; - // Instantiate actions class (controller) - $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); - $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); + // Instantiate actions class (controller) + $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); + $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); } // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (!is_dir($this->template_dir)) - { - $this->template_dir = ''; - } + if (!is_dir($this->template_dir)) + { + $this->template_dir = ''; + } - //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; - //print ' => template_dir='.$this->template_dir.'
'; + //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; + //print ' => template_dir='.$this->template_dir.'
'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Shared method for canvas to assign values for templates * * @param string $action Action string @@ -144,25 +144,25 @@ class Canvas */ public function assign_values(&$action = 'view', $id = 0, $ref = '') { - // phpcs:enable + // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); } - /** - * Return the template to display canvas (if it exists) + /** + * Return the template to display canvas (if it exists) * * @param string $action Action code - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists - */ - public function displayCanvasExists($action) - { - if (empty($this->template_dir)) return 0; + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + */ + public function displayCanvasExists($action) + { + if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; - else return 0; - } + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; + else return 0; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -172,7 +172,7 @@ class Canvas */ public function display_canvas($action) { - // phpcs:enable + // phpcs:enable global $db, $conf, $langs, $user, $canvas; global $form, $formfile; @@ -191,12 +191,12 @@ class Canvas */ public function hasActions() { - return (is_object($this->control)); + return (is_object($this->control)); } /** * Shared method for canvas to execute actions. - * @deprecated Use the doActions of hooks instead of this. + * @deprecated Use the doActions of hooks instead of this. * This function is called if you add a doActions class inside your canvas. Try to not * do that and add action code into a hook instead. * diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index cf671eb57ca..d19e6d00a36 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -33,9 +33,9 @@ class Ccountry // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -50,7 +50,7 @@ class Ccountry // extends CommonObject public $element = 'ccountry'; //!< Id that identify managed objects public $table_element = 'c_country'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -59,9 +59,9 @@ class Ccountry // extends CommonObject public $code_iso; /** - * @var string Countries label - */ - public $label; + * @var string Countries label + */ + public $label; public $active; @@ -70,27 +70,27 @@ class Ccountry // extends CommonObject ); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -102,14 +102,14 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; $sql .= "rowid,"; $sql .= "code,"; $sql .= "code_iso,"; $sql .= "label,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; @@ -120,88 +120,88 @@ class Ccountry // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $code_iso Code ISO - * @return int >0 if OK, 0 if not found, <0 if KO - */ - public function fetch($id, $code = '', $code_iso = '') - { - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $code_iso Code ISO + * @return int >0 if OK, 0 if not found, <0 if KO + */ + public function fetch($id, $code = '', $code_iso = '') + { + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.code_iso,"; $sql .= " t.label,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->code_iso = $obj->code_iso; $this->label = $obj->label; $this->active = $obj->active; - $this->db->free($resql); - return 1; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -214,27 +214,27 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -242,16 +242,16 @@ class Ccountry // extends CommonObject $this->db->commit(); return 1; } - } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -264,15 +264,15 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -282,19 +282,19 @@ class Ccountry // extends CommonObject } } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $langs; - return $langs->trans($this->label); - } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $langs; + return $langs->trans($this->label); + } } diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 39ae2eb63ef..d2c6221a598 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -44,27 +44,27 @@ class Comment extends CommonObject public $description; /** - * Date modification record (tms) - * - * @var integer - */ + * Date modification record (tms) + * + * @var integer + */ public $tms; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; /** diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6015bbceece..7e8d2da34ce 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1288,7 +1288,7 @@ abstract class CommonDocGenerator if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { + uasort($fields, function($a, $b) { return ($a->rank > $b->rank) ? 1 : -1; }); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c278eaeedb7..12759b9fbf2 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -297,7 +297,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiement'; $field = 'fk_facture'; $field2 = 'fk_paiement'; - $field3=', p.ref_ext'; + $field3 = ', p.ref_ext'; $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -305,7 +305,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiementfourn'; $field = 'fk_facturefourn'; $field2 = 'fk_paiementfourn'; - $field3=''; + $field3 = ''; $sharedentity = 'facture_fourn'; } @@ -327,11 +327,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); if (!empty($field3)) { $tmp['ref_ext'] = $obj->ref_ext; } - $retarray[]=$tmp; + $retarray[] = $tmp; $i++; } $this->db->free($resql); @@ -694,7 +694,7 @@ abstract class CommonInvoice extends CommonObject } else { $sql .= ' WHERE fk_facture = '.$this->id; } - $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments + $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments $sql .= ' AND traite = 0'; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a5b6e0b84de..178ddbd05fe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2256,12 +2256,12 @@ abstract class CommonObject return 1; } else { dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -5361,8 +5361,8 @@ abstract class CommonObject $new_array_options[$key] = ''; } elseif ($value) { $object = new $InfoFieldList[0]($this->db); - if (is_numeric($value)) $res = $object->fetch($value); // Common case - else $res = $object->fetch('', $value); // For compatibility + if (is_numeric($value)) $res = $object->fetch($value); // Common case + else $res = $object->fetch('', $value); // For compatibility if ($res > 0) $new_array_options[$key] = $object->id; else { @@ -6821,7 +6821,7 @@ abstract class CommonObject switch ($mode) { case "view": - $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later + $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later break; case "create": case "edit": @@ -8474,7 +8474,7 @@ abstract class CommonObject $this->db->begin(); - switch ($this->element){ + switch ($this->element) { case 'propal': $element = 'propale'; break; @@ -8482,10 +8482,10 @@ abstract class CommonObject $element = 'produit'; break; case 'order_supplier': - $element ='fournisseur/commande'; + $element = 'fournisseur/commande'; break; case 'invoice_supplier': - $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); + $element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); break; case 'shipping': $element = 'expedition/sending'; @@ -8495,8 +8495,8 @@ abstract class CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql.= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 8874175a138..e7c40d60bfd 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -89,7 +89,7 @@ abstract class CommonOrderLine extends CommonObjectLine * @deprecated * @see $subprice */ - public $price; + public $price; /** * Unit price before taxes diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index c3d6e7de299..3a8712ad67d 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,46 +61,46 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format + public $code; // Code of format - /** - * @var array format Array with informations - */ - public $format; + /** + * @var array format Array with informations + */ + public $format; - // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore - // protected - // Nom du format de l'etiquette - protected $_Avery_Name = ''; - // Marge de gauche de l'etiquette - protected $_Margin_Left = 0; - // marge en haut de la page avant la premiere etiquette - protected $_Margin_Top = 0; - // Espace horizontal entre 2 bandes d'etiquettes - protected $_X_Space = 0; - // Espace vertical entre 2 bandes d'etiquettes - protected $_Y_Space = 0; - // NX Nombre d'etiquettes sur la largeur de la page - protected $_X_Number = 0; - // NY Nombre d'etiquettes sur la hauteur de la page - protected $_Y_Number = 0; - // Largeur de chaque etiquette - protected $_Width = 0; - // Hauteur de chaque etiquette - protected $_Height = 0; - // Hauteur des caracteres - protected $_Char_Size = 10; - // Hauteur par defaut d'une ligne - protected $_Line_Height = 10; - // Type of metric.. Will help to calculate good values - protected $_Metric = 'mm'; - // Type of metric for the doc.. - protected $_Metric_Doc = 'mm'; - protected $_COUNTX = 1; - protected $_COUNTY = 1; - protected $_First = 1; - public $Tformat; - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore + // protected + // Nom du format de l'etiquette + protected $_Avery_Name = ''; + // Marge de gauche de l'etiquette + protected $_Margin_Left = 0; + // marge en haut de la page avant la premiere etiquette + protected $_Margin_Top = 0; + // Espace horizontal entre 2 bandes d'etiquettes + protected $_X_Space = 0; + // Espace vertical entre 2 bandes d'etiquettes + protected $_Y_Space = 0; + // NX Nombre d'etiquettes sur la largeur de la page + protected $_X_Number = 0; + // NY Nombre d'etiquettes sur la hauteur de la page + protected $_Y_Number = 0; + // Largeur de chaque etiquette + protected $_Width = 0; + // Hauteur de chaque etiquette + protected $_Height = 0; + // Hauteur des caracteres + protected $_Char_Size = 10; + // Hauteur par defaut d'une ligne + protected $_Line_Height = 10; + // Type of metric.. Will help to calculate good values + protected $_Metric = 'mm'; + // Type of metric for the doc.. + protected $_Metric_Doc = 'mm'; + protected $_COUNTX = 1; + protected $_COUNTY = 1; + protected $_First = 1; + public $Tformat; + // phpcs:enable /** * Constructor * @@ -111,7 +111,7 @@ abstract class CommonStickerGenerator $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -122,7 +122,7 @@ abstract class CommonStickerGenerator * @return int 1=OK, 0=KO */ public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); - // phpcs:enable + // phpcs:enable /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) @@ -134,7 +134,7 @@ abstract class CommonStickerGenerator */ public abstract function addSticker(&$pdf, $outputlangs, $param); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne @@ -145,7 +145,7 @@ abstract class CommonStickerGenerator */ public function Set_Char_Size(&$pdf, $pt) { - // phpcs:enable + // phpcs:enable if ($pt > 3) { $this->_Char_Size = $pt; $this->_Line_Height = $this->_Get_Height_Chars($pt); @@ -153,8 +153,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * protected Print dot line * @@ -167,9 +167,9 @@ abstract class CommonStickerGenerator * @param int $nbPointilles Nb pointilles * @return void */ - protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) - { - // phpcs:enable + protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) + { + // phpcs:enable $pdf->SetLineWidth($epaisseur); $length = abs($x1 - $x2); $hauteur = abs($y1 - $y2); @@ -181,23 +181,23 @@ abstract class CommonStickerGenerator for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($x2 - 1)) { - $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point - $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point } } } for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($y2 - 1)) { - $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point - $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point + $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point + $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point } } } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Function realisant une croix aux 4 coins des cartes * @@ -212,7 +212,7 @@ abstract class CommonStickerGenerator */ protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) { - // phpcs:enable + // phpcs:enable $pdf->SetDrawColor(192, 192, 192); $pdf->SetLineWidth($epaisseur); @@ -255,8 +255,8 @@ abstract class CommonStickerGenerator return $value; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Give the height for a char size given. * @@ -265,7 +265,7 @@ abstract class CommonStickerGenerator */ protected function _Get_Height_Chars($pt) { - // phpcs:enable + // phpcs:enable // Array for link between height of characters and space between lines $_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10); if (in_array($pt, array_keys($_Table_Hauteur_Chars))) { @@ -275,8 +275,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Set format * @@ -286,7 +286,7 @@ abstract class CommonStickerGenerator */ protected function _Set_Format(&$pdf, $format) { - // phpcs:enable + // phpcs:enable $this->_Metric = $format['metric']; $this->_Avery_Name = $format['name']; $this->_Avery_Code = $format['code']; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d87174c5636..56e8f313129 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -32,61 +32,61 @@ */ class Conf { - /** \public */ - //! To store properties found in conf file - public $file; + /** \public */ + //! To store properties found in conf file + public $file; - /** - * @var Object Associative array with some properties ->type, ->db, ... - */ - public $db; + /** + * @var Object Associative array with some properties ->type, ->db, ... + */ + public $db; - //! To store properties found into database - public $global; - //! To store browser info - public $browser; + //! To store properties found into database + public $global; + //! To store browser info + public $browser; - //! To store if javascript/ajax is enabked - public $use_javascript_ajax; - //! To store if javascript/ajax is enabked - public $disable_compute; + //! To store if javascript/ajax is enabked + public $use_javascript_ajax; + //! To store if javascript/ajax is enabked + public $disable_compute; //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) public $theme; // Contains current theme ("eldy", "auguria", ...) public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) - //! Used to store current menu handler + //! Used to store current menu handler public $standard_menu; - // List of activated modules - public $modules = array(); - public $modules_parts = array( - 'css' => array(), - 'js' => array(), - 'tabs' => array(), - 'triggers' => array(), - 'login' => array(), - 'substitutions' => array(), - 'menus' => array(), - 'theme' => array(), - 'sms' => array(), - 'tpl' => array(), - 'barcode' => array(), - 'models' => array(), - 'societe' => array(), - 'hooks' => array(), - 'dir' => array(), - 'syslog' => array(), - ); + // List of activated modules + public $modules = array(); + public $modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); - public $logbuffer = array(); + public $logbuffer = array(); - /** - * @var LogHandlerInterface[] - */ - public $loghandlers = array(); + /** + * @var LogHandlerInterface[] + */ + public $loghandlers = array(); - //! To store properties of multi-company - public $multicompany; + //! To store properties of multi-company + public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -212,7 +212,7 @@ class Conf elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } - // If this is a module constant (must be at end) + // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); @@ -227,20 +227,20 @@ class Conf $i++; } - $db->free($resql); - } + $db->free($resql); + } - // Include other local consts.php files and fetch their values to the corresponding database constants. - if (!empty($this->global->LOCAL_CONSTS_FILES)) { - $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); - foreach ($filesList as $file) { - $file = dol_sanitizeFileName($file); - dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. - } - } + // Include other local consts.php files and fetch their values to the corresponding database constants. + if (!empty($this->global->LOCAL_CONSTS_FILES)) { + $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); + foreach ($filesList as $file) { + $file = dol_sanitizeFileName($file); + dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. + } + } - //var_dump($this->modules); - //var_dump($this->modules_parts['theme']); + //var_dump($this->modules); + //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. @@ -296,7 +296,7 @@ class Conf // Define default dir_output and dir_temp for directories of modules foreach ($this->modules as $module) { - //var_dump($module); + //var_dump($module); // For multicompany sharings $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp"); @@ -450,7 +450,7 @@ class Conf // Set some default values //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month - $this->global->MAIN_MAIL_USE_MULTI_PART = 1; + $this->global->MAIN_MAIL_USE_MULTI_PART = 1; // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; @@ -459,9 +459,9 @@ class Conf if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; if (empty($this->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple'; - // Security + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator - if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask + if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask // conf->use_javascript_ajax $this->use_javascript_ajax = 1; @@ -499,16 +499,16 @@ class Conf if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) - if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' + if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' - // By default, suppliers objects can be linked to all projects - if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; + // By default, suppliers objects can be linked to all projects + if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; - // By default we enable feature to bill time spent - if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; + // By default we enable feature to bill time spent + if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; - // MAIN_HTML_TITLE - if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; + // MAIN_HTML_TITLE + if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25; @@ -520,7 +520,7 @@ class Conf // conf->theme et $this->css if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy"; - if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; + if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/".$this->theme."/style.css.php"; @@ -537,20 +537,20 @@ class Conf if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1; - // Format for date (used by default when not found or not searched in lang) - $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) - $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags - $this->format_hour_short = "%H:%M"; - $this->format_hour_short_duration = "%H:%M"; - $this->format_date_text_short = "%d %b %Y"; - $this->format_date_text = "%d %B %Y"; - $this->format_date_hour_short = "%d/%m/%Y %H:%M"; - $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; - $this->format_date_hour_text_short = "%d %b %Y %H:%M"; - $this->format_date_hour_text = "%d %B %Y %H:%M"; + // Format for date (used by default when not found or not searched in lang) + $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) + $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags + $this->format_hour_short = "%H:%M"; + $this->format_hour_short_duration = "%H:%M"; + $this->format_date_text_short = "%d %b %Y"; + $this->format_date_text = "%d %B %Y"; + $this->format_date_hour_short = "%d/%m/%Y %H:%M"; + $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; + $this->format_date_hour_text_short = "%d %b %Y %H:%M"; + $this->format_date_hour_text = "%d %B %Y %H:%M"; - // Duration of workday - if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; + // Duration of workday + if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; // Limites decimales si non definie (peuvent etre egale a 0) if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5; @@ -590,76 +590,76 @@ class Conf if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; // Timeouts - if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; - if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; + if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; + if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; // Set default variable to calculate VAT as if option tax_mode was 0 (standard) - if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; - if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; // Delay before warnings // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx if (isset($this->agenda)) { - $this->adherent->subscription = new stdClass(); - $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; + $this->adherent->subscription = new stdClass(); + $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; } if (isset($this->agenda)) { $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400; - } + } if (isset($this->projet)) { $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400; - $this->projet->task = new StdClass(); - $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; + $this->projet->task = new StdClass(); + $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; } - if (isset($this->commande)) { - $this->commande->client = new stdClass(); - $this->commande->fournisseur = new stdClass(); - $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; - $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; + if (isset($this->commande)) { + $this->commande->client = new stdClass(); + $this->commande->fournisseur = new stdClass(); + $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; + $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; } if (isset($this->propal)) { - $this->propal->cloture = new stdClass(); - $this->propal->facturation = new stdClass(); - $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; - $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; + $this->propal->cloture = new stdClass(); + $this->propal->facturation = new stdClass(); + $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; + $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; } if (isset($this->facture)) { - $this->facture->client = new stdClass(); - $this->facture->fournisseur = new stdClass(); - $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; - $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; + $this->facture->client = new stdClass(); + $this->facture->fournisseur = new stdClass(); + $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; + $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; } if (isset($this->contrat)) { - $this->contrat->services = new stdClass(); - $this->contrat->services->inactifs = new stdClass(); - $this->contrat->services->expires = new stdClass(); - $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; - $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; + $this->contrat->services = new stdClass(); + $this->contrat->services->inactifs = new stdClass(); + $this->contrat->services->expires = new stdClass(); + $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; + $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; } if (isset($this->commande)) { - $this->bank->rappro = new stdClass(); - $this->bank->cheque = new stdClass(); - $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; - $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; + $this->bank->rappro = new stdClass(); + $this->bank->cheque = new stdClass(); + $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; + $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; } if (isset($this->expensereport)) { - $this->expensereport->approve = new stdClass(); - $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; - $this->expensereport->payment = new stdClass(); - $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + $this->expensereport->approve = new stdClass(); + $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; + $this->expensereport->payment = new stdClass(); + $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + } + if (isset($this->holiday)) { + $this->holiday->approve = new stdClass(); + $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; } - if (isset($this->holiday)) { - $this->holiday->approve = new stdClass(); - $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; - } if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { - $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; + $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; } // For modules that want to disable top or left menu @@ -695,13 +695,13 @@ class Conf if (isset($this->categorie)) $this->category = $this->categorie; if (isset($this->project)) $this->project = $this->projet; - // Object $mc - if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) - { - if (is_object($mc)) $mc->setValues($this); - } + // Object $mc + if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) + { + if (is_object($mc)) $mc->setValues($this); + } - if (!empty($this->syslog->enabled)) { + if (!empty($this->syslog->enabled)) { // We init log handlers if (!empty($this->global->SYSLOG_HANDLERS)) { $handlers = json_decode($this->global->SYSLOG_HANDLERS); @@ -737,6 +737,6 @@ class Conf $this->loghandlers[$handler] = $loghandlerinstance; } } - } + } } } diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php index 9e79093b12b..801a44682c9 100644 --- a/htdocs/core/class/cproductnature.class.php +++ b/htdocs/core/class/cproductnature.class.php @@ -29,9 +29,9 @@ class CProductNature // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -48,66 +48,66 @@ class CProductNature // extends CommonObject */ public $records = array(); - /** - * @var string element - */ + /** + * @var string element + */ public $element='cproductnbature'; - /** - * @var string table element - */ + /** + * @var string table element + */ public $table_element='c_product_nature'; - /** + /** * @var int ID */ public $id; - /** - * @var int code - */ + /** + * @var int code + */ public $code; - /** - * @var string label - */ + /** + * @var string label + */ public $label; - /** - * @var int active - */ + /** + * @var int active + */ public $active; - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= "rowid,"; $sql .= "code,"; $sql .= "label,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : ((int) $this->id)) .","; $sql .= " ".(!isset($this->code) ? 'NULL' : ((int) $this->code)).","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape(trim($this->label))."'").","; @@ -117,185 +117,185 @@ class CProductNature // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - // Commit or rollback - if (!$resql) { + $resql = $this->db->query($sql); + // Commit or rollback + if (!$resql) { dol_syslog(get_class($this)."::create ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id of CUnit object to fetch (rowid) - * @param string $code Code - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '') - { - global $langs; + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql_where = array(); - if ($id) $sql_where[] = " t.rowid = ".$id; - if ($code>=0) $sql_where[] = " t.code = ". ((int) $code); - if (count($sql_where) > 0) { - $sql .= ' WHERE '.implode(' AND ', $sql_where); - } + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($code>=0) $sql_where[] = " t.code = ". ((int) $code); + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->label = $obj->label; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= " t.rowid,"; - $sql .= " t.code,"; - $sql .= " t.label,"; - $sql .= " t.active"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { - $sqlwhere[] = $key.'='.(int) $value; - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.label') { - $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } - $resql = $this->db->query($sql); - if ($resql) { - $this->records = array(); - $num = $this->db->num_rows($resql); - if ($num > 0) { - while ($obj = $this->db->fetch_object($resql)) - { - $record = new self($this->db); + $resql = $this->db->query($sql); + if ($resql) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); - $record->id = $obj->rowid; - $record->code = $obj->code; - $record->label = $obj->label; - $this->records[$record->id] = $record; - } - } - $this->db->free($resql); + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); - return $this->records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql .= " code=".(isset($this->code) ? ((int) $this->code) : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape(trim($this->label))."'" : "null").","; $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null"); - $sql .= " WHERE rowid=".(int) $this->id; + $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - // Commit or rollback + $resql = $this->db->query($sql); + // Commit or rollback if (!$resql) { - dol_syslog(get_class($this)."::update Error ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::update Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -308,10 +308,10 @@ class CProductNature // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - // Commit or rollback + // Commit or rollback if (!$resql) { - dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { @@ -331,7 +331,7 @@ class CProductNature // extends CommonObject { if ($mode == 'label') { return dol_getIdFromCode($this->db, $code, $this->table_element, 'label', 'code'); - } elseif ($mode == 'code'){ + } elseif ($mode == 'code') { return dol_getIdFromCode($this->db, $code, $this->table_element, 'code', 'code'); } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 80c47591fbb..b778b13c512 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -27,9 +27,9 @@ class Cstate // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,7 +44,7 @@ class Cstate // extends CommonObject //var $element='cstate'; //!< Id that identify managed objects //var $table_element='cstate'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -68,27 +68,27 @@ class Cstate // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -99,13 +99,13 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; $sql .= "rowid,"; $sql .= "code_departement,"; $sql .= "nom,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; @@ -115,84 +115,84 @@ class Cstate // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code_departement,"; $sql .= " t.nom,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code_departement = $obj->code_departement; //deprecated $this->code = $obj->code_departement; $this->nom = $obj->nom; //deprecated $this->name = $obj->nom; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -204,40 +204,40 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -250,15 +250,15 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 07d3563088e..fccdec72ab6 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -28,9 +28,9 @@ class Ctypent // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,7 +45,7 @@ class Ctypent // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -58,27 +58,27 @@ class Ctypent // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -94,7 +94,7 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent("; $sql .= "id,"; @@ -104,7 +104,7 @@ class Ctypent // extends CommonObject $sql .= "module"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; @@ -118,88 +118,88 @@ class Ctypent // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $label Label - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $label = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $label = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.id,"; $sql .= " t.code,"; $sql .= " t.libelle as label,"; $sql .= " t.fk_country as country_id,"; $sql .= " t.active,"; $sql .= " t.module"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; - if ($id) $sql .= " WHERE t.id = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; + if ($id) $sql .= " WHERE t.id = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->id; + $this->id = $obj->id; $this->code = $obj->code; $this->libelle = $obj->label; $this->country_id = $obj->country_id; $this->active = $obj->active; $this->module = $obj->module; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -212,27 +212,27 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").","; $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null").""; - $sql .= " WHERE id=".$this->id; + $sql .= " WHERE id=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -240,16 +240,16 @@ class Ctypent // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -262,21 +262,21 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) - { + // Commit or rollback + if ($error) + { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + } else { + $this->db->commit(); + return 1; + } + } } diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 410c3ae3f21..9d1e5c53de1 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -50,9 +50,9 @@ class Ctyperesource public $code; /** - * @var string Type resource label - */ - public $label; + * @var string Type resource label + */ + public $label; public $active; @@ -252,7 +252,7 @@ class Ctyperesource $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -482,9 +482,9 @@ class CtyperesourceLine public $code; /** - * @var string Type resource line label - */ - public $label; + * @var string Type resource line label + */ + public $label; public $active; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index ac7b07ea5a9..5e013b3d32f 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -28,9 +28,9 @@ class CUnits // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -46,7 +46,7 @@ class CUnits // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -61,27 +61,27 @@ class CUnits // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -97,7 +97,7 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; $sql .= "rowid,"; $sql .= "code,"; @@ -105,7 +105,7 @@ class CUnits // extends CommonObject $sql .= "short_label,"; $sql .= "unit_type"; $sql .= "scale"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; @@ -117,45 +117,45 @@ class CUnits // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id of CUnit object to fetch (rowid) - * @param string $code Code - * @param string $short_label Short Label ('g', 'kg', ...) - * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $short_label = '', $unit_type = '') - { - global $langs; + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @param string $short_label Short Label ('g', 'kg', ...) + * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $short_label = '', $unit_type = '') + { + global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.label,"; @@ -164,24 +164,24 @@ class CUnits // extends CommonObject $sql .= " t.unit_type,"; $sql .= " t.scale,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; - $sql_where = array(); - if ($id) $sql_where[] = " t.rowid = ".$id; - if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; - if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; - if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; - if (count($sql_where) > 0) { - $sql .= ' WHERE '.implode(' AND ', $sql_where); - } + $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; + if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; + if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->label = $obj->label; $this->short_label = $obj->short_label; @@ -189,110 +189,110 @@ class CUnits // extends CommonObject $this->unit_type = $obj->unit_type; $this->scale = $obj->scale; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= " t.rowid,"; - $sql .= " t.code,"; - $sql .= " t.label,"; - $sql .= " t.short_label,"; - $sql .= " t.unit_type,"; - $sql .= " t.scale,"; - $sql .= " t.active"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { - $sqlwhere[] = $key.'='.(int) $value; - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { - $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.short_label,"; + $sql .= " t.unit_type,"; + $sql .= " t.scale,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } - $resql = $this->db->query($sql); - if ($resql) { - $this->records = array(); - $num = $this->db->num_rows($resql); - if ($num > 0) { - while ($obj = $this->db->fetch_object($resql)) - { - $record = new self($this->db); + $resql = $this->db->query($sql); + if ($resql) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); - $record->id = $obj->rowid; - $record->code = $obj->code; - $record->label = $obj->label; - $record->short_label = $obj->short_label; - $record->unit_type = $obj->unit_type; - $record->scale = $obj->scale; - $record->active = $obj->active; - $this->records[$record->id] = $record; - } - } - $this->db->free($resql); + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $record->short_label = $obj->short_label; + $record->unit_type = $obj->unit_type; + $record->scale = $obj->scale; + $record->active = $obj->active; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); - return $this->records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -306,29 +306,29 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").","; $sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape($this->scale)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null"); - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -336,16 +336,16 @@ class CUnits // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -358,15 +358,15 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -386,9 +386,9 @@ class CUnits // extends CommonObject public function getUnitFromCode($code, $mode = 'code') { - if ($mode == 'short_label'){ + if ($mode == 'short_label') { return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid'); - } elseif ($mode == 'code'){ + } elseif ($mode == 'code') { return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid'); } @@ -404,21 +404,21 @@ class CUnits // extends CommonObject */ public function unitConverter($value, $fk_unit, $fk_new_unit = 0) { - $value = doubleval(price2num($value)); + $value = doubleval(price2num($value)); $fk_unit = intval($fk_unit); // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_unit); // convert to standard unit - $value = $value * $scaleUnitPow; - if ($fk_new_unit !=0 ){ + $value = $value * $scaleUnitPow; + if ($fk_new_unit != 0) { // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit); if (!empty($scaleUnitPow)) { // convert to new unit - $value = $value / $scaleUnitPow; + $value = $value / $scaleUnitPow; } } return round($value, 2); diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 4cddc65d636..9f901ed3452 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -28,12 +28,12 @@ */ class DiscountAbsolute { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error; @@ -48,190 +48,190 @@ class DiscountAbsolute */ public $id; - /** + /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; - public $discount_type; // 0 => customer discount, 1 => supplier discount - public $amount_ht; // - public $amount_tva; // - public $amount_ttc; // - public $multicurrency_amount_ht; - public $multicurrency_amount_tva; - public $multicurrency_amount_ttc; - // Vat rate - public $tva_tx; - public $vat_src_code; + public $discount_type; // 0 => customer discount, 1 => supplier discount + public $amount_ht; // + public $amount_tva; // + public $amount_ttc; // + public $multicurrency_amount_ht; + public $multicurrency_amount_tva; + public $multicurrency_amount_ttc; + // Vat rate + public $tva_tx; + public $vat_src_code; - /** + /** * @var int User ID Id utilisateur qui accorde la remise */ public $fk_user; - /** + /** * @var string description */ public $description; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) - */ - public $fk_facture_line; + /** + * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) + */ + public $fk_facture_line; - /** - * @var int ID invoice when a discount line is used into an invoice (for credit note) - */ - public $fk_facture; + /** + * @var int ID invoice when a discount line is used into an invoice (for credit note) + */ + public $fk_facture; - /** - * @var int ID credit note or deposit used to create the discount - */ - public $fk_facture_source; - public $ref_facture_source; // Ref credit note or deposit used to create the discount + /** + * @var int ID credit note or deposit used to create the discount + */ + public $fk_facture_source; + public $ref_facture_source; // Ref credit note or deposit used to create the discount public $type_facture_source; - public $fk_invoice_supplier_source; - public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount - public $type_invoice_supplier_source; + public $fk_invoice_supplier_source; + public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount + public $type_invoice_supplier_source; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Load object from database into memory - * - * @param int $rowid id discount to load - * @param int $fk_facture_source fk_facture_source - * @param int $fk_invoice_supplier_source fk_invoice_supplier_source - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) - { - global $conf; + /** + * Load object from database into memory + * + * @param int $rowid id discount to load + * @param int $fk_facture_source fk_facture_source + * @param int $fk_invoice_supplier_source fk_invoice_supplier_source + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) + { + global $conf; - // Check parameters - if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) - { - $this->error = 'ErrorBadParameters'; - return -1; - } + // Check parameters + if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) + { + $this->error = 'ErrorBadParameters'; + return -1; + } - $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; - $sql .= " sr.fk_user,"; - $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; - $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; - $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; - $sql .= " sr.datec,"; - $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; - $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; - $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; - if ($rowid) $sql .= " AND sr.rowid=".$rowid; - if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; - if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; + $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; + $sql .= " sr.fk_user,"; + $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; + $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; + $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; + $sql .= " sr.datec,"; + $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; + $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; + $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; + if ($rowid) $sql .= " AND sr.rowid=".$rowid; + if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; + if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->fk_soc = $obj->fk_soc; - $this->discount_type = $obj->discount_type; + $this->id = $obj->rowid; + $this->fk_soc = $obj->fk_soc; + $this->discount_type = $obj->discount_type; - $this->amount_ht = $obj->amount_ht; - $this->amount_tva = $obj->amount_tva; - $this->amount_ttc = $obj->amount_ttc; + $this->amount_ht = $obj->amount_ht; + $this->amount_tva = $obj->amount_tva; + $this->amount_ttc = $obj->amount_ttc; - $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; - $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; - $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; + $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; - $this->tva_tx = $obj->tva_tx; - $this->vat_src_code = $obj->vat_src_code; + $this->tva_tx = $obj->tva_tx; + $this->vat_src_code = $obj->vat_src_code; - $this->fk_user = $obj->fk_user; - $this->fk_facture_line = $obj->fk_facture_line; - $this->fk_facture = $obj->fk_facture; - $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source - $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source - $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source - $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; - $this->fk_invoice_supplier = $obj->fk_invoice_supplier; - $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source - $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source - $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source - $this->description = $obj->description; - $this->datec = $this->db->jdate($obj->datec); + $this->fk_user = $obj->fk_user; + $this->fk_facture_line = $obj->fk_facture_line; + $this->fk_facture = $obj->fk_facture; + $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source + $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source + $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source + $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; + $this->fk_invoice_supplier = $obj->fk_invoice_supplier; + $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source + $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source + $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source + $this->description = $obj->description; + $this->datec = $this->db->jdate($obj->datec); - $this->db->free($resql); - return 1; - } else { - $this->db->free($resql); - return 0; - } - } else { - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + $this->db->free($resql); + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; + } + } - /** - * Create a discount into database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create a discount into database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; - // Clean parameters - $this->amount_ht = price2num($this->amount_ht); - $this->amount_tva = price2num($this->amount_tva); - $this->amount_ttc = price2num($this->amount_ttc); + // Clean parameters + $this->amount_ht = price2num($this->amount_ht); + $this->amount_tva = price2num($this->amount_tva); + $this->amount_ttc = price2num($this->amount_ttc); - $this->tva_tx = price2num($this->tva_tx); + $this->tva_tx = price2num($this->tva_tx); - $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); - $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); - $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); + $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); + $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); + $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); - if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; - if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; - if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; + if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; + if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; + if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; - // Check parameters - if (empty($this->description)) - { - $this->error = 'BadValueForPropertyDescription'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } + // Check parameters + if (empty($this->description)) + { + $this->error = 'BadValueForPropertyDescription'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } - $userid = $user->id; + $userid = $user->id; if (!($userid > 0)) // For example when record is saved into an anonymous context with a not loaded object $user. { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -240,463 +240,463 @@ class DiscountAbsolute $userid = $tmpinvoice->fk_user_author; // We use the author of invoice } - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; - $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; - $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; - $sql .= " fk_facture_source, fk_invoice_supplier_source"; - $sql .= ")"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; - $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; - $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; - $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; - $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); - $sql .= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; + $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; + $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; + $sql .= " fk_facture_source, fk_invoice_supplier_source"; + $sql .= ")"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; + $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; + $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; + $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); - return $this->id; - } else { - $this->error = $this->db->lasterror().' - sql='.$sql; - return -1; - } - } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + return $this->id; + } else { + $this->error = $this->db->lasterror().' - sql='.$sql; + return -1; + } + } - /** - * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed - * - * @param User $user Object of user asking to delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - global $conf, $langs; + /** + * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed + * + * @param User $user Object of user asking to delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; - // Check if we can remove the discount - if ($this->fk_facture_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_facture_source = ".$this->fk_facture_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_facture_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_facture_source = ".$this->fk_facture_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - // Check if we can remove the discount - if ($this->fk_invoice_supplier_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_invoice_supplier_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - $this->db->begin(); + $this->db->begin(); - // Delete but only if not used - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; - if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie - elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie - else $sql .= " WHERE rowid = ".$this->id; // Delete only line - $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit + // Delete but only if not used + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; + if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie + elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie + else $sql .= " WHERE rowid = ".$this->id; // Delete only line + $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit - dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - // If source of discount was a credit note or deposit, we change source statut. - if ($this->fk_facture_source) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; + dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + // If source of discount was a credit note or deposit, we change source statut. + if ($this->fk_facture_source) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } elseif ($this->fk_invoice_supplier_source) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } elseif ($this->fk_invoice_supplier_source) { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * When discount is a global discount used as an invoice line, we link using rowidline. - * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice - * - * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) - * @return int <0 if KO, >0 if OK - */ - public function link_to_invoice($rowidline, $rowidinvoice) - { - // phpcs:enable - // Check parameters - if (!$rowidline && !$rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -1; - } - if ($rowidline && $rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -2; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * When discount is a global discount used as an invoice line, we link using rowidline. + * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice + * + * @param int $rowidline Invoice line id (To use discount into invoice lines) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @return int <0 if KO, >0 if OK + */ + public function link_to_invoice($rowidline, $rowidinvoice) + { + // phpcs:enable + // Check parameters + if (!$rowidline && !$rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -1; + } + if ($rowidline && $rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -2; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; - } else { - if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; - } - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; + } else { + if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; + } + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!empty($this->discount_type)) { - $this->fk_invoice_supplier_line = $rowidline; - $this->fk_invoice_supplier = $rowidinvoice; - } else { - $this->fk_facture_line = $rowidline; - $this->fk_facture = $rowidinvoice; - } - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!empty($this->discount_type)) { + $this->fk_invoice_supplier_line = $rowidline; + $this->fk_invoice_supplier = $rowidinvoice; + } else { + $this->fk_facture_line = $rowidline; + $this->fk_facture = $rowidinvoice; + } + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * Do not call this if discount is linked to a reconcialiated invoice - * - * @return int <0 if KO, >0 if OK - */ - public function unlink_invoice() - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; - } else { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * Do not call this if discount is linked to a reconcialiated invoice + * + * @return int <0 if KO, >0 if OK + */ + public function unlink_invoice() + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; + } else { $sql .= " SET fk_facture_line = NULL, fk_facture = NULL"; } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - /** - * Return amount (with tax) of discounts currently available for a company, user or other criteria - * - * @param Societe $company Object third party for filter - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre - * @param int $maxvalue Filter on max value for discount - * @param int $discount_type 0 => customer discount, 1 => supplier discount + /** + * Return amount (with tax) of discounts currently available for a company, user or other criteria + * + * @param Societe $company Object third party for filter + * @param User $user Filtre sur un user auteur des remises + * @param string $filter Filtre autre + * @param int $maxvalue Filter on max value for discount + * @param int $discount_type 0 => customer discount, 1 => supplier discount * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, amount otherwise - */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) - { - global $conf; + * @return int <0 if KO, amount otherwise + */ + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) + { + global $conf; - dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); + dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); - $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql .= " WHERE rc.entity = ".$conf->entity; - $sql .= " AND rc.discount_type=".intval($discount_type); - if (!empty($discount_type)) { - $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier - } else { - $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer - } - if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; - if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; - if ($filter) $sql .= ' AND ('.$filter.')'; - if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); + $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.entity = ".$conf->entity; + $sql .= " AND rc.discount_type=".intval($discount_type); + if (!empty($discount_type)) { + $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier + } else { + $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer + } + if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; + if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; + if ($filter) $sql .= ' AND ('.$filter.')'; + if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - //while ($obj) - //{ - //print 'zz'.$obj->amount; - //$obj = $this->db->fetch_object($resql); - //} + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + //while ($obj) + //{ + //print 'zz'.$obj->amount; + //$obj = $this->db->fetch_object($resql); + //} if ($multicurrency) { return $obj->amount_multicurrency; } - return $obj->amount; - } - return -1; - } - - - /** - * Return amount (with tax) of all deposits invoices used by invoice as a payment. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). - * - * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumDepositsUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } else { - $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and excess received amount otherwise - */ - public function getSumCreditNotesUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - /** - * Return amount (with tax) of all converted amount for this credit note - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return clickable ref of object (with picto or not) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @param string $option Where to link to ('invoice' or 'discount') - * @return string String with URL - */ - public function getNomUrl($withpicto, $option = 'invoice') - { - global $langs; - - $result = ''; - $link = ''; - $linkend = ''; - $label = ''; - $picto = ''; - $ref = ''; - - if ($option == 'invoice') { - $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; - $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; - $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; - $link = ''; - $linkend = ''; - $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; - $picto = 'bill'; - } - if ($option == 'discount') { - $label = $langs->trans("Discount"); - $link = ''; - $linkend = ''; - $ref = $langs->trans("Discount"); - $picto = 'generic'; - } - - - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - $result .= $link.$ref.$linkend; - return $result; - } + return $obj->amount; + } + return -1; + } /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Return amount (with tax) of all deposits invoices used by invoice as a payment. + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * + * @param CommonInvoice $invoice Object invoice (customer of supplier) + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumDepositsUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } else { + $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise + */ + public function getSumCreditNotesUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return clickable ref of object (with picto or not) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @param string $option Where to link to ('invoice' or 'discount') + * @return string String with URL + */ + public function getNomUrl($withpicto, $option = 'invoice') + { + global $langs; + + $result = ''; + $link = ''; + $linkend = ''; + $label = ''; + $picto = ''; + $ref = ''; + + if ($option == 'invoice') { + $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; + $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; + $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; + $link = ''; + $linkend = ''; + $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; + $picto = 'bill'; + } + if ($option == 'discount') { + $label = $langs->trans("Discount"); + $link = ''; + $linkend = ''; + $ref = $langs->trans("Discount"); + $picto = 'generic'; + } + + + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $link.$ref.$linkend; + return $result; + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 55474850b8e..a47ebbacd9f 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,132 +28,132 @@ */ class DolEditor { - public $tool; // Store the selected tool + public $tool; // Store the selected tool - // If using fckeditor - public $editor; + // If using fckeditor + public $editor; - // If not using fckeditor - public $content; - public $htmlname; - public $toolbarname; - public $toolbarstartexpanded; - public $rows; - public $cols; - public $height; - public $width; - public $readonly; + // If not using fckeditor + public $content; + public $htmlname; + public $toolbarname; + public $toolbarstartexpanded; + public $rows; + public $cols; + public $height; + public $width; + public $readonly; - /** - * Create an object to build an HTML area to edit a large string content - * - * @param string $htmlname HTML name of WYSIWIG field - * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) - * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). - * @param string $toolbarlocation Where bar is stored : - * 'In' each window has its own toolbar - * 'Out:name' share toolbar into the div called 'name' - * @param boolean $toolbarstartexpanded Bar is visible or not at start + /** + * Create an object to build an HTML area to edit a large string content + * + * @param string $htmlname HTML name of WYSIWIG field + * @param string $content Content of WYSIWIG field + * @param int $width Width in pixel of edit area (auto by default) + * @param int $height Height in pixel of edit area (200px by default) + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). + * @param string $toolbarlocation Where bar is stored : + * 'In' each window has its own toolbar + * 'Out:name' share toolbar into the div called 'name' + * @param boolean $toolbarstartexpanded Bar is visible or not at start * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". - * @param int $rows Size of rows for textarea tool + * @param int $rows Size of rows for textarea tool * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only */ - public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) - { - global $conf, $langs; + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) + { + global $conf, $langs; - dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); - if (!$rows) $rows = round($height / 20); - if (!$cols) $cols = ($width ?round($width / 6) : 80); + if (!$rows) $rows = round($height / 20); + if (!$cols) $cols = ($width ?round($width / 6) : 80); $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); - // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') - $defaulteditor = 'ckeditor'; - $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; - $this->uselocalbrowser = $uselocalbrowser; - $this->readonly = $readonly; + // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') + $defaulteditor = 'ckeditor'; + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; + $this->uselocalbrowser = $uselocalbrowser; + $this->readonly = $readonly; - // Check if extended editor is ok. If not we force textarea - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; + // Check if extended editor is ok. If not we force textarea + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; if ($okforextendededitor === 'ace') $this->tool = 'ace'; - //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile + //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile - // Define some properties - if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) - { - if ($this->tool == 'ckeditor' && ! dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. - $this->content = dol_nl2br($content); - } - else { - $this->content = $content; - } - $this->htmlname = $htmlname; - $this->toolbarname = $shorttoolbarname; - $this->toolbarstartexpanded = $toolbarstartexpanded; - $this->rows = max(ROWS_3, $rows); - $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max - $this->height = $height; - $this->width = $width; - } - } + // Define some properties + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) + { + if ($this->tool == 'ckeditor' && ! dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. + $this->content = dol_nl2br($content); + } + else { + $this->content = $content; + } + $this->htmlname = $htmlname; + $this->toolbarname = $shorttoolbarname; + $this->toolbarstartexpanded = $toolbarstartexpanded; + $this->rows = max(ROWS_3, $rows); + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max + $this->height = $height; + $this->width = $width; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output edit area inside the HTML stream. - * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) - * - * @param int $noprint 1=Return HTML string instead of printing it to output - * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. - * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. - * @param string $titlecontent Show title content before editor area. Used by ACE editor only. - * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) - * @return void|string - */ - public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output edit area inside the HTML stream. + * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) + * + * @param int $noprint 1=Return HTML string instead of printing it to output + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. + * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. + * @param string $titlecontent Show title content before editor area. Used by ACE editor only. + * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) + * @return void|string + */ + public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') + { + // phpcs:enable + global $conf, $langs; - $fullpage = false; - if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) - { - $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all - } + $fullpage = false; + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) + { + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + } - $found = 0; + $found = 0; $out = ''; - if (in_array($this->tool, array('textarea', 'ckeditor'))) - { - $found = 1; - //$out.= ''; + if (in_array($this->tool, array('textarea', 'ckeditor'))) + { + $found = 1; + //$out.= ''; - if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) - { - if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) + { + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); - if (!empty($conf->global->FCKEDITOR_SKIN)) { + if (!empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa } - $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; - $out .= ''."\n"; - } - } + } + $out .= ' })'.$morejs; + $out .= '});'."\n"; + $out .= ''."\n"; + } + } - // Output editor ACE - // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. - if (preg_match('/^ace/', $this->tool)) - { - $found = 1; + // Output editor ACE + // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. + if (preg_match('/^ace/', $this->tool)) + { + $found = 1; $format = $option; - $out .= "\n".''."\n"; + $out .= "\n".''."\n"; if ($titlecontent) { - $out .= '
'.$titlecontent; - $out .= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; - $out .= '
'; - $out .= ''."\n"; + $out .= ''."\n"; } - $out .= '
content);
-        	$out .= '
'; - $out .= ''; + $out .= '
content);
+			$out .= '
'; + $out .= ''; - $out .= ''."\n"; - } + $out .= ''."\n"; + } - if (empty($found)) - { - $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; - } + if (empty($found)) + { + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; + } - if ($noprint) return $out; - else print $out; - } + if ($noprint) return $out; + else print $out; + } } diff --git a/htdocs/core/class/dolexception.class.php b/htdocs/core/class/dolexception.class.php index 2c43a43127c..e083a47d5f7 100644 --- a/htdocs/core/class/dolexception.class.php +++ b/htdocs/core/class/dolexception.class.php @@ -27,10 +27,10 @@ */ class DolException extends Exception { - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 2b148a96e8a..2619d09602b 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -33,7 +33,7 @@ */ class DolGeoIP { - public $gi; + public $gi; /** * Constructor @@ -50,18 +50,18 @@ class DolGeoIP if ($type == 'country') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } elseif ($type == 'city') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } else { print 'ErrorBadParameterInConstructor'; return 0; } // Here, function exists (embedded into PHP or exists because we made include) @@ -93,9 +93,9 @@ class DolGeoIP { $this->gi = geoip_open($datfile, GEOIP_STANDARD); } else { - $this->gi = 'NOGI'; // We are using embedded php geoip functions - //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); - //print geoip_database_info(); + $this->gi = 'NOGI'; // We are using embedded php geoip functions + //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); + //print geoip_database_info(); } } @@ -118,8 +118,8 @@ class DolGeoIP } if ($this->gi == 'NOGI') { - // geoip_country_code_by_addr does not exists - return strtolower(geoip_country_code_by_name($ip)); + // geoip_country_code_by_addr does not exists + return strtolower(geoip_country_code_by_name($ip)); } else { if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { @@ -133,8 +133,8 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); - return strtolower(geoip_country_code_by_addr($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); + return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } } else { if ($geoipversion == '2') @@ -186,37 +186,37 @@ class DolGeoIP } } - /** - * Return verion of data file - * - * @return string Version of datafile - */ - public function getVersion() - { - global $conf; + /** + * Return verion of data file + * + * @return string Version of datafile + */ + public function getVersion() + { + global $conf; - $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + $geoipversion = '2'; // 'php', or '2' + if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; - if ($geoipversion == 'php') - { - if ($this->gi == 'NOGI') return geoip_database_info(); - else return 'geoip_database_info() function not available'; - } + if ($geoipversion == 'php') + { + if ($this->gi == 'NOGI') return geoip_database_info(); + else return 'geoip_database_info() function not available'; + } - return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; - } + return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; + } - /** - * Close geoip object - * - * @return void - */ - public function close() - { - if (function_exists('geoip_close')) { - // With some geoip with PEAR, geoip_close function may not exists - geoip_close($this->gi); - } - } + /** + * Close geoip object + * + * @return void + */ + public function close() + { + if (function_exists('geoip_close')) { + // With some geoip with PEAR, geoip_close function may not exists + geoip_close($this->gi); + } + } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index dee727cb596..0c6d15784f2 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -120,7 +120,7 @@ class DolGraph } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -129,12 +129,12 @@ class DolGraph */ public function SetHorizTickIncrement($xi) { - // phpcs:enable + // phpcs:enable $this->horizTickIncrement = $xi; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -143,12 +143,12 @@ class DolGraph */ public function SetNumXTicks($xt) { - // phpcs:enable + // phpcs:enable $this->SetNumXTicks = $xt; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set label interval to reduce number of labels * @@ -157,12 +157,12 @@ class DolGraph */ public function SetLabelInterval($x) { - // phpcs:enable + // phpcs:enable $this->labelInterval = $x; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X grid * @@ -171,12 +171,12 @@ class DolGraph */ public function SetHideXGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideXGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid * @@ -185,12 +185,12 @@ class DolGraph */ public function SetHideYGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideYGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set y label * @@ -199,11 +199,11 @@ class DolGraph */ public function SetYLabel($label) { - // phpcs:enable + // phpcs:enable $this->YLabel = $label; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set width * @@ -212,11 +212,11 @@ class DolGraph */ public function SetWidth($w) { - // phpcs:enable + // phpcs:enable $this->width = $w; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set title * @@ -225,11 +225,11 @@ class DolGraph */ public function SetTitle($title) { - // phpcs:enable + // phpcs:enable $this->title = $title; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -239,11 +239,11 @@ class DolGraph */ public function SetData($data) { - // phpcs:enable + // phpcs:enable $this->data = $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -252,11 +252,11 @@ class DolGraph */ public function SetDataColor($datacolor) { - // phpcs:enable + // phpcs:enable $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type * @@ -266,11 +266,11 @@ class DolGraph */ public function SetType($type) { - // phpcs:enable + // phpcs:enable $this->type = $type; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set legend * @@ -279,11 +279,11 @@ class DolGraph */ public function SetLegend($legend) { - // phpcs:enable + // phpcs:enable $this->Legend = $legend; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min width * @@ -292,120 +292,120 @@ class DolGraph */ public function SetLegendWidthMin($legendwidthmin) { - // phpcs:enable + // phpcs:enable $this->LegendWidthMin = $legendwidthmin; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set max value * * @param int $max Max value * @return void */ - public function SetMaxValue($max) + public function SetMaxValue($max) { - // phpcs:enable + // phpcs:enable $this->MaxValue = $max; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value * * @return int Max value */ - public function GetMaxValue() + public function GetMaxValue() { - // phpcs:enable + // phpcs:enable return $this->MaxValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min value * * @param int $min Min value * @return void */ - public function SetMinValue($min) + public function SetMinValue($min) { - // phpcs:enable + // phpcs:enable $this->MinValue = $min; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get min value * * @return int Max value */ - public function GetMinValue() + public function GetMinValue() { - // phpcs:enable + // phpcs:enable return $this->MinValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set height * * @param int $h Height * @return void */ - public function SetHeight($h) + public function SetHeight($h) { - // phpcs:enable + // phpcs:enable $this->height = $h; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetShading($s) + public function SetShading($s) { - // phpcs:enable + // phpcs:enable $this->SetShading = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetCssPrefix($s) + public function SetCssPrefix($s) { - // phpcs:enable + // phpcs:enable $this->cssprefix = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bg color * * @return void */ - public function ResetBgColor() + public function ResetBgColor() { - // phpcs:enable + // phpcs:enable unset($this->bgcolor); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bgcolorgrid * * @return void */ - public function ResetBgColorGrid() + public function ResetBgColorGrid() { - // phpcs:enable + // phpcs:enable unset($this->bgcolorgrid); } @@ -414,7 +414,7 @@ class DolGraph * * @return string Error */ - public function isGraphKo() + public function isGraphKo() { return $this->error; } @@ -425,7 +425,7 @@ class DolGraph * @param int $showlegend 1=Show legend (default), 0=Hide legend, 2=Show legend on right * @return void */ - public function setShowLegend($showlegend) + public function setShowLegend($showlegend) { $this->showlegend = $showlegend; } @@ -436,7 +436,7 @@ class DolGraph * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ - public function setShowPointValue($showpointvalue) + public function setShowPointValue($showpointvalue) { $this->showpointvalue = $showpointvalue; } @@ -447,23 +447,23 @@ class DolGraph * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ - public function setShowPercent($showpercent) + public function setShowPercent($showpercent) { $this->showpercent = $showpercent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of complete image * * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColor($bg_color = array(255, 255, 255)) + public function SetBgColor($bg_color = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_color)) @@ -480,16 +480,16 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of grid * * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) + public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_colorgrid)) @@ -506,27 +506,27 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset data color * * @return void */ - public function ResetDataColor() - { - // phpcs:enable - unset($this->datacolor); - } + public function ResetDataColor() + { + // phpcs:enable + unset($this->datacolor); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Get max value * * @return int Max value */ - public function GetMaxValueInData() + public function GetMaxValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -547,15 +547,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return int Min value of all data */ - public function GetMinValueInData() + public function GetMinValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -576,15 +576,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return max value of all data * * @return int Max value of all data */ - public function GetCeilMaxValue() + public function GetCeilMaxValue() { - // phpcs:enable + // phpcs:enable $max = $this->GetMaxValueInData(); if ($max != 0) $max++; $size = dol_strlen(abs(ceil($max))); @@ -601,15 +601,15 @@ class DolGraph return $res; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return double Max value of all data */ - public function GetFloorMinValue() + public function GetFloorMinValue() { - // phpcs:enable + // phpcs:enable $min = $this->GetMinValueInData(); if ($min == '') $min = 0; if ($min != 0) $min--; @@ -633,7 +633,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - public function draw($file, $fileurl = '') + public function draw($file, $fileurl = '') { if (empty($file)) { @@ -656,7 +656,7 @@ class DolGraph call_user_func_array(array($this, $call), array($file, $fileurl)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a graph using JFlot library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); @@ -675,7 +675,7 @@ class DolGraph */ private function draw_jflot($file, $fileurl) { - // phpcs:enable + // phpcs:enable global $conf, $langs; dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); @@ -732,9 +732,9 @@ class DolGraph if (!empty($this->title)) $this->stringtoshow .= '
'.$this->title.'
'; if (!empty($this->shownographyet)) { - $this->stringtoshow .= '
'; - $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; - return; + $this->stringtoshow .= '
'; + $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; + return; } // Start the div that will contains all the graph @@ -825,7 +825,7 @@ class DolGraph // Other cases, graph of type 'bars', 'lines' else { // Add code to support tooltips - // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes + // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes $this->stringtoshow .= ' function showTooltip_'.$tag.'(x, y, contents) { $(\'
\' + contents + \'
\').css({ @@ -882,13 +882,13 @@ class DolGraph $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { - if ($nblot == 3) { - if ($i == $firstlot) $align = 'right'; - elseif ($i == $firstlot + 1) $align = 'center'; - else $align = 'left'; - $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; - } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; - } + if ($nblot == 3) { + if ($i == $firstlot) $align = 'right'; + elseif ($i == $firstlot + 1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; + } if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: '.($this->type[$i] == 'linesnopoint' ? 'false' : 'true').' }, '; $this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $i++; @@ -1280,7 +1280,7 @@ class DolGraph * * @return string HTML string to total value */ - public function total() + public function total() { $value = 0; foreach ($this->data as $valarray) // Loop on each x @@ -1296,7 +1296,7 @@ class DolGraph * @param int|string $shownographyet Show graph to say there is not enough data or the message in $shownographyet if it is a string. * @return string HTML string to show graph */ - public function show($shownographyet = 0) + public function show($shownographyet = 0) { global $langs; @@ -1305,9 +1305,9 @@ class DolGraph $s = '
'; $s .= '
'; if (is_numeric($shownographyet)) { - $s .= $langs->trans("NotEnoughDataYet").'...'; + $s .= $langs->trans("NotEnoughDataYet").'...'; } else { - $s .= $shownographyet.'...'; + $s .= $shownographyet.'...'; } $s .= '
'; return $s; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ba636ac2569..c8905e756d6 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -115,429 +115,429 @@ use Mike42\Escpos\EscposImage; */ class dolReceiptPrinter extends Printer { - const CONNECTOR_DUMMY = 1; - const CONNECTOR_FILE_PRINT = 2; - const CONNECTOR_NETWORK_PRINT = 3; - const CONNECTOR_WINDOWS_PRINT = 4; - const CONNECTOR_CUPS_PRINT = 5; + const CONNECTOR_DUMMY = 1; + const CONNECTOR_FILE_PRINT = 2; + const CONNECTOR_NETWORK_PRINT = 3; + const CONNECTOR_WINDOWS_PRINT = 4; + const CONNECTOR_CUPS_PRINT = 5; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /* + /* * @var string[] array of tags */ - public $tags; - public $printer; - public $template; + public $tags; + public $printer; + public $template; - /** - * Number of order printer - * @var int - */ - public $orderprinter; + /** + * Number of order printer + * @var int + */ + public $orderprinter; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); - /** - * Constructor - * - * @param DoliDB $db database - */ - public function __construct($db) - { - $this->db = $db; - $this->tags = array( - 'dol_line_feed' => 'DOL_LINE_FEED', - 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', - 'dol_align_left' => 'DOL_ALIGN_LEFT', - 'dol_align_center' => 'DOL_ALIGN_CENTER', - 'dol_align_right' => 'DOL_ALIGN_RIGHT', - 'dol_use_font_a' => 'DOL_USE_FONT_A', - 'dol_use_font_b' => 'DOL_USE_FONT_B', - 'dol_use_font_c' => 'DOL_USE_FONT_C', - 'dol_bold' => 'DOL_BOLD', - 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', - 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', - 'dol_double_width' => 'DOL_DOUBLE_WIDTH', - 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', - 'dol_underline' => 'DOL_UNDERLINE', - 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', - 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', - 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', - 'dol_open_drawer' => 'DOL_OPEN_DRAWER', - 'dol_beep' => 'DOL_BEEP', - 'dol_print_text' => 'DOL_PRINT_TEXT', - 'dol_print_barcode' => 'DOL_PRINT_BARCODE', - 'dol_value_date' => 'DateInvoice', - 'dol_value_date_time' => 'DateInvoiceWithTime', - 'dol_value_year' => 'YearInvoice', - 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', - 'dol_value_month' => 'DOL_VALUE_MONTH', - 'dol_value_day' => 'DOL_VALUE_DAY', - 'dol_value_day_letters' => 'DOL_VALUE_DAY', - 'dol_print_payment' => 'DOL_PRINT_PAYMENT', - 'dol_print_logo' => 'DOL_PRINT_LOGO', - 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', - 'dol_value_object_id' => 'InvoiceID', - 'dol_value_object_ref' => 'InvoiceRef', - 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', - 'dol_print_object_tax' => 'TotalVAT', - 'dol_print_object_local_tax1' => 'TotalLT1', - 'dol_print_object_local_tax2' => 'TotalLT2', - 'dol_print_object_total' => 'Total', - 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', - //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', - 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', - 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', - 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', - 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', - 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', - 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', - 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', - //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', - //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', - 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', - 'dol_value_mysoc_address' => 'Address', - 'dol_value_mysoc_zip' => 'Zip', - 'dol_value_mysoc_town' => 'Town', - 'dol_value_mysoc_country' => 'Country', - 'dol_value_mysoc_idprof1' => 'ProfId1', - 'dol_value_mysoc_idprof2' => 'ProfId2', - 'dol_value_mysoc_idprof3' => 'ProfId3', - 'dol_value_mysoc_idprof4' => 'ProfId4', - 'dol_value_mysoc_idprof5' => 'ProfId5', - 'dol_value_mysoc_idprof6' => 'ProfId6', - 'dol_value_mysoc_tva_intra' => 'VATIntra', - 'dol_value_mysoc_capital' => 'Capital', - 'dol_value_vendor_lastname' => 'VendorLastname', - 'dol_value_vendor_firstname' => 'VendorFirstname', - 'dol_value_vendor_mail' => 'VendorEmail', - ); - } + /** + * Constructor + * + * @param DoliDB $db database + */ + public function __construct($db) + { + $this->db = $db; + $this->tags = array( + 'dol_line_feed' => 'DOL_LINE_FEED', + 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', + 'dol_align_left' => 'DOL_ALIGN_LEFT', + 'dol_align_center' => 'DOL_ALIGN_CENTER', + 'dol_align_right' => 'DOL_ALIGN_RIGHT', + 'dol_use_font_a' => 'DOL_USE_FONT_A', + 'dol_use_font_b' => 'DOL_USE_FONT_B', + 'dol_use_font_c' => 'DOL_USE_FONT_C', + 'dol_bold' => 'DOL_BOLD', + 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', + 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', + 'dol_double_width' => 'DOL_DOUBLE_WIDTH', + 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', + 'dol_underline' => 'DOL_UNDERLINE', + 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', + 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', + 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', + 'dol_open_drawer' => 'DOL_OPEN_DRAWER', + 'dol_beep' => 'DOL_BEEP', + 'dol_print_text' => 'DOL_PRINT_TEXT', + 'dol_print_barcode' => 'DOL_PRINT_BARCODE', + 'dol_value_date' => 'DateInvoice', + 'dol_value_date_time' => 'DateInvoiceWithTime', + 'dol_value_year' => 'YearInvoice', + 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', + 'dol_value_month' => 'DOL_VALUE_MONTH', + 'dol_value_day' => 'DOL_VALUE_DAY', + 'dol_value_day_letters' => 'DOL_VALUE_DAY', + 'dol_print_payment' => 'DOL_PRINT_PAYMENT', + 'dol_print_logo' => 'DOL_PRINT_LOGO', + 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', + 'dol_value_object_id' => 'InvoiceID', + 'dol_value_object_ref' => 'InvoiceRef', + 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', + 'dol_print_object_tax' => 'TotalVAT', + 'dol_print_object_local_tax1' => 'TotalLT1', + 'dol_print_object_local_tax2' => 'TotalLT2', + 'dol_print_object_total' => 'Total', + 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', + //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', + 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', + 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', + 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', + 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', + 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', + 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', + 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', + //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', + //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', + 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', + 'dol_value_mysoc_address' => 'Address', + 'dol_value_mysoc_zip' => 'Zip', + 'dol_value_mysoc_town' => 'Town', + 'dol_value_mysoc_country' => 'Country', + 'dol_value_mysoc_idprof1' => 'ProfId1', + 'dol_value_mysoc_idprof2' => 'ProfId2', + 'dol_value_mysoc_idprof3' => 'ProfId3', + 'dol_value_mysoc_idprof4' => 'ProfId4', + 'dol_value_mysoc_idprof5' => 'ProfId5', + 'dol_value_mysoc_idprof6' => 'ProfId6', + 'dol_value_mysoc_tva_intra' => 'VATIntra', + 'dol_value_mysoc_capital' => 'Capital', + 'dol_value_vendor_lastname' => 'VendorLastname', + 'dol_value_vendor_firstname' => 'VendorFirstname', + 'dol_value_vendor_mail' => 'VendorEmail', + ); + } - /** - * list printers - * - * @return int 0 if OK; >0 if KO - */ - public function listPrinters() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $row = $this->db->fetch_array($resql); - switch ($row['fk_type']) { - case 1: - $row['fk_type_name'] = 'CONNECTOR_DUMMY'; - break; - case 2: - $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; - break; - case 3: - $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; - break; - case 4: - $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; - break; - case 5: - $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; - break; - default: - $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; - break; - } - switch ($row['fk_profile']) { - case 0: - $row['fk_profile_name'] = 'PROFILE_DEFAULT'; - break; - case 1: - $row['fk_profile_name'] = 'PROFILE_SIMPLE'; - break; - case 2: - $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; - break; - case 3: - $row['fk_profile_name'] = 'PROFILE_P822D'; - break; - default: - $row['fk_profile_name'] = 'PROFILE_STAR'; - break; - } - $obj[] = $row; - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinters = $obj; - return $error; - } + /** + * list printers + * + * @return int 0 if OK; >0 if KO + */ + public function listPrinters() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $row = $this->db->fetch_array($resql); + switch ($row['fk_type']) { + case 1: + $row['fk_type_name'] = 'CONNECTOR_DUMMY'; + break; + case 2: + $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; + break; + case 3: + $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; + break; + case 4: + $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; + break; + case 5: + $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; + break; + default: + $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; + break; + } + switch ($row['fk_profile']) { + case 0: + $row['fk_profile_name'] = 'PROFILE_DEFAULT'; + break; + case 1: + $row['fk_profile_name'] = 'PROFILE_SIMPLE'; + break; + case 2: + $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; + break; + case 3: + $row['fk_profile_name'] = 'PROFILE_P822D'; + break; + default: + $row['fk_profile_name'] = 'PROFILE_STAR'; + break; + } + $obj[] = $row; + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinters = $obj; + return $error; + } - /** - * List printers templates - * - * @return int 0 if OK; >0 if KO - */ - public function listPrintersTemplates() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $obj[] = $this->db->fetch_array($resql); - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinterstemplates = $obj; - return $error; - } + /** + * List printers templates + * + * @return int 0 if OK; >0 if KO + */ + public function listPrintersTemplates() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $obj[] = $this->db->fetch_array($resql); + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinterstemplates = $obj; + return $error; + } - /** - * Form to Select type printer - * - * @param string $selected Id printer type pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') - { - global $langs; + /** + * Form to Select type printer + * + * @param string $selected Id printer type pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') + { + global $langs; - $options = array( - 1 => $langs->trans('CONNECTOR_DUMMY'), - 2 => $langs->trans('CONNECTOR_FILE_PRINT'), - 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), - 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), 5 => $langs->trans('CONNECTOR_CUPS_PRINT'), - ); + ); - $this->resprint = Form::selectarray($htmlname, $options, $selected); + $this->resprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + return 0; + } - /** - * Form to Select Profile printer - * - * @param string $selected Id printer profile pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') - { - global $langs; + /** + * Form to Select Profile printer + * + * @param string $selected Id printer profile pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') + { + global $langs; - $options = array( - 0 => $langs->trans('PROFILE_DEFAULT'), - 1 => $langs->trans('PROFILE_SIMPLE'), - 2 => $langs->trans('PROFILE_EPOSTEP'), - 3 => $langs->trans('PROFILE_P822D'), - 4 => $langs->trans('PROFILE_STAR'), - ); + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR'), + ); - $this->profileresprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; + } - /** - * Function to Add a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @return int 0 if OK; >0 if KO - */ - public function addPrinter($name, $type, $profile, $parameter) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; - $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Add a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @return int 0 if OK; >0 if KO + */ + public function addPrinter($name, $type, $profile, $parameter) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function updatePrinter($name, $type, $profile, $parameter, $printerid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', fk_type='.$type; - $sql .= ', fk_profile='.$profile; - $sql .= ', parameter="'.$this->db->escape($parameter).'"'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function updatePrinter($name, $type, $profile, $parameter, $printerid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', fk_type='.$type; + $sql .= ', fk_profile='.$profile; + $sql .= ', parameter="'.$this->db->escape($parameter).'"'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Delete a printer from db - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function deletePrinter($printerid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Delete a printer from db + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function deletePrinter($printerid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to add a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @return int 0 if OK; >0 if KO - */ - public function addTemplate($name, $template) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; - $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to add a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @return int 0 if OK; >0 if KO + */ + public function addTemplate($name, $template) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; + $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to delete a printer template in db - * - * @param int $templateid Template ID - * @return int 0 if OK; >0 if KO - */ - public function deleteTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); - $sql .= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to delete a printer template in db + * + * @param int $templateid Template ID + * @return int 0 if OK; >0 if KO + */ + public function deleteTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); + $sql .= " AND entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function updateTemplate($name, $template, $templateid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', template="'.$this->db->escape($template).'"'; - $sql .= ' WHERE rowid='.$templateid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function updateTemplate($name, $template, $templateid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', template="'.$this->db->escape($template).'"'; + $sql .= ' WHERE rowid='.$templateid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Send Test page to Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendTestToPrinter($printerid) - { - global $conf; - $error = 0; - $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); - //$this->profile = CapabilityProfile::load("TM-T88IV"); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - try { - $this->printer->bitImage($img); - $this->printer->text("Hello World!\n"); - $testStr = "1234567890"; - $this->printer->barcode($testStr); - //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); - $this->printer->text("Most simple example\n"); - $this->printer->feed(); - $this->printer->cut(); + /** + * Function to Send Test page to Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendTestToPrinter($printerid) + { + global $conf; + $error = 0; + $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); + //$this->profile = CapabilityProfile::load("TM-T88IV"); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + try { + $this->printer->bitImage($img); + $this->printer->text("Hello World!\n"); + $testStr = "1234567890"; + $this->printer->barcode($testStr); + //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); + $this->printer->text("Most simple example\n"); + $this->printer->feed(); + $this->printer->cut(); // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector) @@ -545,227 +545,227 @@ class dolReceiptPrinter extends Printer $data = $this->printer->connector-> getData(); dol_syslog($data); } - $this->printer->close(); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->printer->close(); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } - /** - * Function to Print Receipt Ticket - * - * @param Facture|Commande $object Order or invoice object - * @param int $templateid Template id - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendToPrinter($object, $templateid, $printerid) - { - global $conf, $mysoc, $langs, $user; - $error = 0; - $ret = $this->loadTemplate($templateid); + /** + * Function to Print Receipt Ticket + * + * @param Facture|Commande $object Order or invoice object + * @param int $templateid Template id + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendToPrinter($object, $templateid, $printerid) + { + global $conf, $mysoc, $langs, $user; + $error = 0; + $ret = $this->loadTemplate($templateid); - // tags a remplacer par leur valeur avant de parser (dol_value_xxx) - $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); - $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); - //$this->template = str_replace('', $object->points, $this->template); - $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template); - $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template); - $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template); - $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); - $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); - $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); - $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); + // tags a remplacer par leur valeur avant de parser (dol_value_xxx) + $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); + $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); + //$this->template = str_replace('', $object->points, $this->template); + $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template); + $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template); + $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template); + $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); + $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); + $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); + $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); - $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); - $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); - $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template); - $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template); - //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); - $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template); - //$this->template = str_replace('', $object->customer_account_balance, $this->template); - //$this->template = str_replace('', $object->customer_points, $this->template); + $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); + $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); + $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template); + $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template); + //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); + $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template); + //$this->template = str_replace('', $object->customer_account_balance, $this->template); + //$this->template = str_replace('', $object->customer_points, $this->template); - $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template); - $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template); - $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template); - $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template); - $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template); - $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template); - $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template); + $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template); + $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template); + $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template); + $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template); + $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template); + $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template); + $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template); - $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template); - $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template); - $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template); + $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template); + $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template); + $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template); - // parse template + // parse template $this->template = str_replace("{", "<", $this->template); $this->template = str_replace("}", ">", $this->template); - $p = xml_parser_create(); - xml_parse_into_struct($p, $this->template, $vals, $index); - xml_parser_free($p); - //print '
'.print_r($index, true).'
'; - //print '
'.print_r($vals, true).'
'; - // print ticket - $level = 0; - $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - $nboflines = count($vals); - for ($tplline = 0; $tplline < $nboflines; $tplline++) { - //var_dump($vals[$tplline]['value']); - switch ($vals[$tplline]['tag']) { - case 'DOL_PRINT_TEXT': - $this->printer->text($vals[$tplline]['value']); - break; - case 'DOL_PRINT_OBJECT_LINES': - foreach ($object->lines as $line) { - //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX': - //var_dump($object); - $vatarray = array(); - foreach ($object->lines as $line) { - $vatarray[$line->tva_tx] += $line->total_tva; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX1': - //var_dump($object); - $total_localtax1 = 0; - foreach ($object->lines as $line) { - $total_localtax1 += $line->total_localtax1; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX2': - //var_dump($object); - $total_localtax2 = 0; - foreach ($object->lines as $line) { - $total_localtax2 += $line->total_localtax2; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TOTAL': - $title = $langs->trans('TotalHT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalVAT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalTTC'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - break; - case 'DOL_LINE_FEED': - $this->printer->feed(); - break; - case 'DOL_LINE_FEED_REVERSE': - $this->printer->feedReverse(); - break; - case 'DOL_ALIGN_CENTER': - $this->printer->setJustification(Printer::JUSTIFY_CENTER); - break; - case 'DOL_ALIGN_RIGHT': - $this->printer->setJustification(Printer::JUSTIFY_RIGHT); - break; - case 'DOL_ALIGN_LEFT': - $this->printer->setJustification(Printer::JUSTIFY_LEFT); - break; - case 'DOL_OPEN_DRAWER': - $this->printer->pulse(); - break; - case 'DOL_ACTIVATE_BUZZER': - //$this->printer->buzzer(); - break; - case 'DOL_PRINT_BARCODE': - // $vals[$tplline]['value'] -> barcode($content, $type) - // var_dump($vals[$tplline]['value']); - try { - $this->printer->barcode($vals[$tplline]['value']); - } catch (Exception $e) { - $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; - $error++; - } - break; - case 'DOL_PRINT_LOGO': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->graphics($img); - break; - case 'DOL_PRINT_LOGO_OLD': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->bitImage($img); - break; - case 'DOL_PRINT_QRCODE': - // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) - $this->printer->qrcode($vals[$tplline]['value']); - break; - case 'DOL_CUT_PAPER_FULL': - $this->printer->cut(Printer::CUT_FULL); - break; - case 'DOL_CUT_PAPER_PARTIAL': - $this->printer->cut(Printer::CUT_PARTIAL); - break; - case 'DOL_USE_FONT_A': - $this->printer->setFont(Printer::FONT_A); - break; - case 'DOL_USE_FONT_B': - $this->printer->setFont(Printer::FONT_B); - break; - case 'DOL_USE_FONT_C': - $this->printer->setFont(Printer::FONT_C); - break; + $p = xml_parser_create(); + xml_parse_into_struct($p, $this->template, $vals, $index); + xml_parser_free($p); + //print '
'.print_r($index, true).'
'; + //print '
'.print_r($vals, true).'
'; + // print ticket + $level = 0; + $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + $nboflines = count($vals); + for ($tplline = 0; $tplline < $nboflines; $tplline++) { + //var_dump($vals[$tplline]['value']); + switch ($vals[$tplline]['tag']) { + case 'DOL_PRINT_TEXT': + $this->printer->text($vals[$tplline]['value']); + break; + case 'DOL_PRINT_OBJECT_LINES': + foreach ($object->lines as $line) { + //var_dump($line); + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX': + //var_dump($object); + $vatarray = array(); + foreach ($object->lines as $line) { + $vatarray[$line->tva_tx] += $line->total_tva; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX1': + //var_dump($object); + $total_localtax1 = 0; + foreach ($object->lines as $line) { + $total_localtax1 += $line->total_localtax1; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX2': + //var_dump($object); + $total_localtax2 = 0; + foreach ($object->lines as $line) { + $total_localtax2 += $line->total_localtax2; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TOTAL': + $title = $langs->trans('TotalHT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalVAT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalTTC'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + break; + case 'DOL_LINE_FEED': + $this->printer->feed(); + break; + case 'DOL_LINE_FEED_REVERSE': + $this->printer->feedReverse(); + break; + case 'DOL_ALIGN_CENTER': + $this->printer->setJustification(Printer::JUSTIFY_CENTER); + break; + case 'DOL_ALIGN_RIGHT': + $this->printer->setJustification(Printer::JUSTIFY_RIGHT); + break; + case 'DOL_ALIGN_LEFT': + $this->printer->setJustification(Printer::JUSTIFY_LEFT); + break; + case 'DOL_OPEN_DRAWER': + $this->printer->pulse(); + break; + case 'DOL_ACTIVATE_BUZZER': + //$this->printer->buzzer(); + break; + case 'DOL_PRINT_BARCODE': + // $vals[$tplline]['value'] -> barcode($content, $type) + // var_dump($vals[$tplline]['value']); + try { + $this->printer->barcode($vals[$tplline]['value']); + } catch (Exception $e) { + $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; + $error++; + } + break; + case 'DOL_PRINT_LOGO': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->graphics($img); + break; + case 'DOL_PRINT_LOGO_OLD': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->bitImage($img); + break; + case 'DOL_PRINT_QRCODE': + // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) + $this->printer->qrcode($vals[$tplline]['value']); + break; + case 'DOL_CUT_PAPER_FULL': + $this->printer->cut(Printer::CUT_FULL); + break; + case 'DOL_CUT_PAPER_PARTIAL': + $this->printer->cut(Printer::CUT_PARTIAL); + break; + case 'DOL_USE_FONT_A': + $this->printer->setFont(Printer::FONT_A); + break; + case 'DOL_USE_FONT_B': + $this->printer->setFont(Printer::FONT_B); + break; + case 'DOL_USE_FONT_C': + $this->printer->setFont(Printer::FONT_C); + break; case 'DOL_BOLD': - $this->printer->setEmphasis(true); - break; + $this->printer->setEmphasis(true); + break; case 'DOL_BOLD_DISABLED': - $this->printer->setEmphasis(false); - break; + $this->printer->setEmphasis(false); + break; case 'DOL_DOUBLE_HEIGHT': - $this->printer->setTextSize(1, 2); - break; + $this->printer->setTextSize(1, 2); + break; case 'DOL_DOUBLE_WIDTH': - $this->printer->setTextSize(2, 1); - break; + $this->printer->setTextSize(2, 1); + break; case 'DOL_DEFAULT_HEIGHT_WIDTH': - $this->printer->setTextSize(1, 1); - break; + $this->printer->setTextSize(1, 1); + break; case 'DOL_UNDERLINE': - $this->printer->setUnderline(true); - break; + $this->printer->setUnderline(true); + break; case 'DOL_UNDERLINE_DISABLED': - $this->printer->setUnderline(false); - break; + $this->printer->setUnderline(false); + break; case 'DOL_BEEP': - $this->printer->getPrintConnector() -> write("\x1e"); - break; + $this->printer->getPrintConnector() -> write("\x1e"); + break; case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { if ($line->special_code == $this->orderprinter) @@ -775,7 +775,7 @@ class dolReceiptPrinter extends Printer $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); } - } + } break; case 'DOL_PRINT_PAYMENT': $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; @@ -793,10 +793,10 @@ class dolReceiptPrinter extends Printer $row = $this->db->fetch_object($resql); $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12; $spaces = str_repeat(' ', $spacestoadd); - $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; + $amount_payment = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n"); - if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments + if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments { $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12; $spaces = str_repeat(' ', $spacestoadd); @@ -806,15 +806,15 @@ class dolReceiptPrinter extends Printer } } break; - default: - $this->printer->text($vals[$tplline]['tag']); - $this->printer->text($vals[$tplline]['value']); - $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; - $error++; - break; - } - } - // If is DummyPrintConnector send to log to debugging + default: + $this->printer->text($vals[$tplline]['tag']); + $this->printer->text($vals[$tplline]['value']); + $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; + $error++; + break; + } + } + // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $data = $this->printer->connector->getData(); @@ -822,103 +822,103 @@ class dolReceiptPrinter extends Printer dol_syslog($data); } // Close and print - $this->printer->close(); - } - return $error; - } + $this->printer->close(); + } + return $error; + } - /** - * Function to load Template - * - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function loadTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'SELECT template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE rowid='.$templateid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'TemplateDontExist'; - } else { - $this->template = $obj['0']; - } + /** + * Function to load Template + * + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function loadTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'SELECT template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE rowid='.$templateid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'TemplateDontExist'; + } else { + $this->template = $obj['0']; + } - return $error; - } + return $error; + } - /** - * Function Init Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function initPrinter($printerid) - { - global $conf; + /** + * Function Init Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function initPrinter($printerid) + { + global $conf; if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ $this->connector = new DummyPrintConnector(); $this->printer = new Printer($this->connector, $this->profile); return; } - $error = 0; - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid = '.$printerid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'PrinterDontExist'; - } - if (!$error) { - $parameter = $obj['parameter']; - try { - switch ($obj['fk_type']) { - case 1: - $this->connector = new DummyPrintConnector(); - break; - case 2: - $this->connector = new FilePrintConnector($parameter); - break; - case 3: - $parameters = explode(':', $parameter); - $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); - break; - case 4: - $this->connector = new WindowsPrintConnector($parameter); - break; + $error = 0; + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'PrinterDontExist'; + } + if (!$error) { + $parameter = $obj['parameter']; + try { + switch ($obj['fk_type']) { + case 1: + $this->connector = new DummyPrintConnector(); + break; + case 2: + $this->connector = new FilePrintConnector($parameter); + break; + case 3: + $parameters = explode(':', $parameter); + $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); + break; + case 4: + $this->connector = new WindowsPrintConnector($parameter); + break; case 5: - $this->connector = new CupsPrintConnector($parameter); - break; - default: - $this->connector = 'CONNECTOR_UNKNOWN'; - break; - } - $this->printer = new Printer($this->connector, $this->profile); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->connector = new CupsPrintConnector($parameter); + break; + default: + $this->connector = 'CONNECTOR_UNKNOWN'; + break; + } + $this->printer = new Printer($this->connector, $this->profile); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 2eaf5f744bd..efb2e554da9 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -114,15 +114,15 @@ class EmailSenderProfile extends CommonObject public $entity; /** - * @var string Email Sender Profile label - */ - public $label; + * @var string Email Sender Profile label + */ + public $label; public $email; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; @@ -305,9 +305,9 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; - $label = $this->label; + $label = $this->label; - $url = ''; + $url = ''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; $linkstart = ''; @@ -332,7 +332,7 @@ class EmailSenderProfile extends CommonObject return $this->LibStatut($this->active, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -356,8 +356,8 @@ class EmailSenderProfile extends CommonObject return dolGetStatus($label, $labelshort, '', $statusType, $mode); } - /** - * Charge les informations d'ordre info dans l'objet commande + /** + * Charge les informations d'ordre info dans l'objet commande * * @param int $id Id of order * @return void diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index 7e02aa57032..c30c37266c1 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -149,8 +149,8 @@ class EvalMath $expr = trim($expr); if (substr($expr, - 1, 1) == ';') $expr = substr($expr, 0, strlen($expr) - 1); // strip semicolons at the end - // =============== - // is it a variable assignment? + // =============== + // is it a variable assignment? $matches = array(); if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant @@ -160,8 +160,8 @@ class EvalMath return false; // get the result and make sure it's good $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array return $this->v[$matches[1]]; // and return the resulting value - // =============== - // is it a function assignment? + // =============== + // is it a function assignment? } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { $fnn = $matches[1]; // get the function name if (in_array($matches[1], $this->fb)) { // make sure it isn't built in @@ -235,7 +235,7 @@ class EvalMath $ops_p = array('+' => 0, '-' => 0, '*' => 1, '/' => 1, '_' => 1, '^' => 2); // operator precedence $expecting_op = false; // we use this in syntax-checking the expression - // and determining when a - is a negation + // and determining when a - is a negation $matches = array(); if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good @@ -244,7 +244,7 @@ class EvalMath while (1) { // 1 Infinite Loop ;) $op = substr($expr, $index, 1); // get the first character at the current index - // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand + // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand $match = array(); $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); // =============== @@ -253,7 +253,7 @@ class EvalMath $index++; } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack return $this->trigger(4, "illegal character '_'", "_"); // but not in the input expression - // =============== + // =============== } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? $op = '*'; @@ -372,7 +372,7 @@ class EvalMath $stack = new EvalMathStack(); foreach ($tokens as $token) { // nice and easy - // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on + // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on $matches = array(); if (in_array($token, array('+', '-', '*', '/', '^'))) { if (is_null($op2 = $stack->pop())) @@ -412,7 +412,7 @@ class EvalMath $fnn = 'log'; eval('$stack->push('.$fnn.'($op1));'); // perfectly safe eval() } elseif (array_key_exists($fnn, $this->f)) { // user function - // get args + // get args $args = array(); for ($i = count($this->f[$fnn]['args']) - 1; $i >= 0; $i--) { if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index bffd23f05d2..fc0c4533b7d 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -43,10 +43,10 @@ class Events // extends CommonObject */ public $id; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,7 +58,7 @@ class Events // extends CommonObject */ public $tms; - /** + /** * @var string Type */ public $type; @@ -94,7 +94,7 @@ class Events // extends CommonObject public $eventstolog = array( array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1), + array('id'=>'USER_LOGOUT', 'test'=>1), array('id'=>'USER_CREATE', 'test'=>1), array('id'=>'USER_MODIFY', 'test'=>1), array('id'=>'USER_NEW_PASSWORD', 'test'=>1), @@ -187,7 +187,7 @@ class Events // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // Clean parameters $this->id = (int) $this->id; @@ -222,7 +222,7 @@ class Events // extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - public function fetch($id, $user = null) + public function fetch($id, $user = null) { $sql = "SELECT"; $sql .= " t.rowid,"; @@ -271,7 +271,7 @@ class Events // extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - public function delete($user) + public function delete($user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; $sql .= " WHERE rowid=".$this->id; @@ -289,13 +289,13 @@ class Events // extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() { $this->id = 0; @@ -306,5 +306,5 @@ class Events // extends CommonObject $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); - } + } } diff --git a/htdocs/core/class/extralanguages.class.php b/htdocs/core/class/extralanguages.class.php index a57fa20f510..34c2e34dc82 100644 --- a/htdocs/core/class/extralanguages.class.php +++ b/htdocs/core/class/extralanguages.class.php @@ -28,13 +28,13 @@ class ExtraLanguages { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** - * @var array New array to store extralanguages definition - */ + * @var array New array to store extralanguages definition + */ public $attributes; /** @@ -47,7 +47,7 @@ class ExtraLanguages */ public $errors = array(); - /** + /** * @var string DB Error number */ public $errno; @@ -57,7 +57,7 @@ class ExtraLanguages * Constructor * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -67,7 +67,7 @@ class ExtraLanguages } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with * the widgetForTranslation() method. @@ -80,7 +80,7 @@ class ExtraLanguages */ public function fetch_name_extralanguages($elementtype, $forceload = false) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($elementtype)) return array(); diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index c941a3a0745..b601994536e 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -176,16 +176,16 @@ class FileUpload ) ); - $hookmanager->executeHooks( - 'overrideUploadOptions', - array( - 'options' => &$options, - 'element' => $element - ), - $object, - $action, - $hookmanager - ); + $hookmanager->executeHooks( + 'overrideUploadOptions', + array( + 'options' => &$options, + 'element' => $element + ), + $object, + $action, + $hookmanager + ); if ($options) { $this->options = array_replace_recursive($this->options, $options); @@ -504,26 +504,26 @@ class FileUpload // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { - $info[] = $this->handleFileUpload( - $upload['tmp_name'][$index], - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], - $upload['error'][$index], - $index - ); + $info[] = $this->handleFileUpload( + $upload['tmp_name'][$index], + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], + $upload['error'][$index], + $index + ); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: - $info[] = $this->handleFileUpload( - isset($upload['tmp_name']) ? $upload['tmp_name'] : null, - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), - isset($upload['error']) ? $upload['error'] : null, - 0 - ); + $info[] = $this->handleFileUpload( + isset($upload['tmp_name']) ? $upload['tmp_name'] : null, + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), + isset($upload['error']) ? $upload['error'] : null, + 0 + ); } header('Vary: Accept'); $json = json_encode($info); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index c0216f16a19..0e822076641 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -69,25 +69,25 @@ class Fiscalyear extends CommonObject public $label; /** - * Date start (date_start) - * - * @var integer - */ + * Date start (date_start) + * + * @var integer + */ public $date_start; /** - * Date end (date_end) - * - * @var integer - */ + * Date end (date_end) + * + * @var integer + */ public $date_end; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; public $statut; // 0=open, 1=closed @@ -214,11 +214,11 @@ class Fiscalyear extends CommonObject } /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ + * Load an object from database + * + * @param int $id Id of record to load + * @return int <0 if KO, >0 if OK + */ public function fetch($id) { $sql = "SELECT rowid, label, date_start, date_end, statut"; @@ -245,7 +245,7 @@ class Fiscalyear extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php index 25f3dc6af11..e27e45de954 100644 --- a/htdocs/core/class/genericobject.class.php +++ b/htdocs/core/class/genericobject.class.php @@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class GenericObject extends CommonObject { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } } diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php index 117b8e30e02..ee122ff7cb5 100644 --- a/htdocs/core/class/google.class.php +++ b/htdocs/core/class/google.class.php @@ -26,63 +26,63 @@ */ class GoogleAPI { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - public $key; + public $key; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $key Google key - */ - public function __construct($db, $key) - { - $this->db = $db; - $this->key = $key; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $key Google key + */ + public function __construct($db, $key) + { + $this->db = $db; + $this->key = $key; + } - /** - * Return geo coordinates of an address - * - * @param string $address Address - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France - * @return string Coordinates - */ - public function getGeoCoordinatesOfAddress($address) - { - global $conf; + /** + * Return geo coordinates of an address + * + * @param string $address Address + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France + * @return string Coordinates + */ + public function getGeoCoordinatesOfAddress($address) + { + global $conf; - $i = 0; + $i = 0; - // Desired address - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; + // Desired address + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; - // Retrieve the URL contents - $page = file_get_contents($urladdress); + // Retrieve the URL contents + $page = file_get_contents($urladdress); - $code = strstr($page, ''); - $code = strstr($code, '>'); - $val = strpos($code, "<"); - $code = substr($code, 1, $val - 1); - //print $code; - //print "
"; - $latitude = substr($code, 0, strpos($code, ",")); - $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); + $code = strstr($page, ''); + $code = strstr($code, '>'); + $val = strpos($code, "<"); + $code = substr($code, 1, $val - 1); + //print $code; + //print "
"; + $latitude = substr($code, 0, strpos($code, ",")); + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); - // Output the coordinates - //echo "Longitude: $longitude ',' Latitude: $latitude"; + // Output the coordinates + //echo "Longitude: $longitude ',' Latitude: $latitude"; - $i++; - } + $i++; + } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index dca7c123399..89b5a79df4b 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. + if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4a3561149ec..3bdbea18702 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1187,12 +1187,12 @@ class Form // We search companies $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays"; } if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1283,7 +1283,7 @@ class Form if ($obj->client || $obj->fournisseur) $label .= ')'; } - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $label .= ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : ''); if (!empty($obj->country_code)) { $label .= ', '.$langs->trans('Country'.$obj->country_code); @@ -3566,106 +3566,106 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load in cache list of transport mode - * - * @return int Nb of lines loaded, <0 if KO - */ - public function load_cache_transport_mode() - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache list of transport mode + * + * @return int Nb of lines loaded, <0 if KO + */ + public function load_cache_transport_mode() + { + // phpcs:enable + global $langs; - $num=count($this->cache_transport_mode); - if ($num > 0) return $num; // Cache already loaded + $num=count($this->cache_transport_mode); + if ($num > 0) return $num; // Cache already loaded - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $this->cache_transport_mode = array(); + $this->cache_transport_mode = array(); - $sql = "SELECT rowid, code, label, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; - $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; - //if ($active >= 0) $sql.= " AND active = ".$active; + $sql = "SELECT rowid, code, label, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; + $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; + //if ($active >= 0) $sql.= " AND active = ".$active; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - // If traduction exist, we use it else we take the default label - $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); - $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; - $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; - $this->cache_transport_mode[$obj->rowid]['label']= $label; - $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; - $i++; - } + // If traduction exist, we use it else we take the default label + $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); + $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; + $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; + $this->cache_transport_mode[$obj->rowid]['label']= $label; + $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; + $i++; + } - $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); + $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); - return $num; - } - else { - dol_print_error($this->db); - return -1; - } - } + return $num; + } + else { + dol_print_error($this->db); + return -1; + } + } - /** - * Return list of transport mode for intracomm report - * - * @param string $selected Id of the transport mode pre-selected - * @param string $htmlname Name of the select field - * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code - * @param int $empty 1=can be empty, 0 else - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $maxlength Max length of label - * @param int $active Active or not, -1 = all - * @param string $morecss Add more CSS on select tag - * @return void - */ - public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') - { - global $langs,$user; + /** + * Return list of transport mode for intracomm report + * + * @param string $selected Id of the transport mode pre-selected + * @param string $htmlname Name of the select field + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 else + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param int $active Active or not, -1 = all + * @param string $morecss Add more CSS on select tag + * @return void + */ + public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + { + global $langs,$user; - dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); - $this->load_cache_transport_mode(); + $this->load_cache_transport_mode(); - print ''; + if ($empty) print ''; + foreach ($this->cache_transport_mode as $id => $arraytypes) + { + // If not good status + if ($active >= 0 && $arraytypes['active'] != $active) continue; - // We discard empty line if showempty is on because an empty line has already been output. - if ($empty && empty($arraytypes['code'])) continue; + // We discard empty line if showempty is on because an empty line has already been output. + if ($empty && empty($arraytypes['code'])) continue; - if ($format == 0) print ''; - } - print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } + if ($format == 0) print ''; + } + print ''; + if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } /** * Return a HTML select list of shipping mode @@ -4704,40 +4704,40 @@ class Form } } - /** - * Show form with transport mode - * - * @param string $page Page - * @param int $selected Id mode pre-select - * @param string $htmlname Name of select html field - * @param int $active Active or not, -1 = all - * @param int $addempty 1=Add empty entry - * @return void - */ - public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) - { - global $langs; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); - print ''; - print '
'; - } - else { - if ($selected) - { - $this->load_cache_transport_mode(); - print $this->cache_transport_mode[$selected]['label']; - } else { - print " "; - } - } - } + /** + * Show form with transport mode + * + * @param string $page Page + * @param int $selected Id mode pre-select + * @param string $htmlname Name of select html field + * @param int $active Active or not, -1 = all + * @param int $addempty 1=Add empty entry + * @return void + */ + public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); + print ''; + print '
'; + } + else { + if ($selected) + { + $this->load_cache_transport_mode(); + print $this->cache_transport_mode[$selected]['label']; + } else { + print " "; + } + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency code * @@ -5650,7 +5650,7 @@ class Form if ($d && $h) { $retstring .= ($h == 2 ? '
' : ' '); - $retstring.=''; + $retstring .= ''; } if ($h) @@ -6622,7 +6622,7 @@ class Form templateSelection: formatSelection /* For 4.0 */ }); });'."\n"; - } elseif ($addjscombo == 2 && ! defined('DISABLE_MULTISELECT')) + } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) { // Add other js lib // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index f48e9b8eb74..d6f7b269da1 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -36,26 +36,26 @@ class FormAccounting extends Form private $options_cache = array(); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) */ public $error = ''; - /** + /** * Constructor * * @param DoliDB $db Database handler */ public function __construct($db) { - $this->db = $db; + $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of journals with label by nature * @@ -72,16 +72,16 @@ class FormAccounting extends Form */ public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $out = ''; - $options = array(); + $options = array(); if ($usecache && !empty($this->options_cache[$usecache])) { - $options = $this->options_cache[$usecache]; - $selected = $selectid; + $options = $this->options_cache[$usecache]; + $selected = $selectid; } else { $sql = "SELECT rowid, code, label, nature, entity, active"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; @@ -99,27 +99,27 @@ class FormAccounting extends Form return -1; } - $selected = 0; + $selected = 0; $langs->load('accountancy'); while ($obj = $this->db->fetch_object($resql)) { $label = $obj->code.' - '.$langs->trans($obj->label); - $select_value_in = $obj->rowid; + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; // Try to guess if we have found default value - if ($select_in == 1) { - $select_value_in = $obj->code; - } - if ($select_out == 1) { - $select_value_out = $obj->code; - } - // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid - if ($selectid != '' && $selectid == $select_value_in) { - //var_dump("Found ".$selectid." ".$select_value_in); - $selected = $select_value_out; - } + if ($select_in == 1) { + $select_value_in = $obj->code; + } + if ($select_out == 1) { + $select_value_out = $obj->code; + } + // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } $options[$select_value_out] = $label; } @@ -136,83 +136,83 @@ class FormAccounting extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return list of accounting category. - * Use mysoc->country_id or mysoc->country_code so they must be defined. - * - * @param string $selected Preselected type - * @param string $htmlname Name of field in form - * @param int $useempty Set to 1 if we want an empty value - * @param int $maxlen Max length of text in combo box - * @param int $help Add or not the admin help picto - * @param int $allcountries All countries - * @return void - */ - public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) - { - // phpcs:enable - global $db, $langs, $user, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of accounting category. + * Use mysoc->country_id or mysoc->country_code so they must be defined. + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $useempty Set to 1 if we want an empty value + * @param int $maxlen Max length of text in combo box + * @param int $help Add or not the admin help picto + * @param int $allcountries All countries + * @return void + */ + public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) + { + // phpcs:enable + global $db, $langs, $user, $mysoc; - if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) - { - dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); - exit; - } + if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) + { + dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); + exit; + } - if (!empty($mysoc->country_id)) - { - $sql = "SELECT c.rowid, c.label as type, c.range_account"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; + if (!empty($mysoc->country_id)) + { + $sql = "SELECT c.rowid, c.label as type, c.range_account"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; $sql .= " AND c.category_type = 0"; - if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id; - $sql .= " ORDER BY c.label ASC"; - } else { - $sql = "SELECT c.rowid, c.label as type, c.range_account"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; - $sql .= " WHERE c.active = 1"; + if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id; + $sql .= " ORDER BY c.label ASC"; + } else { + $sql = "SELECT c.rowid, c.label as type, c.range_account"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; + $sql .= " WHERE c.active = 1"; $sql .= " AND c.category_type = 0"; $sql .= " AND c.fk_country = co.rowid"; - if (empty($allcountries)) $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'"; - $sql .= " ORDER BY c.label ASC"; - } + if (empty($allcountries)) $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'"; + $sql .= " ORDER BY c.label ASC"; + } - dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - $out = ''; + $i = 0; - if ($useempty) $out .= ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $out .= ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= ''; - } else { - $menuarray[$prefix.'_'.$file] = ''; - } - } - } - closedir($handle); - } - } - } - } + if ($file == $selected) + { + $menuarray[$prefix.'_'.$file] = ''; + } else { + $menuarray[$prefix.'_'.$file] = ''; + } + } + } + closedir($handle); + } + } + } + } ksort($menuarray); // Output combo list of menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); @@ -208,7 +208,7 @@ class FormAdmin // Affiche titre print ''; @@ -217,69 +217,69 @@ class FormAdmin print $val."\n"; // Show menu entry } print ''; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return combo list of available menu families - * - * @param string $selected Menu pre-selected - * @param string $htmlname Name of html select - * @param string[] $dirmenuarray Directories to scan - * @return void - */ - public function select_menu_families($selected, $htmlname, $dirmenuarray) - { - // phpcs:enable - global $langs, $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return combo list of available menu families + * + * @param string $selected Menu pre-selected + * @param string $htmlname Name of html select + * @param string[] $dirmenuarray Directories to scan + * @return void + */ + public function select_menu_families($selected, $htmlname, $dirmenuarray) + { + // phpcs:enable + global $langs, $conf; - //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set - $expdevmenu = array(); + //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set + $expdevmenu = array(); $menuarray = array(); foreach ($dirmenuarray as $dirmenu) { - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot.$dirmenu; - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); - if (preg_match('/^index/i', $filelib)) continue; - if (preg_match('/^default/i', $filelib)) continue; - if (preg_match('/^empty/i', $filelib)) continue; - if (preg_match('/\.lib/i', $filelib)) continue; - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot.$dirmenu; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); + if (preg_match('/^index/i', $filelib)) continue; + if (preg_match('/^default/i', $filelib)) continue; + if (preg_match('/^empty/i', $filelib)) continue; + if (preg_match('/\.lib/i', $filelib)) continue; + if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; - $menuarray[$filelib] = 1; - } - $menuarray['all'] = 1; - } - closedir($handle); - } - } - } + $menuarray[$filelib] = 1; + } + $menuarray['all'] = 1; + } + closedir($handle); + } + } + } } ksort($menuarray); // Affichage liste deroulante des menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); $newprefix = $tab[0]; print ''; - $arraytz = array( + $arraytz = array( "Pacific/Midway"=>"GMT-11:00", "Pacific/Fakaofo"=>"GMT-10:00", "America/Anchorage"=>"GMT-09:00", @@ -335,17 +335,17 @@ class FormAdmin "Pacific/Auckland"=>"GMT+12:00", "Pacific/Enderbury"=>"GMT+13:00" ); - foreach ($arraytz as $lib => $gmt) { - print ''."\n"; - } - print ''; - } + foreach ($arraytz as $lib => $gmt) { + print ''."\n"; + } + print ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return html select list with available languages (key='en_US', value='United States' for example) * @@ -365,23 +365,23 @@ class FormAdmin $sql = "SELECT code, label, width, height, unit"; $sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format"; $sql .= " WHERE active=1"; - if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; + if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $unitKey = $langs->trans('SizeUnit'.$obj->unit); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $unitKey = $langs->trans('SizeUnit'.$obj->unit); - $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); + $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); - $i++; - } - } else { + $i++; + } + } else { dol_print_error($this->db); return ''; } @@ -396,7 +396,7 @@ class FormAdmin } foreach ($paperformat as $key => $value) { - if ($selected == $key) + if ($selected == $key) { $out .= ''; } else { diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index a359bd194f7..9d50a0bb60b 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -31,40 +31,40 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class FormBank { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste des types de comptes financiers - * - * @param integer $selected Type pre-selectionne - * @param string $htmlname Nom champ formulaire - * @return void - */ - public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') - { - $account = new Account($this->db); + /** + * Retourne la liste des types de comptes financiers + * + * @param integer $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @return void + */ + public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') + { + $account = new Account($this->db); - print Form::selectarray($htmlname, $account->type_lib, $selected); - } + print Form::selectarray($htmlname, $account->type_lib, $selected); + } /** * Returns the name of the Iban label. India uses 'IFSC' and the rest of the world 'IBAN' name. diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 104daf6de0e..52d4c795c85 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -29,198 +29,198 @@ */ class FormBarCode { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Return HTML select with list of bar code generators - * - * @param int $selected Id code pre-selected - * @param array $barcodelist Array of barcodes generators - * @param int $code_id Id du code barre - * @param int $idForm Id du formulaire - * @return string HTML select string - */ - public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') - { - global $conf, $langs; + /** + * Return HTML select with list of bar code generators + * + * @param int $selected Id code pre-selected + * @param array $barcodelist Array of barcodes generators + * @param int $code_id Id du code barre + * @param int $idForm Id du formulaire + * @return string HTML select string + */ + public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') + { + global $conf, $langs; - $disable = ''; + $disable = ''; - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - //onChange="barcode_coder_save(\''.$idForm.'\') - } + print ''."\n"; + //onChange="barcode_coder_save(\''.$idForm.'\') + } - // We check if barcode is already selected by default - if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || - (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) - { - $disable = 'disabled'; - } + // We check if barcode is already selected by default + if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || + (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) + { + $disable = 'disabled'; + } - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder = '
'; - $select_encoder .= ''; - $select_encoder .= ''; - $select_encoder .= ''; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder = ''; + $select_encoder .= ''; + $select_encoder .= ''; + $select_encoder .= ''; + } - $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); - $select_encoder .= ''; + $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); + $select_encoder .= ''; - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder .= '
'; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder .= ''; + } - return $select_encoder; - } + return $select_encoder; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Print form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Affiche valeur vide dans liste - * @return void - * @deprecated - */ - public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - // phpcs:enable - print $this->selectBarcodeType($selected, $htmlname, $useempty); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Print form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Affiche valeur vide dans liste + * @return void + * @deprecated + */ + public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + // phpcs:enable + print $this->selectBarcodeType($selected, $htmlname, $useempty); + } - /** - * Return html form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Display empty value in select - * @return string - */ - public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - global $langs, $conf; + /** + * Return html form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Display empty value in select + * @return string + */ + public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + global $langs, $conf; - $out = ''; + $out = ''; - $sql = "SELECT rowid, code, libelle"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE coder <> '0'"; - $sql .= " AND entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, code, libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE coder <> '0'"; + $sql .= " AND entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; - if ($useempty && $num > 0) { - $out .= ''; - $out .= ''; - } + if ($useempty && $num > 0) { + $out .= ''; + $out .= ''; + } - while ($i < $num) { - $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) { - $out .= ''; - $i++; - } - $out .= ""; - $out .= ajax_combobox("select_".$htmlname); - } else { - dol_print_error($this->db); - } - return $out; - } + while ($i < $num) { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid) { + $out .= ''; + $i++; + } + $out .= ""; + $out .= ajax_combobox("select_".$htmlname); + } else { + dol_print_error($this->db); + } + return $out; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return void - * @deprecated - */ - public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') - { - // phpcs:enable - print $this->formBarcodeType($page, $selected, $htmlname); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return void + * @deprecated + */ + public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') + { + // phpcs:enable + print $this->formBarcodeType($page, $selected, $htmlname); + } - /** - * Return html form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return string - */ - public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') - { - global $langs, $conf; - $out = ''; - if ($htmlname != "none") { - $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= '
'; - $out .= $this->selectBarcodeType($selected, $htmlname, 1); - $out .= ''; - $out .= '
'; - } - return $out; - } + /** + * Return html form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return string + */ + public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') + { + global $langs, $conf; + $out = ''; + if ($htmlname != "none") { + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= $this->selectBarcodeType($selected, $htmlname, 1); + $out .= ''; + $out .= '
'; + } + return $out; + } } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f6e412e0958..ee9e8564933 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -186,13 +186,13 @@ class FormCompany extends Form { global $user, $langs; - print '
'; + print ''; print ''; - print ''; + print ''; dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectcontactlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -220,8 +220,8 @@ class FormCompany extends Form print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); - if (!empty($htmlname) && $user->admin) print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; print '
'; } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index b2e32b8c063..7c91c1a4148 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -27,29 +27,29 @@ */ class FormContract { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -61,9 +61,9 @@ class FormContract * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - // phpcs:enable + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + // phpcs:enable global $db, $user, $conf, $langs; $hideunselectables = false; @@ -78,12 +78,12 @@ class FormContract if ($socid > 0) { // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. - if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { - $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { + $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; } elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { - $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; $sql .= " OR c.fk_soc IS NULL)"; - } + } } if ($socid == 0) $sql .= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; $sql .= " ORDER BY c.ref "; @@ -164,30 +164,30 @@ class FormContract dol_print_error($this->db); return -1; } - } + } - /** - * Show a form to select a contract - * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) - * @param int $selected Id contract preselected - * @param string $htmlname Nom de la zone html - * @param int $maxlength Maximum length of label - * @param int $showempty Show empty line - * @param int $showRef Show customer and supplier reference on each contract (when found) - * @return int Nbr of project if OK, <0 if KO - */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - global $langs; + /** + * Show a form to select a contract + * + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) + * @return int Nbr of project if OK, <0 if KO + */ + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + global $langs; - print "\n"; - print '
'; - print ''; - print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); - print ''; - print '
'; - } + print "\n"; + print '
'; + print ''; + print ''; + $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); + print ''; + print '
'; + } } diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 2701d126331..b6a9140cf58 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -28,75 +28,75 @@ */ class FormCron extends Form { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display On Off selector - * - * @param string $htmlname Html control name - * @param integer $selected selected value - * @param integer $readonly Select is read only or not - * @return string HTML select field - */ - public function select_typejob($htmlname, $selected = 0, $readonly = 0) - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param integer $selected selected value + * @param integer $readonly Select is read only or not + * @return string HTML select field + */ + public function select_typejob($htmlname, $selected = 0, $readonly = 0) + { + // phpcs:enable + global $langs; - $langs->load('cron@cron'); - $out = ''; - if (!empty($readonly)) { - if ($selected == 'command') { - $out = $langs->trans('CronType_command'); - $out .= ''; - } elseif ($selected == 'method') { - $out = $langs->trans('CronType_method'); - $out .= ''; - } - } else { - $out = ''; + $out .= ''; + $out .= ''; + } elseif ($selected == 'method') { + $out = $langs->trans('CronType_method'); + $out .= ''; + } + } else { + $out = ''; - } + $out .= ''; + } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index 516c6e4b59c..d65f68423b2 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -27,111 +27,111 @@ */ class FormExpenseReport { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste deroulante des differents etats d'une note de frais. - * Les valeurs de la liste sont les id de la table c_expensereport_statuts - * - * @param int $selected preselect status - * @param string $htmlname Name of HTML select - * @param int $useempty 1=Add empty line - * @param int $useshortlabel Use short labels - * @return string HTML select with status - */ - public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) - { - global $langs; + /** + * Retourne la liste deroulante des differents etats d'une note de frais. + * Les valeurs de la liste sont les id de la table c_expensereport_statuts + * + * @param int $selected preselect status + * @param string $htmlname Name of HTML select + * @param int $useempty 1=Add empty line + * @param int $useshortlabel Use short labels + * @return string HTML select with status + */ + public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) + { + global $langs; - $tmpep = new ExpenseReport($this->db); + $tmpep = new ExpenseReport($this->db); - print ''; - print ajax_combobox($htmlname); - } + print ''; + print ajax_combobox($htmlname); + } - /** - * Return list of types of notes with select value = id - * - * @param int $selected Preselected type - * @param string $htmlname Name of field in form - * @param int $showempty Add an empty field - * @param int $active 1=Active only, 0=Unactive only, -1=All - * @return string Select html - */ - public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) - { - // phpcs:enable - global $langs, $user; - $langs->load("trips"); + /** + * Return list of types of notes with select value = id + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @param int $active 1=Active only, 0=Unactive only, -1=All + * @return string Select html + */ + public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) + { + // phpcs:enable + global $langs, $user; + $langs->load("trips"); - $out = ''; + $out = ''; - $out .= ''; - $out .= ajax_combobox($htmlname); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= '