diff --git a/.gitignore b/.gitignore index e9603bd2d8f..3315a7eed88 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ yarn.lock package-lock.json doc/install.lock +/.asciidoctorconfig.adoc diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 897f60e8aaa..7e2cdc56543 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2088,7 +2088,7 @@ class BookKeeping extends CommonObject * FIXME: This function takes the parent of parent to get the root account ! * * @param string $account Accounting account - * @return array Array with root account information (max 2 upper level) + * @return array|int Array with root account information (max 2 upper level), <0 if KO */ public function getRootAccount($account = null) { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 5749518e2b9..272c067807d 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -329,6 +329,7 @@ class Lettering extends BookKeeping // Update request $now = dol_now(); + $affected_rows = 0; if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; @@ -341,6 +342,8 @@ class Lettering extends BookKeeping if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } else { + $affected_rows = $this->db->affected_rows($resql); } } @@ -352,7 +355,7 @@ class Lettering extends BookKeeping } return -1 * $error; } else { - return 1; + return $affected_rows; } } @@ -387,7 +390,7 @@ class Lettering extends BookKeeping } return -1 * $error; } else { - return 1; + return $this->db->affected_rows($resql); } } @@ -482,7 +485,7 @@ class Lettering extends BookKeeping else $result = $this->updateLettering($bookkeeping_lines); if ($result < 0) { $group_error++; - } else { + } elseif ($result > 0) { $nb_lettering++; } } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 544f077f1ea..0137e63406f 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -805,6 +805,12 @@ if (!$error && $action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index d00a968571f..12303089dca 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -381,6 +381,12 @@ if ($action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 9eb6688c63b..565a3a59222 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -463,7 +463,15 @@ if ($action == 'writebookkeeping') { if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + $errorforinvoice[$key] = 'other'; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 89a1ed2904d..74df98e873a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -3303,11 +3303,11 @@ class Adherent extends CommonObject */ public function getKanbanView($option = '', $arraydata = null) { + global $selected; $return = '
'; $return .= '
'; $return .= ''; - if (property_exists($this, 'photo') || !empty($this->photo)) { $return.= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); } else { @@ -3316,6 +3316,7 @@ class Adherent extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'type')) { $return .= '
'.$this->type.''; } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 396dea45b0e..141a2264113 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -991,7 +991,10 @@ class AdherentType extends CommonObject */ public function getKanbanView($option = '', $arraydata = null) { - global $langs,$user; + global $langs, $user; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -999,6 +1002,7 @@ class AdherentType extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if ($user->rights->adherent->configurer) { $return .= 'ref.'">'.img_edit().''; } else { diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index c8994283fe1..5f8dbf07249 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -515,6 +515,8 @@ class Subscription extends CommonObject */ public function getKanbanView($option = '', $arraydata = null) { + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -523,6 +525,7 @@ class Subscription extends CommonObject $return .= '
'; $return .= ''.(property_exists($this, 'fk_adherent')? $this->fk_adherent: $this->ref ).''; + $return .= ''; if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index bbb97e293fe..99bbb6d9cb1 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -38,9 +38,11 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "orders")); +$action = GETPOST('action', 'aZ09'); + $type = GETPOST('type', 'alpha'); $value = GETPOST('value', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -98,7 +100,9 @@ if ($action == 'specimen') { // For invoices $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) // Search template files - $file = ''; $classname = ''; $filefound = 0; + $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); @@ -185,12 +189,12 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') { * View */ +$form = new Form($db); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", ""); -$form = new Form($db); - $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); @@ -205,6 +209,7 @@ print dol_get_fiche_head($head, 'invoice', $langs->trans("Suppliers"), -1, 'comp print load_fiche_titre($langs->trans("SuppliersInvoiceNumberingModel"), '', ''); +print '
'; print ''; print ''; print ''; @@ -244,7 +249,7 @@ foreach ($dirmodels as $reldir) { print $module->info(); print ''; - // Show example of numbering model + // Show example of numbering module print '
'.$langs->trans("Name").''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { @@ -297,13 +302,13 @@ foreach ($dirmodels as $reldir) { } } -print '

'; +print '

'; /* - * Modeles documents for supplier invoices + * Documents models for supplier invoices */ print load_fiche_titre($langs->trans("BillsPDFModules"), '', ''); @@ -329,6 +334,7 @@ if ($resql) { dol_print_error($db); } +print '
'; print ''."\n"; print ''."\n"; print ''."\n"; @@ -380,7 +386,7 @@ foreach ($dirmodels as $reldir) { //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 'scandir).'&label='.urlencode($module->name).'&type=invoice_supplier">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; /*} @@ -391,7 +397,7 @@ foreach ($dirmodels as $reldir) { print ""; } else { print '"; } @@ -400,9 +406,9 @@ foreach ($dirmodels as $reldir) { if (getDolGlobalString("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').''; + 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 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; @@ -420,7 +426,7 @@ foreach ($dirmodels as $reldir) { print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; print "\n"; @@ -432,7 +438,7 @@ foreach ($dirmodels as $reldir) { } } -print '
'.$langs->trans("Name").''."\n"; - print 'scandir).'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '

'; +print '

'; /* * Other options @@ -443,6 +449,8 @@ print ''; print ''; print load_fiche_titre($langs->trans("OtherOptions"), '', ''); + +print '
'; print ''; print ''; print ''; @@ -472,7 +480,7 @@ print '\n"; -print '
'.$langs->trans("Parameter").''; print ''; print "

'; +print '

'; print ''; @@ -482,6 +490,8 @@ print ''; */ print load_fiche_titre($langs->trans("Notifications"), '', ''); + +print '
'; print ''; print ''; print ''; @@ -495,6 +505,7 @@ print '\n"; print '
'.$langs->trans("Parameter").''; print "
'; +print '
'; // End of page llxFooter(); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index abee8200cef..171ad4035a9 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -38,25 +38,28 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "orders", "stocks")); -if (!$user->admin) { - accessforbidden(); -} +$action = GETPOST('action', 'aZ09'); $type = GETPOST('type', 'alpha'); $value = GETPOST('value', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $label = GETPOST('label', 'alpha'); -$action = GETPOST('action', 'aZ09'); $scandir = GETPOST('scan_dir', 'alpha'); $specimenthirdparty = new Societe($db); $specimenthirdparty->initAsSpecimen(); +$error = 0; + +if (!$user->admin) { + accessforbidden(); +} + /* -* Actions -*/ + * Actions + */ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; @@ -77,7 +80,9 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') { // For orders +} + +if ($action == 'specimen') { // For orders $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); @@ -317,8 +322,8 @@ print '

'; /* -* Documents models for supplier orders -*/ + * Documents models for supplier orders + */ print load_fiche_titre($langs->trans("OrdersModelModule"), '', ''); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 361ac64928e..c00b9781756 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1567,6 +1567,9 @@ class BOM extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $db,$langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $prod = new Product($db); $prod->fetch($this->fk_product); @@ -1577,6 +1580,7 @@ class BOM extends CommonObject $return .= '
'; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : '').''; + $return .= ''; if (property_exists($this, 'fields') && !empty($this->fields['bomtype']['arrayofkeyval'])) { $return .= '
'.$langs->trans("Type").' : '; if ($this->bomtype == 0) { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index b378ff2b033..ba3839afa5f 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -73,17 +73,19 @@ $result = $object->fetch($id); $hookmanager->initHooks(array('ciblescard', 'globalcard')); // Security check -if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) { +if (!$user->hasRight('mailing', 'lire') || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) { accessforbidden(); } //$result = restrictedArea($user, 'mailing'); +$sqlmessage = ''; + /* * Actions */ -if ($action == 'add') { +if ($action == 'add' && $user->hasRight('mailing', 'creer')) { // Add recipients $module = GETPOST("module", 'alpha'); $result = -1; @@ -103,6 +105,8 @@ if ($action == 'add') { $obj = new $classname($db); dol_syslog("Call add_to_target on class ".$classname); $result = $obj->add_to_target($id); + + $sqlmessage = $obj->sql; } } if ($result > 0) { @@ -117,7 +121,7 @@ if ($action == 'add') { } } -if (GETPOST('clearlist', 'int')) { +if (GETPOST('clearlist', 'int') && $user->hasRight('mailing', 'creer')) { // Loading Class $obj = new MailingTargets($db); $obj->clear_target($id); @@ -127,7 +131,7 @@ if (GETPOST('clearlist', 'int')) { */ } -if (GETPOST('exportcsv', 'int')) { +if (GETPOST('exportcsv', 'int') && $user->hasRight('mailing', 'lire')) { $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv'; header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename='.$completefilename); @@ -166,7 +170,7 @@ if (GETPOST('exportcsv', 'int')) { exit; } -if ($action == 'delete') { +if ($action == 'delete' && $user->hasRight('mailing', 'creer')) { // Ici, rowid indique le destinataire et id le mailing $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid); $resql = $db->query($sql); @@ -454,7 +458,14 @@ if ($object->fetch($id) >= 0) { print '
'; // End table print '
'; - print '

'; + print '
'; + + if ($sqlmessage && $user->admin) { + print info_admin($langs->trans("SQLUsedForExport").':
'.$sqlmessage, 0, 0, 1, '', 'TechnicalInformation'); + print '
'; + } + + print '
'; } // List of selected targets diff --git a/htdocs/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php new file mode 100644 index 00000000000..f3b35d07cfe --- /dev/null +++ b/htdocs/comm/propal/agenda.php @@ -0,0 +1,256 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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/comm/propal/agenda.php + * \ingroup propal + * \brief Tab of events on Proposal + */ +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("propal", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) { + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) { + $actioncode = '0'; + } +} else { + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); +} +$search_rowid = GETPOST('search_rowid'); +$search_agenda_label = GETPOST('search_agenda_label'); + +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} + +// Initialize technical objects +$object = new Propal($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectagenda', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->propal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; +} + +$permissiontoread = $user->hasRight("propal", "lire"); +$permissiontoadd = $user->hasRight("propal", "creer"); + +// Security check +if (!empty($user->socid)) { + $socid = $user->socid; +} +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +restrictedArea($user, 'propal', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + */ + +$parameters = array('id'=>$id); +$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)) { + // 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 tests are required to be compatible with all browsers + $actioncode = ''; + $search_agenda_label = ''; + } +} + + + +/* + * View + */ + +$form = new Form($db); + +if ($object->id > 0) { + $title = $langs->trans("Agenda"); + //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; + llxHeader('', $title, $help_url); + + if (isModEnabled('notification')) { + $langs->load("mails"); + } + $head = propal_prepare_head($object); + + + print dol_get_fiche_head($head, 'agenda', $langs->trans("Proposal"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; + } + } + } + } + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $object->info($object->id); + dol_print_object_info($object, 1); + + print '
'; + + print dol_get_fiche_end(); + + + + // Actions buttons + + $objthirdparty = $object; + $objcon = new stdClass(); + + $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; + $out .= '&backtopage='.urlencode($urlbacktopage); + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + $morehtmlright = ''; + + //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; + //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; + //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + + if (isModEnabled('agenda')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } else { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0); + } + } + + + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + print '
'; + + $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_propal_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + print_barre_liste($langs->trans("ActionsOnPropal").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + //print_barre_liste($langs->trans("ActionsOnPropal"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : ''); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f504cf84cd9..5833072e8be 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -3038,10 +3038,14 @@ if ($action == 'create') { print '
'; + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/comm/propal/agenda.php?id='.$object->id); + // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'propal', $socid, 1); + $somethingshown = $formactions->showactions($object, 'propal', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty print '
'; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b52e39a0088..75990668e5d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3964,6 +3964,9 @@ class Propal extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -3972,6 +3975,7 @@ class Propal extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'fk_project')) { $return .= ' | '.$this->fk_project.''; } diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 480aebe1def..028c6aacc18 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -246,7 +246,9 @@ class PropaleStats extends Stats 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." INNER JOIN ".$this->from_line." ON p.rowid = tl.fk_propal INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; + $sql .= " FROM ".$this->from; + $sql .= " INNER JOIN ".$this->from_line." ON p.rowid = tl.fk_propal"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php deleted file mode 100644 index 8a1d2afaabd..00000000000 --- a/htdocs/comm/propal/info.php +++ /dev/null @@ -1,126 +0,0 @@ - - * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2017 Ferran Marcet - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/comm/propal/info.php - * \ingroup propal - * \brief Page d'affichage des infos d'une proposition commerciale - */ - -// Load Dolibarr environment -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -} - -// Load translation files required by the page -$langs->loadLangs(array('propal', 'compta')); - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$socid = GETPOST('socid', 'int'); - -$object = new Propal($db); -if (!$object->fetch($id, $ref) > 0) { - dol_print_error($db); - exit; -} - -// Security check -if (!empty($user->socid)) { - $socid = $user->socid; - $object->id = $user->socid; -} -restrictedArea($user, 'propal', $object->id); - -$usercancreate = $user->hasRight("propal", "creer"); - - -/* - * View - */ - -$form = new Form($db); - -$title = $object->ref." - ".$langs->trans('Info'); -$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; -llxHeader('', $title, $help_url); - -$object->fetch_thirdparty(); - -$head = propal_prepare_head($object); -print dol_get_fiche_head($head, 'info', $langs->trans('Proposal'), -1, 'propal'); - -$object->info($object->id); - - -// Proposal card - -$linkback = ''.$langs->trans("BackToList").''; - - -$morehtmlref = '
'; -// Ref customer -$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); -$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); -// Thirdparty -$morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); -// Project -if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } -} -$morehtmlref .= '
'; - -dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - -print '
'; -print '
'; - -print '
'; - -dol_print_object_info($object); - -print '
'; - -print dol_get_fiche_end(); - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index ad029628739..9138a757989 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -712,6 +712,7 @@ class Orders extends DolibarrApi * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error + * */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 86fcfbea1ad..6348d8e1325 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2727,7 +2727,7 @@ class Commande extends CommonOrder * @param int $offset For pagination * @param string $sortfield Sort criteria * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK + * @return int|array -1 if KO, array with result if OK */ public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 3ba717f7a51..73cb5d3bf02 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -527,6 +527,14 @@ if ($action == 'create') { print ''; print ''; + // IBAN + print ''.$langs->trans($ibankey).''; + print ''; + + // BIC + print ''.$langs->trans($bickey).''; + print ''; + // Show fields of bank account $sizecss = ''; foreach ($object->getFieldsToShow() as $val) { @@ -559,13 +567,6 @@ if ($action == 'create') { $bickey = "SWIFT"; } - // IBAN - print ''.$langs->trans($ibankey).''; - print ''; - - print ''.$langs->trans($bickey).''; - print ''; - if (isModEnabled('paymentbybanktransfer')) { print ''.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).''; print ''; @@ -753,6 +754,38 @@ if ($action == 'create') { print ''.$langs->trans("BankName").''; print ''.$object->bank.''; + $ibankey = FormBank::getIBANLabel($object); + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') { + $bickey = "SWIFT"; + } + + // IBAN + print ''.$langs->trans($ibankey).''; + print ''.getIbanHumanReadable($object).' '; + if (!empty($object->iban)) { + if (!checkIbanForAccount($object)) { + print img_picto($langs->trans("IbanNotValid"), 'warning'); + } else { + print img_picto($langs->trans("IbanValid"), 'info'); + } + } + print ''; + + // BIC + print ''.$langs->trans($bickey).''; + print ''.$object->bic.' '; + if (!empty($object->bic)) { + if (!checkSwiftForAccount($object)) { + print img_picto($langs->trans("SwiftNotValid"), 'warning'); + } else { + print img_picto($langs->trans("SwiftValid"), 'info'); + } + } + print ''; + + // TODO Add a link "Show more..." for all ohter informations. + // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { $content = ''; @@ -771,34 +804,6 @@ if ($action == 'create') { print ''; } - $ibankey = FormBank::getIBANLabel($object); - $bickey = "BICNumber"; - if ($object->getCountryCode() == 'IN') { - $bickey = "SWIFT"; - } - - print ''.$langs->trans($ibankey).''; - print ''.getIbanHumanReadable($object).' '; - if (!empty($object->iban)) { - if (!checkIbanForAccount($object)) { - print img_picto($langs->trans("IbanNotValid"), 'warning'); - } else { - print img_picto($langs->trans("IbanValid"), 'info'); - } - } - print ''; - - print ''.$langs->trans($bickey).''; - print ''.$object->bic.' '; - if (!empty($object->bic)) { - if (!checkSwiftForAccount($object)) { - print img_picto($langs->trans("SwiftNotValid"), 'warning'); - } else { - print img_picto($langs->trans("SwiftValid"), 'info'); - } - } - print ''; - if (isModEnabled('prelevement')) { print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''; print ''.$object->ics.''; @@ -1080,6 +1085,20 @@ if ($action == 'create') { print ''; print ''; + $ibankey = FormBank::getIBANLabel($object); + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') { + $bickey = "SWIFT"; + } + + // IBAN + print ''.$langs->trans($ibankey).''; + print ''; + + // BIC + print ''.$langs->trans($bickey).''; + print ''; + // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { $content = ''; @@ -1106,19 +1125,6 @@ if ($action == 'create') { print ''; } - $ibankey = FormBank::getIBANLabel($object); - $bickey = "BICNumber"; - if ($object->getCountryCode() == 'IN') { - $bickey = "SWIFT"; - } - - // IBAN - print ''.$langs->trans($ibankey).''; - print ''; - - print ''.$langs->trans($bickey).''; - print ''; - if (isModEnabled('prelevement')) { print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 3ee2ad037b5..b20acb71da2 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -30,6 +30,7 @@ * \ingroup bank * \brief File of class to manage bank accounts */ + require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; @@ -1831,6 +1832,9 @@ class Account extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -1838,6 +1842,7 @@ class Account extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'type_lib')) { $return .= '
'.substr($this->type_lib[$this->type], 0, 24).'...'; @@ -1857,6 +1862,8 @@ class Account extends CommonObject } +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; + /** * Class to manage bank transaction lines */ diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d5888e0e7a1..933ff6742b0 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -779,6 +779,9 @@ class PaymentVarious extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -786,6 +789,7 @@ class PaymentVarious extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; if (property_exists($this, 'fk_bank')) { $return .= ' | '.$this->fk_bank.''; } diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index deb86fba456..373bd6560cf 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -480,6 +480,9 @@ class CashControl extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -488,6 +491,7 @@ class CashControl extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1, 1) : $this->ref).''; + $return .= ''; if (property_exists($this, 'posmodule')) { $return .= '
'.substr($langs->trans("Module/Application"), 0, 12).' : '.$this->posmodule.''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3396c7c518c..eadbe8efd05 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5811,6 +5811,8 @@ class Facture extends CommonInvoice */ public function getKanbanView($option = '', $arraydata = null) { + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -5819,6 +5821,7 @@ class Facture extends CommonInvoice $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; if (property_exists($this, 'socid')) { $return .= '
'.$this->socid.''; } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 5224d5e7f09..5f027960ee8 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -835,7 +835,7 @@ if ($object->id > 0) { $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; $sql .= " pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,"; - $sql .= " pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status,"; + $sql .= " pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.amount as pb_amount,"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; @@ -896,6 +896,7 @@ if ($object->id > 0) { $withdrawreceipt->date_creation = $db->jdate($obj->datec); $withdrawreceipt->statut = $obj->status; $withdrawreceipt->status = $obj->status; + $withdrawreceipt->amount = $obj->pb_amount; //$withdrawreceipt->credite = $db->jdate($obj->credite); print $withdrawreceipt->getNomUrl(1); @@ -942,7 +943,7 @@ if ($object->id > 0) { // Past requests $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; - $sql .= " pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.fk_bank_account,"; + $sql .= " pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.fk_bank_account, pb.amount as pb_amount,"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; @@ -1003,6 +1004,7 @@ if ($object->id > 0) { $withdrawreceipt->statut = $obj->status; $withdrawreceipt->status = $obj->status; $withdrawreceipt->fk_bank_account = $obj->fk_bank_account; + $withdrawreceipt->amount = $obj->pb_amount; //$withdrawreceipt->credite = $db->jdate($obj->credite); print $withdrawreceipt->getNomUrl(1); diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index a6db785b779..95647d0f65e 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -640,6 +640,9 @@ class Localtax extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -647,6 +650,7 @@ class Localtax extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'label')) { $return .= ' | '.$this->label.''; } diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 1aebdace757..9135f2d2eb5 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -42,6 +42,11 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); +$type = GETPOST('type'); +if (empty($type)) { + $type = 'CHQ'; +} + $object = new RemiseCheque($db); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -60,6 +65,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; $upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits"; + // filter by dates from / to $search_date_start_day = GETPOST('search_date_start_day', 'int'); $search_date_start_month = GETPOST('search_date_start_month', 'int'); @@ -84,6 +90,10 @@ $usercandelete = $user->rights->banque->cheque; $permissiontodelete = $user->rights->banque->cheque; +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + /* * Actions @@ -132,8 +142,11 @@ if ($action == 'setref' && $user->rights->banque->cheque) { } if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->banque->cheque) { - if (is_array(GETPOST('toRemise'))) { - $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise')); + if (GETPOSTISARRAY('toRemise')) { + $object->type = $type; + $arrayofid = GETPOST('toRemise', 'array:int'); + + $result = $object->create($user, GETPOST("accountid", "int"), 0, $arrayofid); if ($result > 0) { if ($object->statut == 1) { // If statut is validated, we build doc $object->fetch($object->id); // To force to reload all properties in correct property name @@ -286,7 +299,16 @@ if (GETPOST('removefilter')) { $filteraccountid = 0; } -$title = $langs->trans("Cheques")." - ".$langs->trans("Card"); +if ($action == 'new') { + $title = $langs->trans("NewChequeDeposit"); +} else { + if ($type == 'CHQ') { + $title = $langs->trans("Cheques"); + } else { + $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type); + } +} + $helpurl = ""; llxHeader("", $title, $helpurl); @@ -302,7 +324,7 @@ if ($action == 'new') { $hselected = $h; $h++; - print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account'); + print load_fiche_titre($title, '', 'bank_account'); } else { $result = $object->fetch($id, $ref); if ($result < 0) { @@ -357,7 +379,12 @@ if ($action == 'new') { $now = dol_now(); - print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; + $labeltype = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $type); + if ($type == 'CHQ') { + print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; + } else { + print ''.$langs->trans("SelectPaymentTransactionAndGenerate", $labeltype).'

'."\n"; + } print '
'; print ''; @@ -366,9 +393,28 @@ if ($action == 'new') { print dol_get_fiche_head(); print ''; - //print ''; - // Filter - print ''; + } + // Date + print '
'.$langs->trans('Date').''.dol_print_date($now,'day').'
'.$langs->trans("DateChequeReceived").''; + + if (count($arrayofpaymentmodetomanage) > 1) { + $arrayoflabels = array(); + foreach ($arrayofpaymentmodetomanage as $key => $val) { + $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + $arrayoflabels[$key] = $labelval; + } + // Type + print '
'; + print $langs->trans("Type"); + print ''; + print $form->selectarray('type', $arrayoflabels, $type); + print '
'; + if ($type == 'CHQ') { + print $langs->trans("DateChequeReceived"); + } else { + print $langs->trans("DatePaymentReceived"); + } + print ''; // filter by dates from / to print '
'; print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -402,7 +448,7 @@ if ($action == 'new') { $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; - $sql .= " WHERE b.fk_type = 'CHQ'"; + $sql .= " WHERE b.fk_type = '".$db->escape($type)."'"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; @@ -437,7 +483,11 @@ if ($action == 'new') { } if ($i == 0) { - print '
'.$langs->trans("NoWaitingChecks").'

'; + if ($type == 'CHQ') { + print '
'.$langs->trans("NoWaitingChecks").'

'; + } else { + print '
'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'

'; + } } } @@ -459,9 +509,11 @@ if ($action == 'new') { '; $num = $db->num_rows($resql); + print ''; print ''; print ''; + print ''; print ''; $moreforfilter = ''; @@ -469,11 +521,17 @@ if ($action == 'new') { print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; print '\n"; print '\n"; print '\n"; - print '\n"; + print '\n"; print '\n"; print '\n"; print ''; + print ''; } print "
'.$langs->trans("DateChequeReceived").''; + if ($type == 'CHQ') { + print $langs->trans("DateChequeReceived"); + } else { + print $langs->trans("DatePaymentForDepositReceived", $type); + } + print ''.$langs->trans("ChequeNumber")."'.$langs->trans("CheckTransmitter")."'.$langs->trans("Bank")."'.$langs->trans("Amount")."'.$langs->trans("Amount")."'.$langs->trans("Payment")."'.$langs->trans("LineRecord")."'.$langs->trans("Select")."
"; @@ -541,7 +599,13 @@ if ($action == 'new') { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + $morehtmlleft = ''; + $moreghtmlright = ''; + + $labelval = ($langs->trans("PaymentType".$object->type) != "PaymentType".$object->type ? $langs->trans("PaymentType".$object->type) : $object->type); + $morehtmlref = '
'.$langs->trans("Type").' : '.$labelval.'
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft, '', 0, $moreghtmlright); print '
'; @@ -632,7 +696,7 @@ if ($action == 'new') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type= 'CHQ'"; + $sql .= " AND b.fk_type= '".$db->escape($object->type)."'"; $sql .= " AND b.fk_bordereau = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); @@ -706,9 +770,9 @@ if ($action == 'new') { $i++; } } else { - print '
'; + print ''; print $langs->trans("None"); - print '
"; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 5c885267559..e84b0004564 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -53,6 +53,8 @@ class RemiseCheque extends CommonObject //! Numero d'erreur Plage 1024-1279 public $errno; + public $type = 'CHQ'; // 'CHQ', 'TRA', ... + public $amount; public $date_bordereau; public $account_id; @@ -92,9 +94,9 @@ class RemiseCheque extends CommonObject { global $conf; - $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext"; - $sql .= ", bc.date_bordereau as date_bordereau"; - $sql .= ", ba.label as account_label"; + $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext,"; + $sql .= " bc.date_bordereau as date_bordereau, bc.type,"; + $sql .= " ba.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON bc.fk_bank_account = ba.rowid"; $sql .= " WHERE bc.entity = ".$conf->entity; @@ -118,6 +120,7 @@ class RemiseCheque extends CommonObject $this->nbcheque = $obj->nbcheque; $this->statut = $obj->statut; $this->ref_ext = $obj->ref_ext; + $this->type = $obj->type; if ($this->statut == 0) { $this->ref = "(PROV".$this->id.")"; @@ -154,6 +157,11 @@ class RemiseCheque extends CommonObject dol_syslog("RemiseCheque::Create start", LOG_DEBUG); + // Clean parameters + if (empty($this->type)) { + $this->type = 'CHQ'; + } + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bordereau_cheque ("; @@ -167,6 +175,7 @@ class RemiseCheque extends CommonObject $sql .= ", entity"; $sql .= ", nbcheque"; $sql .= ", ref_ext"; + $sql .= ", type"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'"; @@ -178,6 +187,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".((int) $conf->entity); $sql .= ", 0"; $sql .= ", ''"; + $sql .= ", '".$this->db->escape($this->type)."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -205,7 +215,7 @@ class RemiseCheque extends CommonObject if ($this->id > 0 && $this->errno == 0) { $sql = "SELECT b.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql .= " WHERE b.fk_type = 'CHQ'"; + $sql .= " WHERE b.fk_type = '".$this->db->escape($this->type)."'"; $sql .= " AND b.amount > 0"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.fk_account = ".((int) $account_id); @@ -278,9 +288,9 @@ class RemiseCheque extends CommonObject } /** - * Supprime la remise en base + * Delete deposit from database * - * @param User $user Utilisateur qui effectue l'operation + * @param User $user User that delete * @return int */ public function delete($user = '') @@ -464,10 +474,11 @@ class RemiseCheque extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Objet user + * @param User $user Objet user + * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user) + public function load_board($user, $type = 'CHQ') { // phpcs:enable global $conf, $langs; @@ -481,7 +492,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type = 'CHQ'"; + $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; @@ -518,9 +529,10 @@ class RemiseCheque extends CommonObject /** * Charge indicateurs this->nb de tableau de bord * - * @return int <0 if ko, >0 if ok + * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) + * @return int <0 if ko, >0 if ok */ - public function load_state_board() + public function load_state_board($type = 'CHQ') { // phpcs:enable global $user; @@ -534,7 +546,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type = 'CHQ'"; + $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; $sql .= " AND b.amount > 0"; $resql = $this->db->query($sql); @@ -615,7 +627,7 @@ class RemiseCheque extends CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. - $sav_charseSupprimert_output = $outputlangs->charset_output; + $sav_charset_output = $outputlangs->charset_output; $result = $docmodel->write_file($this, $conf->bank->dir_output.'/checkdeposits', $this->ref, $outputlangs); if ($result > 0) { @@ -664,7 +676,7 @@ class RemiseCheque extends CommonObject $sql .= " SET amount = ".price2num($total); $sql .= ", nbcheque = ".((int) $nb); $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity = ".((int) $conf->entity); $resql = $this->db->query($sql); if (!$resql) { @@ -813,7 +825,7 @@ class RemiseCheque extends CommonObject $sql = "SELECT MAX(rowid)"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " WHERE rowid < ".$this->id; + $sql .= " WHERE rowid < ".((int) $this->id); $sql .= " AND entity = ".$conf->entity; $result = $this->db->query($sql); @@ -825,7 +837,7 @@ class RemiseCheque extends CommonObject $sql = "SELECT MIN(rowid)"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " WHERE rowid > ".$this->id; + $sql .= " WHERE rowid > ".((int) $this->id); $sql .= " AND entity = ".$conf->entity; $result = $this->db->query($sql); @@ -1032,6 +1044,8 @@ class RemiseCheque extends CommonObject { global $langs; + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -1039,6 +1053,7 @@ class RemiseCheque extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'date_bordereau')) { $return .= '
'.$langs->trans("DateCreation").' : '.dol_print_date($this->db->jdate($this->date_bordereau), 'day').''; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 394de095104..073fd90944e 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -43,6 +43,10 @@ $result = restrictedArea($user, 'banque', '', ''); $usercancreate = $user->hasRight('banque', 'cheque'); +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + /* * Actions @@ -55,47 +59,61 @@ $usercancreate = $user->hasRight('banque', 'cheque'); * View */ -llxHeader('', $langs->trans("ChequesArea")); +if (getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ') == 'CHQ') { + $title = $langs->trans("ChequesArea"); +} else { + $title = $langs->trans("DocumentsDepositArea"); +} + +llxHeader('', $title); $newcardbutton = ''; if ($usercancreate) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new'); } -print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepositstatic->picto); +print load_fiche_titre($title, $newcardbutton, $checkdepositstatic->picto); print '
'; -$sql = "SELECT count(b.rowid) as nb"; -$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql .= " WHERE ba.rowid = b.fk_account"; -$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql .= " AND b.fk_type = 'CHQ'"; -$sql .= " AND b.fk_bordereau = 0"; -$sql .= " AND b.amount > 0"; - -$resql = $db->query($sql); - print '
'; print ''; print ''; -print '\n"; +print '\n"; print "\n"; -if ($resql) { - $num = ''; - if ($obj = $db->fetch_object($resql)) { - $num = $obj->nb; +foreach ($arrayofpaymentmodetomanage as $val) { + $sql = "SELECT count(b.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE ba.rowid = b.fk_account"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.fk_type = '".$db->escape($val)."'"; + $sql .= " AND b.fk_bordereau = 0"; + $sql .= " AND b.amount > 0"; + + $resql = $db->query($sql); + if ($resql) { + $num = ''; + if ($obj = $db->fetch_object($resql)) { + $num = $obj->nb; + } + print ''; + print ''; + print ''; + } else { + dol_print_error($db); } - print ''; - print ''; - print ''; -} else { - dol_print_error($db); } + print "
'.$langs->trans("BankChecks")."'.$langs->trans("DocumentsForDeposit")."
'; + if ($val == 'CHQ') { + print $langs->trans("BankChecks"); + } else { + print ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $langs->trans("PaymentMode").' '.$val); + } + print ''; + print ''.dol_escape_htmltag($num).''; + print '
'.$langs->trans("BankChecksToReceipt").''; - print ''.$num.''; - print '
\n"; @@ -103,64 +121,79 @@ print '
'; $max = 10; -$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; -$sql .= " bc.statut, bc.nbcheque,"; -$sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,"; -$sql .= " aj.code"; -$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; -$sql .= " WHERE ba.rowid = bc.fk_bank_account"; -$sql .= " AND bc.entity = ".$conf->entity; -$sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC"; -$sql .= $db->plimit($max); +foreach ($arrayofpaymentmodetomanage as $val) { + $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; + $sql .= " bc.statut, bc.nbcheque, bc.type,"; + $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,"; + $sql .= " aj.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; + $sql .= " WHERE ba.rowid = bc.fk_bank_account"; + $sql .= " AND bc.entity = ".((int) $conf->entity); + $sql .= " AND bc.type = '".$db->escape($val)."'"; + $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC"; + $sql .= $db->plimit($max); -$resql = $db->query($sql); -if ($resql) { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print ''; - print '"; - print ''; - print ''; - print ''; - print ''; - print "\n"; + $resql = $db->query($sql); + if ($resql) { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'.$langs->trans("LastCheckReceiptShort", $max).''.$langs->trans("Date")."'.$langs->trans("Account").''.$langs->trans("NbOfCheques").''.$langs->trans("Amount").''.$langs->trans("Status").'
'; + print ''; + print ''; + print '"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - while ($objp = $db->fetch_object($resql)) { - $checkdepositstatic->id = $objp->rowid; - $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); - $checkdepositstatic->statut = $objp->statut; + $i = 0; + while ($objp = $db->fetch_object($resql)) { + $i++; - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->label; - $accountstatic->number = $objp->number; - $accountstatic->currency_code = $objp->currency_code; - $accountstatic->account_number = $objp->account_number; - $accountstatic->accountancy_journal = $objp->code; - $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal; + $checkdepositstatic->id = $objp->rowid; + $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); + $checkdepositstatic->statut = $objp->statut; - print ''."\n"; + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->label; + $accountstatic->number = $objp->number; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + $accountstatic->accountancy_journal = $objp->code; + $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''."\n"; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } + if ($i == 0) { + print ''; + } + print "
'; + if ($val == 'CHQ') { + print $langs->trans("LastCheckReceiptShort", $max); + } else { + $labelpaymentmode = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + print $langs->trans("LastPaymentForDepositShort", $max, $labelpaymentmode); + } + print ''.$langs->trans("Date")."'.$langs->trans("Account").''.$langs->trans("NbOfCheques").''.$langs->trans("Amount").''.$langs->trans("Status").'
'.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db), 'day').''.$accountstatic->getNomUrl(1).''.$objp->nbcheque.''.price($objp->amount).''.$checkdepositstatic->LibStatut($objp->statut, 3).'
'.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db), 'day').''.$accountstatic->getNomUrl(1).''.$objp->nbcheque.''.price($objp->amount).''.$checkdepositstatic->LibStatut($objp->statut, 3).'
'.$langs->trans("None").'
"; + print '
'; + + $db->free($resql); + } else { + dol_print_error($db); } - print "
"; - print '
'; - - $db->free($resql); -} else { - dol_print_error($db); } - print '
'; // End of page diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 3c617a2db0c..11748c5c870 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -73,6 +73,16 @@ $formother = new FormOther($db); $checkdepositstatic = new RemiseCheque($db); $accountstatic = new Account($db); +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + +$arrayoflabels = array(); +foreach ($arrayofpaymentmodetomanage as $key => $val) { + $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + $arrayoflabels[$key] = $labelval; +} + /* * Actions @@ -93,10 +103,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -llxHeader('', $langs->trans("ChequesReceipts")); +llxHeader('', $langs->trans("ChequeDeposits")); $sql = "SELECT bc.rowid, bc.ref, bc.date_bordereau,"; -$sql .= " bc.nbcheque, bc.amount, bc.statut,"; +$sql .= " bc.nbcheque, bc.amount, bc.statut, bc.type,"; $sql .= " ba.rowid as bid, ba.label"; $sqlfields = $sql; // $sql fields to remove for count total @@ -104,7 +114,7 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,"; $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE bc.fk_bank_account = ba.rowid"; -$sql .= " AND bc.entity = ".$conf->entity; +$sql .= " AND bc.entity = ".((int) $conf->entity); // Search criteria if ($search_ref) { @@ -191,10 +201,13 @@ if ($resql) { // Fields title search print ''; - print ''; + print ''; print ''; print ''; - print ''; + // Type + print ''; + print ''; + print ''; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } @@ -217,6 +230,7 @@ if ($resql) { print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "bc.ref", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "bc.type", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "bc.date_bordereau", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("NbOfCheques", $_SERVER["PHP_SELF"], "bc.nbcheque", "", $param, 'class="right"', $sortfield, $sortorder); @@ -236,6 +250,7 @@ if ($resql) { $checkdepositstatic->nbcheque = $objp->nbcheque; $checkdepositstatic->amount = $objp->amount; $checkdepositstatic->date_bordereau = $objp->date_bordereau; + $checkdepositstatic->type = $objp->type; $account = new Account($db); $account->fetch($objp->bid); @@ -257,12 +272,15 @@ if ($resql) { // Num ref cheque print ''; - print $checkdepositstatic->getNomUrl(1); print ''; + // Type + $labelpaymentmode = ($langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) != "PaymentType".$checkdepositstatic->type ? $langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) : $checkdepositstatic->type); + print ''.dol_escape_htmltag($labelpaymentmode).''; + // Date - print ''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''; // TODO Use date hour + print ''.dol_print_date($db->jdate($objp->date_bordereau), 'dayhour', 'tzuser').''; // Bank print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index cbe2eda9533..3618817e19a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -426,6 +426,7 @@ class BonPrelevement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit or credit transfer order to "paid" status. + * Then create the payment for each invoice of the prelemevement_bon. * * @param User $user Id of user * @param int $date date of action @@ -1317,6 +1318,9 @@ class BonPrelevement extends CommonObject $label = img_picto('', $this->picto).' '.$langs->trans($labeltoshow).' '.$this->getLibStatut(5); $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; + if (isset($this->amount)) { + $label .= '
'.$langs->trans("Amount").": ".price($this->amount); + } if (isset($this->date_trans)) { $label .= '
'.$langs->trans("TransData").": ".dol_print_date($this->date_trans, 'dayhour', 'tzuserrel'); } @@ -2524,6 +2528,8 @@ class BonPrelevement extends CommonObject { global $langs; + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -2531,6 +2537,7 @@ class BonPrelevement extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; if (property_exists($this, 'date_echeance')) { $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->date_echeance), 'day').''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 140f1cffec6..c9e9b6e561b 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -761,6 +761,8 @@ class ChargeSociales extends CommonObject { global $conf, $langs; + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -768,6 +770,7 @@ class ChargeSociales extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(0) : $this->ref).''; + $return .= ''; if (property_exists($this, 'label')) { $return .= '  
'.$this->label.'
'; } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 220863a0cb2..2be181d7350 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -917,6 +917,9 @@ class Tva extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -925,6 +928,7 @@ class Tva extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; if (property_exists($this, 'amount')) { $return .= ' | '.$langs->trans("Amount").' : '.price($this->amount).''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 407eed06921..379cda22d43 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1868,7 +1868,7 @@ class Contact extends CommonObject * Updates all roles (default contact for companies) according to values inside the ->roles array. * This is called by update of contact. * - * @return float|int + * @return int * @see fetchRoles() */ public function updateRoles() @@ -1878,7 +1878,7 @@ class Contact extends CommonObject $error = 0; if (!isset($this->roles)) { - return; // Avoid to loose roles when property not set + return 0; // Avoid to loose roles when property not set } $this->db->begin(); @@ -2177,6 +2177,9 @@ class Contact extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -2189,6 +2192,7 @@ class Contact extends CommonObject $return .= ''; $return .= '
'; $return .= '
'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'
'; + $return .= ''; if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index cea2b5464d3..1a9a318acb5 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -64,7 +64,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'contact', $contactid, ''); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars $search_phone = GETPOST("search_phone", 'alpha'); @@ -297,7 +297,7 @@ if (empty($reshook)) { // 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 - $sall = ""; + $search_all = ""; $search_id = ''; $search_firstlast_only = ""; $search_lastname = ""; @@ -430,7 +430,6 @@ $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total -// SQL Table Aliase $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; if (isset($extrafields->attributes[$object->table_element]['label']) && 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 (p.rowid = ef.fk_object)"; @@ -569,8 +568,8 @@ if (!empty($searchCategorySupplierList)) { } } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } if (strlen($search_phone)) { $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); @@ -725,7 +724,7 @@ if (!$resql) { $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '') && !$page) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id); @@ -750,7 +749,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } -$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); +$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all); $param .= '&type='.urlencode($type).'&view='.urlencode($view); if (!empty($search_categ) && $search_categ != '-1') { $param .= '&search_categ='.urlencode($search_categ); @@ -761,8 +760,8 @@ if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') { if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') { $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); } -if ($sall != '') { - $param .= '&sall='.urlencode($sall); +if ($search_all != '') { + $param .= '&search_all='.urlencode($search_all); } if ($search_id > 0) { $param .= "&search_id=".urlencode($search_id); @@ -886,14 +885,14 @@ $objecttmp = new Contact($db); $trackid = 'ctc'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { +if ($search_all) { $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } if ($search_firstlast_only) { print '
'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'
'; @@ -955,7 +954,7 @@ print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -1234,28 +1233,28 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { // 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, -); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; } if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; } if (!empty($arrayfields['p.statut']['checked'])) { print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; } if (!empty($arrayfields['p.import_key']['checked'])) { print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; } if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; } print "\n"; @@ -1291,7 +1290,7 @@ while ($i < $imaxinloop) { $contactstatic->country_code = $obj->country_code; $contactstatic->photo = $obj->photo; $contactstatic->import_key = $obj->import_key; - + $contactstatic->photo = $obj->photo; $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel; if ($mode == 'kanban') { @@ -1299,7 +1298,13 @@ while ($i < $imaxinloop) { print '\n"; + print ''."\n"; } $i++; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 8afbc4b1f68..2817cfc406a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1535,12 +1535,12 @@ if ($action == 'create') { if ($nbofservices > 1 && $conf->browser->layout != 'phone' && !empty($user->rights->contrat->creer)) { print '
'; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print '
'; print '
'; } - $contactstatic->photo = $obj->photo; + // Output Kanban + 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($object->id, $arrayofselected)) { + $selected = 1; + } + } if ($obj->socid > 0) { $contactstatic->fetch_thirdparty($obj->socid); } @@ -1549,7 +1554,7 @@ while ($i < $imaxinloop) { 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); + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation @@ -1606,7 +1611,7 @@ while ($i < $imaxinloop) { } } - print "
'; if ($cursorline > 1) { - print 'rowid.'">'; + print 'rowid.'">'; echo img_up('default', 0, 'imgupforline'); print ''; } if ($cursorline < $nbofservices) { - print 'rowid.'">'; + print 'rowid.'">'; echo img_down('default', 0, 'imgdownforline'); print ''; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 14f5cb62bfa..3e3678fbcad 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -758,7 +758,7 @@ class Contrat extends CommonObject * * @param int $only_services 0=Default, 1=Force only services (depending on setup, we may also have physical products in a contract) * @param int $loadalsotranslation 0=Default, 1=Load also translations of product descriptions - * @return ContratLigne[] Return array of contract lines + * @return array|int Return array of contract lines */ public function fetch_lines($only_services = 0, $loadalsotranslation = 0) { @@ -2829,6 +2829,9 @@ class Contrat extends CommonObject public function getKanbanView($option = '', $arraydata = null) { global $langs; + + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= ''; @@ -2837,6 +2840,7 @@ class Contrat extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'societe')) { $return .= '
'.$this->societe.''; } diff --git a/htdocs/core/ajax/ajaxinvoiceline.php b/htdocs/core/ajax/ajaxinvoiceline.php new file mode 100644 index 00000000000..432ad15b151 --- /dev/null +++ b/htdocs/core/ajax/ajaxinvoiceline.php @@ -0,0 +1,69 @@ + + * + * 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/core/ajax/ajaxinvoiceline.php + * \brief File to load contacts combobox + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} + +// Load Dolibarr environment +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + +$invoice_id = GETPOST('id', 'int'); // id of thirdparty +$action = GETPOST('action', 'aZ09'); +$htmlname = GETPOST('htmlname', 'alpha'); + + + +// Security check +restrictedArea($user, 'facture', $invoice_id, '', '', 'fk_soc', 'rowid'); + + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; + +// Load original field value +if (!empty($invoice_id) && !empty($action) && !empty($htmlname)) { + $formProject = new FormProjets($db); + + $return = array(); + if (empty($showempty)) { + $showempty = 0; + } + + $return['value'] = $formProject->selectInvoiceAndLine($invoice_id, 0, 'invoiceid', 'invoicelineid', 'maxwidth500', array(), 1); + //$return['num'] = $form->num; + //$return['error'] = $form->error; + + echo json_encode($return); +} diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 96928adfdff..1c18264618d 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -432,7 +432,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box while (($file = readdir($handle)) !== false) { $reg = array(); if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg)) { - if (preg_match('/\.back$/', $file)) { + if (preg_match('/\.back$/', $file) || preg_match('/^(.+)\.disabled\.php/', $file)) { continue; } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index e7e31cc9398..055cb58e84f 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -889,7 +889,7 @@ abstract class CommonInvoice extends CommonObject { global $conf, $mysoc, $user, $langs; - if ($type != 'bank-transfer' && empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { + if ($type != 'bank-transfer' && $type != 'credit-transfer' && empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { return 0; } if ($type != 'direct-debit' && empty($conf->global->STRIPE_SEPA_CREDIT_TRANSFER)) { @@ -916,10 +916,10 @@ abstract class CommonInvoice extends CommonObject $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_prelevement_bons"; $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; $sql .= " WHERE rowid = ".((int) $did); - if ($type != 'direct-debit') { + if ($type != 'bank-transfer' && $type != 'credit-transfer') { $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one } - if ($type != 'credit-transfer') { + if ($type != 'direct-debit') { $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one } $sql .= " AND traite = 0"; // Add a protection to not process twice diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 8f2edc005ec..e624beae75b 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -44,6 +44,8 @@ abstract class CommonOrder extends CommonObject { global $langs, $conf; + $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); + $return = '
'; $return .= '
'; $return .= '
'; @@ -51,6 +53,7 @@ abstract class CommonOrder extends CommonObject $return .= '
'; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 21d245aec2a..8506ab1f352 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -37,15 +37,15 @@ */ /** - * \file htdocs/core/class/html.form.class.php + * \file htdocs/core/class/html.form.class.php * \ingroup core - * \brief File of class with all html predefined components + * \brief File of class with all html predefined components */ /** - * Class to manage generation of HTML components - * Only common components must be here. + * Class to manage generation of HTML components + * Only common components must be here. * * TODO Merge all function load_cache_* and loadCache* (except load_cache_vatrates) into one generic function loadCacheTable */ @@ -81,7 +81,7 @@ class Form /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { @@ -91,18 +91,18 @@ class Form /** * Output key field for an editable field * - * @param string $text Text of label or key to translate - * @param string $htmlname Name of select field ('edit' prefix will be added) - * @param string $preselected Value to show/edit (not used in this function) - * @param object $object Object (on the page we show) - * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) - * @param string $moreparam More param to add on a href URL. - * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. - * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' - * @param string $paramid Key of parameter for id ('id', 'socid') - * @param string $help Tooltip help - * @return string HTML edit field + * @param string $text Text of label or key to translate + * @param string $htmlname Name of select field ('edit' prefix will be added) + * @param string $preselected Value to show/edit (not used in this function) + * @param object $object Object (on the page we show) + * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $moreparam More param to add on a href URL. + * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. + * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' + * @param string $paramid Key of parameter for id ('id', 'socid') + * @param string $help Tooltip help + * @return string HTML edit field */ public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id', $help = '') { @@ -114,7 +114,7 @@ class Form if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;/', $typeofdata)) { if (!empty($perm)) { $tmp = explode(':', $typeofdata); - $ret .= '
'; + $ret .= '
'; if ($fieldrequired) { $ret .= ''; } @@ -126,7 +126,7 @@ class Form if ($fieldrequired) { $ret .= ''; } - $ret .= '
'."\n"; + $ret .= '
' . "\n"; } else { if ($fieldrequired) { $ret .= ''; @@ -164,8 +164,8 @@ class Form if (empty($notabletag) && $perm) { $ret .= '
'; } - if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { - $ret .= 'id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).''; + if ($htmlname && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { + $ret .= '' . img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)) . ''; } if (!empty($notabletag) && $notabletag == 1) { if ($text) { @@ -191,23 +191,23 @@ class Form /** * Output value of a field for an editable field * - * @param string $text Text of label (not used in this function) - * @param string $htmlname Name of select field - * @param string $value Value to show/edit - * @param object $object Object (that we want to show) - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') - * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value - * @param object $extObject External object ??? - * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') - * @param string $moreparam More param to add on the form on action href URL parameter - * @param int $notabletag Do no output table tags - * @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email') - * @param string $paramid Key of parameter for id ('id', 'socid') - * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) - * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) - * @param string $editaction [=''] use GETPOST default action or set action to edit mode - * @return string HTML edit field + * @param string $text Text of label (not used in this function) + * @param string $htmlname Name of select field + * @param string $value Value to show/edit + * @param object $object Object (that we want to show) + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') + * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value + * @param object $extObject External object ??? + * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') + * @param string $moreparam More param to add on the form on action href URL parameter + * @param int $notabletag Do no output table tags + * @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email') + * @param string $paramid Key of parameter for id ('id', 'socid') + * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) + * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) + * @param string $editaction [=''] use GETPOST default action or set action to edit mode + * @return string HTML edit field */ public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '') { @@ -230,7 +230,7 @@ class Form } elseif ($reg[1] == 'int') { $typeofdata = 'numeric'; } else { - return 'ErrorBadParameter '.$typeofdata; + return 'ErrorBadParameter ' . $typeofdata; } } @@ -241,13 +241,13 @@ class Form if ($editaction == '') { $editaction = GETPOST('action', 'aZ09'); } - $editmode = ($editaction == 'edit'.$htmlname); + $editmode = ($editaction == 'edit' . $htmlname); if ($editmode) { $ret .= "\n"; - $ret .= ''; - $ret .= ''; - $ret .= ''; - $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; if (empty($notabletag)) { $ret .= ''; } @@ -256,29 +256,29 @@ class Form } if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(integer)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value, 0); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(numeric|amount)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $ret .= ''; - } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = (empty($tmp[2]) ? '' : $tmp[2]); $morealt = ''; if (preg_match('/%/', $cols)) { - $morealt = ' style="width: '.$cols.'"'; + $morealt = ' style="width: ' . $cols . '"'; $cols = ''; } $valuetoshow = ($editvalue ? $editvalue : $value); - $ret .= ''; } else { - $resultforextrlang .= ''; + $resultforextrlang .= ''; } } $result .= $resultforextrlang; $result .= ''; - $result .= ''; + $result .= ''; } return $result; @@ -467,15 +467,15 @@ class Form /** * Output edit in place form * - * @param object $object Object - * @param string $value Value to show/edit - * @param string $htmlname DIV ID (field name) - * @param int $condition Condition to edit - * @param string $inputType Type of input ('string', 'numeric', 'datepicker' ('day' do not work, don't know why), 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:loadmethod:savemethod:buttononly') - * @param string $editvalue When in edit mode, use this value as $value instead of value - * @param object $extObject External object - * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') - * @return string HTML edit in place + * @param object $object Object + * @param string $value Value to show/edit + * @param string $htmlname DIV ID (field name) + * @param int $condition Condition to edit + * @param string $inputType Type of input ('string', 'numeric', 'datepicker' ('day' do not work, don't know why), 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:loadmethod:savemethod:buttononly') + * @param string $editvalue When in edit mode, use this value as $value instead of value + * @param object $extObject External object + * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') + * @return string HTML edit in place */ protected function editInPlace($object, $value, $htmlname, $condition, $inputType = 'textarea', $editvalue = null, $extObject = null, $custommsg = null) { @@ -495,11 +495,11 @@ class Form if ($condition) { $element = false; $table_element = false; - $fk_element = false; - $loadmethod = false; - $savemethod = false; - $ext_element = false; - $button_only = false; + $fk_element = false; + $loadmethod = false; + $savemethod = false; + $ext_element = false; + $button_only = false; $inputOption = ''; $rows = ''; $cols = ''; @@ -523,7 +523,7 @@ class Form if (!empty($tmp[2])) { $savemethod = $tmp[2]; } - $out .= ''."\n"; + $out .= '' . "\n"; } elseif ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) { $tmp = explode(':', $inputType); $inputType = $tmp[0]; @@ -534,7 +534,7 @@ class Form $savemethod = $tmp[2]; } - $out .= ''."\n"; // Use for timestamp format + $out .= '' . "\n"; // Use for timestamp format } elseif (preg_match('/^(select|autocomplete)/', $inputType)) { $tmp = explode(':', $inputType); $inputType = $tmp[0]; @@ -565,40 +565,40 @@ class Form } if (isModEnabled('fckeditor')) { - $out .= ''."\n"; + $out .= '' . "\n"; } else { $inputType = 'textarea'; } } - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; if (!empty($savemethod)) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($ext_element)) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($custommsg)) { if (is_array($custommsg)) { if (!empty($custommsg['success'])) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($custommsg['error'])) { - $out .= ''."\n"; + $out .= '' . "\n"; } } else { - $out .= ''."\n"; + $out .= '' . "\n"; } } if ($inputType == 'textarea') { - $out .= ''."\n"; - $out .= ''."\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; } - $out .= ''.$value.''."\n"; - $out .= ''.(!empty($editvalue) ? $editvalue : $value).''."\n"; + $out .= '' . $value . '' . "\n"; + $out .= '' . (!empty($editvalue) ? $editvalue : $value) . '' . "\n"; } else { $out = $value; } @@ -607,32 +607,32 @@ class Form } /** - * Show a text and picto with tooltip on text or picto. + * Show a text and picto with tooltip on text or picto. * Can be called by an instancied $form->textwithtooltip or by a static call Form::textwithtooltip * - * @param string $text Text to show - * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. - * @param int $tooltipon 1=tooltip on text, 2=tooltip on image, 3=tooltip sur les 2 - * @param int $direction -1=image is before, 0=no image, 1=image is after - * @param string $img Html code for image (use img_xxx() function to get it) - * @param string $extracss Add a CSS style to td tags - * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $incbefore Include code before the text - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) - * @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. + * @param string $text Text to show + * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. + * @param int $tooltipon 1=tooltip on text, 2=tooltip on image, 3=tooltip sur les 2 + * @param int $direction -1=image is before, 0=no image, 1=image is after + * @param string $img Html code for image (use img_xxx() function to get it) + * @param string $extracss Add a CSS style to td tags + * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span + * @param string $incbefore Include code before the text + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) + * @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. */ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { if ($incbefore) { - $text = $incbefore.$text; + $text = $incbefore . $text; } if (!$htmltext) { return $text; } - $direction = (int) $direction; // For backward compatibility when $direction was set to '' instead of 0 + $direction = (int) $direction; // For backward compatibility when $direction was set to '' instead of 0 $tag = 'td'; if ($notabs == 2) { @@ -646,11 +646,11 @@ class Form $extrastyle = ''; if ($direction < 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extracss = ($extracss ? $extracss . ' ' : '') . ($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-left: 3px;'; } if ($direction > 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extracss = ($extracss ? $extracss . ' ' : '') . ($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-right: 3px;'; } @@ -663,53 +663,53 @@ class Form $htmltext = str_replace('"', '"', $htmltext); } else { $classfortooltip = 'classfortooltiponclick'; - $textfordialog .= ''; + $textfordialog .= ''; } if ($tooltipon == 2 || $tooltipon == 3) { - $paramfortooltipimg = ' class="'.$classfortooltip.($notabs != 3 ? ' inline-block' : '').($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"'; + $paramfortooltipimg = ' class="' . $classfortooltip . ($notabs != 3 ? ' inline-block' : '') . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '"'; if ($tooltiptrigger == '') { - $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip + $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on img tag to store tooltip } else { - $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"'; + $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"'; } } else { - $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag + $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag } if ($tooltipon == 1 || $tooltipon == 3) { - $paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" '; + $paramfortooltiptd = ' class="' . ($tooltipon == 3 ? 'cursorpointer ' : '') . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '" '; if ($tooltiptrigger == '') { - $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip + $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on td tag to store tooltip } else { - $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"'; + $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"'; } } else { - $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag + $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag } if (empty($notabs)) { $s .= '
'; } elseif ($notabs == 2) { - $s .= '
'; + $s .= '
'; } // Define value if value is before if ($direction < 0) { - $s .= '<'.$tag.$paramfortooltipimg; + $s .= '<' . $tag . $paramfortooltipimg; if ($tag == 'td') { $s .= ' class="valigntop" width="14"'; } - $s .= '>'.$textfordialog.$img.''; + $s .= '>' . $textfordialog . $img . ''; } // Use another method to help avoid having a space in value in order to use this value with jquery // Define label if ((string) $text != '') { - $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.''; + $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . ''; } // Define value if value is after if ($direction > 0) { - $s .= '<'.$tag.$paramfortooltipimg; + $s .= '<' . $tag . $paramfortooltipimg; if ($tag == 'td') { $s .= ' class="valignmiddle" width="14"'; } - $s .= '>'.$textfordialog.$img.''; + $s .= '>' . $textfordialog . $img . ''; } if (empty($notabs)) { $s .= '
'; @@ -721,18 +721,18 @@ class Form } /** - * Show a text with a picto and a tooltip on picto + * Show a text with a picto and a tooltip on picto * - * @param string $text Text to show - * @param string $htmltext Content of tooltip - * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon - * @param string $type Type of picto ('info', 'infoclickable', 'help', 'helpclickable', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none' - * @param string $extracss Add a CSS style to td, div or span tag - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') - * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) - * @return string HTML code of text, picto, tooltip + * @param string $text Text to show + * @param string $htmltext Content of tooltip + * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon + * @param string $type Type of picto ('info', 'infoclickable', 'help', 'helpclickable', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none' + * @param string $extracss Add a CSS style to td, div or span tag + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) + * @return string HTML code of text, picto, tooltip */ public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger = '', $forcenowrap = 0) { @@ -799,12 +799,12 @@ class Form /** * Generate select HTML to choose massaction * - * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. - * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. - * @param int $alwaysvisible 1=select button always visible - * @param string $name Name for massaction - * @param string $cssclass CSS class used to check for select - * @return string|void Select list + * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. + * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. + * @param int $alwaysvisible 1=select button always visible + * @param string $name Name for massaction + * @param string $cssclass CSS class used to check for select + * @return string|void Select list */ public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name = 'massaction', $cssclass = 'checkforselect') { @@ -813,7 +813,7 @@ class Form $disabled = 0; $ret = '
'; - $ret .= ''; // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. $parameters = array(); @@ -823,9 +823,9 @@ class Form return; } if (empty($reshook)) { - $ret .= ''; + $ret .= ''; foreach ($arrayofaction as $code => $label) { - $ret .= ''; + $ret .= ''; } } $ret .= $hookmanager->resPrint; @@ -833,17 +833,17 @@ class Form $ret .= ''; if (empty($conf->dol_optimize_smallscreen)) { - $ret .= ajax_combobox('.'.$name.'select'); + $ret .= ajax_combobox('.' . $name . 'select'); } // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret .= ''; // Hidden button BEFORE so it is the one used when we submit with ENTER. - $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"').' class="button smallpaddingimp'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; + $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"') . ' class="button smallpaddingimp' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' ' . $name . ' ' . $name . 'confirmed" value="' . dol_escape_htmltag($langs->trans("Confirm")) . '">'; $ret .= '
'; if (!empty($conf->use_javascript_ajax)) { $ret .= ' - '; $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out .= ' '; + $out .= ' '; $out .= '
'; } @@ -2288,32 +2302,33 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * - * @param int $selected Preselected products - * @param string $htmlname Name of HTML select field (must be unique in page). - * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param int $limit Limit on number of returned lines - * @param int $price_level Level of price to show - * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param int $finished 2=all, 1=finished, 0=raw material - * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) - * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used - * 'warehouseopen' = count products from open warehouses, - * 'warehouseclosed' = count products from closed warehouses, - * 'warehouseinternal' = count products from warehouses for internal correct/transfer only - * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) - * @param string $nooutput No print, return the output into a string - * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase - * @return void|string + * @param int $selected Preselected products + * @param string $htmlname Name of HTML select field (must be unique in page). + * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limit on number of returned lines + * @param int $price_level Level of price to show + * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished 2=all, 1=finished, 0=raw material + * @param string $selected_input_value Value of preselected input text (for use with ajax) + * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param array $ajaxoptions Options for ajax_autocompleter + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int $forcecombo Force to use combo box + * @param string $morecss Add more css on select + * @param int $hidepriceinlabel 1=Hide prices in label + * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only + * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) + * @param string $nooutput No print, return the output into a string + * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase + * @return void|string */ public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1) { @@ -2340,7 +2355,7 @@ class Form $placeholder = ''; if ($selected && empty($selected_input_value)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); $selected_input_value = $producttmpselect->ref; @@ -2355,17 +2370,17 @@ class Form } } // mode=1 means customers products - $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); + $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&status_purchase=' . $status_purchase . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus; + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); if (isModEnabled('variants') && is_array($selected_combinations)) { // Code to automatically insert with javascript the select of attributes under the select of product // when a parent of variant has been selected. $out .= ' - '; } if (empty($hidelabel)) { - $out .= $langs->trans("RefOrLabel").' : '; + $out .= $langs->trans("RefOrLabel") . ' : '; } elseif ($hidelabel > 1) { - $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"'; + $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"'; if ($hidelabel == 2) { $out .= img_picto($langs->trans("Search"), 'search'); } } - $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />'; if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); } @@ -2471,7 +2486,7 @@ class Form * @param string $morecss Add more css on select * @param string $nooutput No print, return the output into a string * @param int $forcecombo Force to use combo box - * @param array $TProducts Add filter on a defined product + * @param array $TProducts Add filter on a defined product * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) @@ -2479,29 +2494,29 @@ class Form // phpcs:enable global $conf, $user, $langs, $db; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $error = 0; $out = ''; if (!$forcecombo) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $events = array(); $out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT")); } - $out .= ''; $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; - $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; - if (!empty($status)) $sql.= ' AND status = '. (int) $status; - if (!empty($type)) $sql.= ' AND bomtype = '. (int) $type; - if (!empty($TProducts)) $sql .= ' AND fk_product IN ('.$this->db->sanitize(implode(',', $TProducts)).')'; - if (!empty($limit)) $sql.= ' LIMIT '. (int) $limit; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bom_bom as b'; + $sql .= ' WHERE b.entity IN (' . getEntity('bom') . ')'; + if (!empty($status)) $sql .= ' AND status = ' . (int) $status; + if (!empty($type)) $sql .= ' AND bomtype = ' . (int) $type; + if (!empty($TProducts)) $sql .= ' AND fk_product IN (' . $this->db->sanitize(implode(',', $TProducts)) . ')'; + if (!empty($limit)) $sql .= ' LIMIT ' . (int) $limit; $resql = $db->query($sql); if ($resql) { - if ($showempty) { + if ($showempty) { $out .= ''; + $out .= '>' . $obj->ref . ' - ' . $product->label . ' - ' . $obj->label . ''; } } else { $error++; @@ -2525,30 +2540,31 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of products for a customer. + * Return list of products for a customer. * Called by select_produits. * - * @param int $selected Preselected product - * @param string $htmlname Name of select html - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param int $limit Limit on number of returned lines - * @param int $price_level Level of price to show - * @param string $filterkey Filter on product - * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param int $finished Filter on finished field: 2=No filter - * @param int $outputmode 0=HTML select string, 1=Array - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus Warehouse status filter to group/count stock. Following comma separated filter options can be used. - * 'warehouseopen' = count products from open warehouses, - * 'warehouseclosed' = count products from closed warehouses, - * 'warehouseinternal' = count products from warehouses for internal correct/transfer only - * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase - * @return array|string Array of keys for json + * @param int $selected Preselected product + * @param string $htmlname Name of select html + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limit on number of returned lines + * @param int $price_level Level of price to show + * @param string $filterkey Filter on product + * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished Filter on finished field: 2=No filter + * @param int $outputmode 0=HTML select string, 1=Array + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int $forcecombo Force to use combo box + * @param string $morecss Add more css on select + * @param int $hidepriceinlabel 1=Hide prices in label + * @param string $warehouseStatus Warehouse status filter to group/count stock. Following comma separated filter options can be used. + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only + * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase + * @return array|string Array of keys for json */ public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1) { @@ -2566,7 +2582,7 @@ class Form $warehouseStatusArray = array(); if (!empty($warehouseStatus)) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; if (preg_match('/warehouseclosed/', $warehouseStatus)) { $warehouseStatusArray[] = Entrepot::STATUS_CLOSED; } @@ -2580,19 +2596,19 @@ class Form $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { - $selectFieldsGrouped = ", sum(".$this->db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + $selectFieldsGrouped = ", sum(" . $this->db->ifsql("e.statut IS NULL", "0", "ps.reel") . ") as stock"; // e.statut is null if there is no record in stock } else { - $selectFieldsGrouped = ", ".$this->db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; + $selectFieldsGrouped = ", " . $this->db->ifsql("p.stock IS NULL", 0, "p.stock") . " AS stock"; } $sql = "SELECT "; - $sql .= $selectFields.$selectFieldsGrouped; + $sql .= $selectFields . $selectFieldsGrouped; if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category - $sql .= ", (SELECT ".$this->db->prefix()."categorie_product.fk_categorie - FROM ".$this->db->prefix()."categorie_product - WHERE ".$this->db->prefix()."categorie_product.fk_product=p.rowid + $sql .= ", (SELECT " . $this->db->prefix() . "categorie_product.fk_categorie + FROM " . $this->db->prefix() . "categorie_product + WHERE " . $this->db->prefix() . "categorie_product.fk_product=p.rowid LIMIT 1 ) AS categorie_product_id "; } @@ -2618,83 +2634,83 @@ class Form } // Price by quantity if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= ", (SELECT pp.rowid FROM ".$this->db->prefix()."product_price as pp WHERE pp.fk_product = p.rowid"; + $sql .= ", (SELECT pp.rowid FROM " . $this->db->prefix() . "product_price as pp WHERE pp.fk_product = p.rowid"; if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= " AND price_level = ".((int) $price_level); + $sql .= " AND price_level = " . ((int) $price_level); } $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1) as price_rowid"; - $sql .= ", (SELECT pp.price_by_qty FROM ".$this->db->prefix()."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable + $sql .= ", (SELECT pp.price_by_qty FROM " . $this->db->prefix() . "product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= " AND price_level = ".((int) $price_level); + $sql .= " AND price_level = " . ((int) $price_level); } $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1) as price_by_qty"; $selectFields .= ", price_rowid, price_by_qty"; } - $sql .= " FROM ".$this->db->prefix()."product as p"; + $sql .= " FROM " . $this->db->prefix() . "product as p"; if (count($warehouseStatusArray)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as ps on ps.fk_product = p.rowid"; - $sql .= " LEFT JOIN ".$this->db->prefix()."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; - $sql .= ' AND e.statut IN ('.$this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as ps on ps.fk_product = p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" . getEntity('stock') . ")"; + $sql .= ' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))) . ')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. } // include search in supplier ref if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; } //Price by customer if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_customer_price as pcp ON pcp.fk_soc=".((int) $socid)." AND pcp.fk_product=p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) . " AND pcp.fk_product=p.rowid"; } // Units if (getDolGlobalInt('PRODUCT_USE_UNITS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_units u ON u.rowid = p.fk_unit"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_units u ON u.rowid = p.fk_unit"; } // Multilang : we add translation if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_lang as pl ON pl.fk_product = p.rowid "; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_lang as pl ON pl.fk_product = p.rowid "; if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $soc = new Societe($this->db); $result = $soc->fetch($socid); if ($result > 0 && !empty($soc->default_lang)) { - $sql .= " AND pl.lang = '".$this->db->escape($soc->default_lang)."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($soc->default_lang) . "'"; } else { - $sql .= " AND pl.lang = '".$this->db->escape($langs->getDefaultLang())."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) . "'"; } } else { - $sql .= " AND pl.lang = '".$this->db->escape($langs->getDefaultLang())."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) . "'"; } } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; + $sql .= ' WHERE p.entity IN (' . getEntity('product') . ')'; if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " AND pac.rowid IS NULL"; } if ($finished == 0) { - $sql .= " AND p.finished = ".((int) $finished); + $sql .= " AND p.finished = " . ((int) $finished); } elseif ($finished == 1) { - $sql .= " AND p.finished = ".((int) $finished); + $sql .= " AND p.finished = " . ((int) $finished); if ($status >= 0) { - $sql .= " AND p.tosell = ".((int) $status); + $sql .= " AND p.tosell = " . ((int) $status); } } elseif ($status >= 0) { - $sql .= " AND p.tosell = ".((int) $status); + $sql .= " AND p.tosell = " . ((int) $status); } if ($status_purchase >= 0) { - $sql .= " AND p.tobuy = ".((int) $status_purchase); + $sql .= " AND p.tobuy = " . ((int) $status_purchase); } // Filter by product type if (strval($filtertype) != '') { - $sql .= " AND p.fk_product_type = ".((int) $filtertype); + $sql .= " AND p.fk_product_type = " . ((int) $filtertype); } elseif (!isModEnabled('product')) { // when product module is disabled, show services only $sql .= " AND p.fk_product_type = 1"; } elseif (!isModEnabled('service')) { // when service module is disabled, show products only @@ -2718,21 +2734,21 @@ class Form if ($i > 0) { $sql .= " AND "; } - $sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= "(p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pl.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql .= " OR pcp.ref_customer LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) { - $sql .= " OR p.description LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR p.description LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pl.description LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } } if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } $sql .= ")"; $i++; @@ -2741,12 +2757,12 @@ class Form $sql .= ")"; } if (isModEnabled('barcode')) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; } $sql .= ')'; } if (count($warehouseStatusArray)) { - $sql .= " GROUP BY ".$selectFields; + $sql .= " GROUP BY " . $selectFields; } //Sort by category @@ -2761,23 +2777,23 @@ class Form $sql .= $this->db->plimit($limit, 0); // Build output string - dol_syslog(get_class($this)."::select_produits_list search products", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_list search products", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; $num = $this->db->num_rows($result); $events = null; if (!$forcecombo) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT")); } - $out .= ''; $textifempty = ''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. @@ -2794,7 +2810,7 @@ class Form } } if ($showempty) { - $out .= ''; + $out .= ''; } $i = 0; @@ -2805,11 +2821,11 @@ class Form if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) { // Price by quantity will return many prices for the same product $sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type"; - $sql .= " FROM ".$this->db->prefix()."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".((int) $objp->price_rowid); + $sql .= " FROM " . $this->db->prefix() . "product_price_by_qty"; + $sql .= " WHERE fk_product_price = " . ((int) $objp->price_rowid); $sql .= " ORDER BY quantity ASC"; - dol_syslog(get_class($this)."::select_produits_list search prices by qty", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_list search prices by qty", LOG_DEBUG); $result2 = $this->db->query($sql); if ($result2) { $nb_prices = $this->db->num_rows($result2); @@ -2847,7 +2863,7 @@ class Form $price_product = new Product($this->db); $price_product->fetch($objp->rowid, '', '', 1); - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($price_product); if ($price_result >= 0) { @@ -2891,15 +2907,15 @@ class Form * This define value for &$opt and &$optJson. * This function is called by select_produits_list(). * - * @param object $objp Resultset of fetch - * @param string $opt Option (var used for returned value in string option format) - * @param string $optJson Option (var used for returned value in json format) - * @param int $price_level Price level - * @param string $selected Preselected value - * @param int $hidepriceinlabel Hide price in label - * @param string $filterkey Filter key to highlight - * @param int $novirtualstock Do not load virtual stock, even if slow option STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO is on. - * @return void + * @param object $objp Resultset of fetch + * @param string $opt Option (var used for returned value in string option format) + * @param string $optJson Option (var used for returned value in json format) + * @param int $price_level Price level + * @param string $selected Preselected value + * @param int $hidepriceinlabel Hide price in label + * @param string $filterkey Filter key to highlight + * @param int $novirtualstock Do not load virtual stock, even if slow option STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO is on. + * @return void */ protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { @@ -2930,7 +2946,7 @@ class Form $label = $objp->label_translated; } if (!empty($filterkey) && $filterkey != '') { - $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $label, 1); + $label = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '$1', $label, 1); } $outkey = $objp->rowid; @@ -2947,36 +2963,36 @@ class Form $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; - $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; - $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; + $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; + $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : ''; if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; } // Units $outvalUnits = ''; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; + $outvalUnits .= ' - ' . $objp->unit_short; } } if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { if (!empty($objp->weight) && $objp->weight_units !== null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->surface) && $objp->surface_units !== null) { $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->volume) && $objp->volume_units !== null) { $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } } if ($outdurationvalue && $outdurationunit) { @@ -2988,14 +3004,14 @@ class Form 'y' => $langs->trans('Year') ); if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ? 's' : '')); } } - $opt = '\n"; $optJson = array( - 'key'=>$outkey, - 'value'=>$outref, - 'label'=>$outval, - 'label2'=>$outlabel, - 'desc'=>$outdesc, - 'type'=>$outtype, - 'price_ht'=>price2num($outprice_ht), - 'price_ttc'=>price2num($outprice_ttc), - 'price_ht_locale'=>price(price2num($outprice_ht)), - 'price_ttc_locale'=>price(price2num($outprice_ttc)), - 'pricebasetype'=>$outpricebasetype, - 'tva_tx'=>$outtva_tx, - 'default_vat_code'=>$outdefault_vat_code, - 'qty'=>$outqty, - 'discount'=>$outdiscount, - 'duration_value'=>$outdurationvalue, - 'duration_unit'=>$outdurationunit, - 'pbq'=>$outpbq, - 'labeltrans'=>$outlabel_translated, - 'desctrans'=>$outdesc_translated, - 'ref_customer'=>$outrefcust + 'key' => $outkey, + 'value' => $outref, + 'label' => $outval, + 'label2' => $outlabel, + 'desc' => $outdesc, + 'type' => $outtype, + 'price_ht' => price2num($outprice_ht), + 'price_ttc' => price2num($outprice_ttc), + 'price_ht_locale' => price(price2num($outprice_ht)), + 'price_ttc_locale' => price(price2num($outprice_ttc)), + 'pricebasetype' => $outpricebasetype, + 'tva_tx' => $outtva_tx, + 'default_vat_code' => $outdefault_vat_code, + 'qty' => $outqty, + 'discount' => $outdiscount, + 'duration_value' => $outdurationvalue, + 'duration_unit' => $outdurationunit, + 'pbq' => $outpbq, + 'labeltrans' => $outlabel_translated, + 'desctrans' => $outdesc_translated, + 'ref_customer' => $outrefcust ); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) + * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * - * @param int $socid Id third party - * @param string $selected Preselected product - * @param string $htmlname Name of HTML Select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param string $filtre For a SQL filter - * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $hidelabel Hide label (0=no, 1=yes) - * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices - * @param string $morecss More CSS - * @param string $placeholder Placeholder - * @return void + * @param int $socid Id third party + * @param string $selected Preselected product + * @param string $htmlname Name of HTML Select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre For a SQL filter + * @param array $ajaxoptions Options for ajax_autocompleter + * @param int $hidelabel Hide label (0=no, 1=yes) + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss More CSS + * @param string $placeholder Placeholder + * @return void */ public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '', $placeholder = '') { @@ -3244,7 +3261,7 @@ class Form $selected_input_value = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { if ($selected > 0) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); $selected_input_value = $producttmpselect->ref; @@ -3252,33 +3269,34 @@ class Form } // mode=2 means suppliers products - $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=2&status=' . $status . '&finished=' . $finished . '&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice; + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); - print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').''; + print ($hidelabel ? '' : $langs->trans("RefOrLabel") . ' : ') . ''; } else { print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder); } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of suppliers products + * Return list of suppliers products * - * @param int $socid Id of supplier thirdparty (0 = no filter) - * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') - * @param string $htmlname Name of HTML select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param string $filtre Generic filter. Data must not come from user input. - * @param string $filterkey Filter of produdts - * @param int $statut -1=Return all products, 0=Products not on buy, 1=Products on buy - * @param int $outputmode 0=HTML select string, 1=Array - * @param int $limit Limit of line number - * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices - * @param string $morecss Add more CSS - * @param int $showstockinlist Show stock information (slower). - * @param string $placeholder Placeholder - * @return array|string Array of keys for json or HTML component + * @param int $socid Id of supplier thirdparty (0 = no filter) + * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') + * @param string $htmlname Name of HTML select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre Generic filter. Data must not come from user input. + * @param string $filterkey Filter of produdts + * @param int $statut -1=Return all products, 0=Products not on buy, 1=Products on buy + * @param int $outputmode 0=HTML select string, 1=Array + * @param int $limit Limit of line number + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss Add more CSS + * @param int $showstockinlist Show stock information (slower). + * @param string $placeholder Placeholder + * @return array|string Array of keys for json or HTML component */ public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0, $placeholder = '') { @@ -3314,25 +3332,25 @@ class Form if (isModEnabled('barcode')) { $sql .= ", pfp.barcode"; } - $sql .= " FROM ".$this->db->prefix()."product as p"; - $sql .= " LEFT JOIN ".$this->db->prefix()."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; + $sql .= " FROM " . $this->db->prefix() . "product as p"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" . getEntity('product') . ") )"; if ($socid > 0) { - $sql .= " AND pfp.fk_soc = ".((int) $socid); + $sql .= " AND pfp.fk_soc = " . ((int) $socid); } - $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON pfp.fk_soc = s.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON pfp.fk_soc = s.rowid"; // Units if (getDolGlobalInt('PRODUCT_USE_UNITS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_units u ON u.rowid = p.fk_unit"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_units u ON u.rowid = p.fk_unit"; } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; + $sql .= " WHERE p.entity IN (" . getEntity('product') . ")"; if ($statut != -1) { - $sql .= " AND p.tobuy = ".((int) $statut); + $sql .= " AND p.tobuy = " . ((int) $statut); } if (strval($filtertype) != '') { - $sql .= " AND p.fk_product_type = ".((int) $filtertype); + $sql .= " AND p.fk_product_type = " . ((int) $filtertype); } if (!empty($filtre)) { - $sql .= " ".$filtre; + $sql .= " " . $filtre; } // Add where from hooks $parameters = array(); @@ -3352,9 +3370,9 @@ class Form if ($i > 0) { $sql .= " AND "; } - $sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= "(pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { - $sql .= " OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } $sql .= ")"; $i++; @@ -3363,8 +3381,8 @@ class Form $sql .= ")"; } if (isModEnabled('barcode')) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; + $sql .= " OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; } $sql .= ')'; } @@ -3373,20 +3391,20 @@ class Form // Build output string - dol_syslog(get_class($this)."::select_produits_fournisseurs_list", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_fournisseurs_list", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; $num = $this->db->num_rows($result); //$out.=''; + $out .= ''; + $form = ''; + print ''; + print ''; + print ''; + $out .= ''; + $out .= ''; if ($user->admin && empty($noinfoadmin)) { - $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - $out.= ajax_combobox($htmlname); + $out .= ajax_combobox($htmlname); if ($deposit_percent >= 0) { - $out .= '
' . "\n"; if (empty($disableformtag)) { $formconfirm .= "\n"; @@ -5408,7 +5437,7 @@ class Form if (!empty($conf->use_javascript_ajax)) { $formconfirm .= ''; - $formconfirm .= ''."\n"; + $formconfirm .= '' . "\n"; } $formconfirm .= "\n"; @@ -5431,28 +5460,29 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show a form to select a project * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id pre-selected project - * @param string $htmlname Name of select field - * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable) - * @param int $maxlength Max length - * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $nooutput No print is done. String is returned. - * @param string $textifnoproject Text to show if no project - * @param string $morecss More CSS - * @return string Return html content + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id pre-selected project + * @param string $htmlname Name of select field + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable) + * @param int $maxlength Max length + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $nooutput No print is done. String is returned. + * @param string $textifnoproject Text to show if no project + * @param string $morecss More CSS + * @return string Return html content */ public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject = '', $morecss = '') { // phpcs:enable global $langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; $out = ''; @@ -5460,11 +5490,11 @@ class Form $langs->load("project"); if ($htmlname != "none") { - $out .= '
'; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1, 0, $morecss); - $out .= ''; + $out .= ''; $out .= '
'; } else { $out .= ''; @@ -5473,7 +5503,7 @@ class Form $projet->fetch($selected); $out .= $projet->getNomUrl(0, '', 1); } else { - $out .= ''.$textifnoproject.''; + $out .= '' . $textifnoproject . ''; } $out .= ''; } @@ -5486,20 +5516,21 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Show a form to select payment conditions + * Show a form to select payment conditions * - * @param int $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Name of select html field - * @param int $addempty Add empty entry - * @param string $type Type ('direct-debit' or 'bank-transfer') - * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) - * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) - * 0 : use default deposit percentage from entry - * > 0 : force deposit percentage (for example, from company object) - * @param int $nooutput No print is done. String is returned. - * @return string HTML output or '' + * @param int $page Page + * @param string $selected Id condition pre-selectionne + * @param string $htmlname Name of select html field + * @param int $addempty Add empty entry + * @param string $type Type ('direct-debit' or 'bank-transfer') + * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) + * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * 0 : use default deposit percentage from entry + * > 0 : force deposit percentage (for example, from company object) + * @param int $nooutput No print is done. String is returned. + * @return string HTML output or '' */ public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '', $filtertype = -1, $deposit_percent = -1, $nooutput = 0) { @@ -5509,14 +5540,14 @@ class Form $out = ''; if ($htmlname != "none") { - $out .= '
'; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; if ($type) { - $out .= ''; + $out .= ''; } $out .= $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, 0, '', $deposit_percent); - $out .= ''; + $out .= ''; $out .= '
'; } else { if ($selected) { @@ -5546,26 +5577,27 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show a form to select a delivery delay * - * @param int $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Name of select html field - * @param int $addempty Ajoute entree vide - * @return void + * @param int $page Page + * @param string $selected Id condition pre-selectionne + * @param string $htmlname Name of select html field + * @param int $addempty Ajoute entree vide + * @return void */ public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) { // phpcs:enable global $langs; if ($htmlname != "none") { - print '
'; + print ''; print ''; - print ''; + print ''; $this->selectAvailabilityDelay($selected, $htmlname, -1, $addempty); - print ''; - print ''; + print ''; + print ''; print '
'; } else { if ($selected) { @@ -5581,21 +5613,21 @@ class Form * Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) * List found into table c_input_reason loaded by loadCacheInputReason * - * @param string $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Name of select html field - * @param int $addempty Add empty entry - * @return void + * @param string $page Page + * @param string $selected Id condition pre-selectionne + * @param string $htmlname Name of select html field + * @param int $addempty Add empty entry + * @return void */ public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) { global $langs; if ($htmlname != "none") { - print '
'; + print ''; print ''; - print ''; + print ''; $this->selectInputReason($selected, $htmlname, -1, $addempty); - print ''; + print ''; print '
'; } else { if ($selected) { @@ -5613,18 +5645,19 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show a form + html select a date * - * @param string $page Page - * @param string $selected Date preselected - * @param string $htmlname Html name of date input fields or 'none' - * @param int $displayhour Display hour selector - * @param int $displaymin Display minutes selector - * @param int $nooutput 1=No print output, return string - * @param string $type 'direct-debit' or 'bank-transfer' - * @return string - * @see selectDate() + * @param string $page Page + * @param string $selected Date preselected + * @param string $htmlname Html name of date input fields or 'none' + * @param int $displayhour Display hour selector + * @param int $displaymin Display minutes selector + * @param int $nooutput 1=No print output, return string + * @param string $type 'direct-debit' or 'bank-transfer' + * @return string + * @see selectDate() */ public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type = '') { @@ -5634,17 +5667,17 @@ class Form $ret = ''; if ($htmlname != "none") { - $ret .= '
'; - $ret .= ''; - $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; if ($type) { - $ret .= ''; + $ret .= ''; } $ret .= ''; $ret .= ''; - $ret .= ''; + $ret .= ''; $ret .= '
'; - $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); + $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form' . $htmlname, 1, 0); $ret .= '
'; } else { if ($displayhour) { @@ -5662,15 +5695,16 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show a select form to choose a user * - * @param string $page Page - * @param string $selected Id of user preselected - * @param string $htmlname Name of input html field. If 'none', we just output the user link. - * @param array $exclude List of users id to exclude - * @param array $include List of users id to include - * @return void + * @param string $page Page + * @param string $selected Id of user preselected + * @param string $htmlname Name of input html field. If 'none', we just output the user link. + * @param array $exclude List of users id to exclude + * @param array $include List of users id to include + * @return void */ public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') { @@ -5678,15 +5712,15 @@ class Form global $langs; if ($htmlname != "none") { - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; print $this->select_dolusers($selected, $htmlname, 1, $exclude, 0, $include); - print ''; + print ''; print '
'; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; $theuser = new User($this->db); $theuser->fetch($selected); print $theuser->getNomUrl(1); @@ -5698,18 +5732,19 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show form with payment mode * - * @param string $page Page - * @param int $selected Id mode pre-selectionne - * @param string $htmlname Name of select html field - * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) - * @param int $active Active or not, -1 = all - * @param int $addempty 1=Add empty entry - * @param string $type Type ('direct-debit' or 'bank-transfer') - * @param int $nooutput 1=Return string, no output - * @return string HTML output or '' + * @param string $page Page + * @param int $selected Id mode pre-selectionne + * @param string $htmlname Name of select html field + * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) + * @param int $active Active or not, -1 = all + * @param int $addempty 1=Add empty entry + * @param string $type Type ('direct-debit' or 'bank-transfer') + * @param int $nooutput 1=Return string, no output + * @return string HTML output or '' */ public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0, $type = '', $nooutput = 0) { @@ -5718,14 +5753,14 @@ class Form $out = ''; if ($htmlname != "none") { - $out .= '
'; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; if ($type) { - $out .= ''; + $out .= ''; } $out .= $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active, '', 1); - $out .= ''; + $out .= ''; $out .= '
'; } else { if ($selected) { @@ -5747,22 +5782,22 @@ 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 + * @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 ''; - print ''; + print ''; $this->selectTransportMode($selected, $htmlname, 0, $addempty, 0, 0, $active); - print ''; + print ''; print '
'; } else { if ($selected) { @@ -5775,24 +5810,25 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show form with multicurrency code * - * @param string $page Page - * @param string $selected code pre-selectionne - * @param string $htmlname Name of select html field - * @return void + * @param string $page Page + * @param string $selected code pre-selectionne + * @param string $htmlname Name of select html field + * @return void */ public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') { // phpcs:enable global $langs; if ($htmlname != "none") { - print '
'; + print ''; print ''; - print ''; + print ''; print $this->selectMultiCurrency($selected, $htmlname, 0); - print ''; + print ''; print '
'; } else { dol_include_once('/core/lib/company.lib.php'); @@ -5801,14 +5837,15 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show form with multicurrency rate * - * @param string $page Page - * @param double $rate Current rate - * @param string $htmlname Name of select html field - * @param string $currency Currency code to explain the rate - * @return void + * @param string $page Page + * @param double $rate Current rate + * @param string $htmlname Name of select html field + * @param string $currency Currency code to explain the rate + * @return void */ public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') { @@ -5816,21 +5853,21 @@ class Form global $langs, $mysoc, $conf; if ($htmlname != "none") { - print '
'; + print ''; print ''; - print ''; - print ' '; + print ''; + print ' '; print ' '; - print ''; + print ''; print '
'; } else { if (!empty($rate)) { print price($rate, 1, $langs, 1, 0); if ($currency && $rate != 1) { - print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; + print '   (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')'; } } else { print 1; @@ -5840,29 +5877,30 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Show a select box with available absolute discounts + * Show a select box with available absolute discounts * - * @param string $page Page URL where form is shown - * @param int $selected Value pre-selected - * @param string $htmlname Name of SELECT component. If 'none', not changeable. Example 'remise_id'. - * @param int $socid Third party id - * @param float $amount Total amount available - * @param string $filter SQL filter on discounts - * @param int $maxvalue Max value for lines that can be selected - * @param string $more More string to add - * @param int $hidelist 1=Hide list - * @param int $discount_type 0 => customer discount, 1 => supplier discount - * @return void + * @param string $page Page URL where form is shown + * @param int $selected Value pre-selected + * @param string $htmlname Name of SELECT component. If 'none', not changeable. Example 'remise_id'. + * @param int $socid Third party id + * @param float $amount Total amount available + * @param string $filter SQL filter on discounts + * @param int $maxvalue Max value for lines that can be selected + * @param string $more More string to add + * @param int $hidelist 1=Hide list + * @param int $discount_type 0 => customer discount, 1 => supplier discount + * @return void */ public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) { // phpcs:enable global $conf, $langs; if ($htmlname != "none") { - print '
'; + print ''; print ''; - print ''; + print ''; print '
'; if (!empty($discount_type)) { if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -5900,24 +5938,24 @@ class Form print '
'; if (empty($hidelist)) { print '
'; - $newfilter = 'discount_type='.intval($discount_type); + $newfilter = 'discount_type=' . intval($discount_type); if (!empty($discount_type)) { $newfilter .= ' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL'; // Supplier discounts available } else { $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available } if ($filter) { - $newfilter .= ' AND ('.$filter.')'; + $newfilter .= ' AND (' . $filter . ')'; } // output the combo of discounts $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); if ($nbqualifiedlines > 0) { - print '   '; @@ -5941,14 +5979,15 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Show forms to select a contact * - * @param string $page Page - * @param Societe $societe Filter on third party - * @param int $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML select. If 'none', we just show contact link. - * @return void + * @param string $page Page + * @param Societe $societe Filter on third party + * @param int $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML select. If 'none', we just show contact link. + * @return void */ public function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') { @@ -5956,23 +5995,23 @@ class Form global $langs, $conf; if ($htmlname != "none") { - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print '
'; print $this->selectcontacts($societe->id, $selected, $htmlname); $num = $this->num; if ($num == 0) { $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - print ''.$addcontact.''; + print '' . $addcontact . ''; } print '
'; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $contact = new Contact($this->db); $contact->fetch($selected); print $contact->getFullName($langs); @@ -5983,21 +6022,22 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Output html select to select thirdparty * - * @param string $page Page - * @param string $selected Id preselected - * @param string $htmlname Name of HTML select - * @param string $filter Optional filters criteras. Do not use a filter coming from input of users. - * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box - * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param int $nooutput No print output. Return it only. - * @param array $excludeids Exclude IDs from the select combo - * @param string $textifnothirdparty Text to show if no thirdparty - * @return string HTML output or '' + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select + * @param string $filter Optional filters criteras. Do not use a filter coming from input of users. + * @param int $showempty Add an empty field + * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $forcecombo Force to use combo box + * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param int $nooutput No print output. Return it only. + * @param array $excludeids Exclude IDs from the select combo + * @param string $textifnothirdparty Text to show if no thirdparty + * @return string HTML output or '' */ public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty = '') { @@ -6006,20 +6046,20 @@ class Form $out = ''; if ($htmlname != "none") { - $out .= '
'; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0, 'minwidth100', '', '', 1, array(), false, $excludeids); - $out .= ''; + $out .= ''; $out .= '
'; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $soc = new Societe($this->db); $soc->fetch($selected); $out .= $soc->getNomUrl(0, ''); } else { - $out .= ''.$textifnothirdparty.''; + $out .= '' . $textifnothirdparty . ''; } } @@ -6033,13 +6073,14 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Retourne la liste des devises, dans la langue de l'utilisateur * - * @param string $selected preselected currency code - * @param string $htmlname name of HTML select list - * @deprecated - * @return void + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list + * @deprecated + * @return void */ public function select_currency($selected = '', $htmlname = 'currency_id') { @@ -6050,11 +6091,11 @@ class Form /** * Retourne la liste des devises, dans la langue de l'utilisateur * - * @param string $selected preselected currency code - * @param string $htmlname name of HTML select list - * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code - * @param string $useempty '1'=Allow empty value - * @return string + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list + * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code + * @param string $useempty '1'=Allow empty value + * @return string */ public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0, $useempty = '') { @@ -6068,22 +6109,22 @@ class Form $selected = 'EUR'; // Pour compatibilite } - $out .= ''; if ($useempty) { $out .= ''; } foreach ($langs->cache_currencies as $code_iso => $currency) { $labeltoshow = $currency['label']; if ($mode == 1) { - $labeltoshow .= ' ('.$code_iso.')'; + $labeltoshow .= ' (' . $code_iso . ')'; } else { - $labeltoshow .= ' ('.$langs->getCurrencySymbol($code_iso).')'; + $labeltoshow .= ' (' . $langs->getCurrencySymbol($code_iso) . ')'; } if ($selected && $selected == $code_iso) { - $out .= ''; @@ -6094,23 +6135,23 @@ class Form } // Make select dynamic - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); return $out; } /** - * Return array of currencies in user language + * Return array of currencies in user language * - * @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 - * @param string $morecss More css - * @return string + * @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 + * @param string $morecss More css + * @return string */ public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0, $filter = '', $excludeConfCurrency = false, $morecss = '') { @@ -6120,10 +6161,10 @@ class Form $TCurrency = array(); - $sql = "SELECT code FROM ".$this->db->prefix()."multicurrency"; - $sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; + $sql = "SELECT code FROM " . $this->db->prefix() . "multicurrency"; + $sql .= " WHERE entity IN ('" . getEntity('mutlicurrency') . "')"; if ($filter) { - $sql .= " AND ".$filter; + $sql .= " AND " . $filter; } $resql = $this->db->query($sql); if ($resql) { @@ -6133,7 +6174,7 @@ class Form } $out = ''; - $out .= ''; if ($useempty) { $out .= ''; } @@ -6145,13 +6186,13 @@ class Form foreach ($langs->cache_currencies as $code_iso => $currency) { if (isset($TCurrency[$code_iso])) { if (!empty($selected) && $selected == $code_iso) { - $out .= ''; } } @@ -6160,18 +6201,19 @@ class Form $out .= ''; // Make select dynamic - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); return $out; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Load into the cache vat rates of a country * - * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'") - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'") + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ public function load_cache_vatrates($country_code) { @@ -6186,10 +6228,10 @@ class Form dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; - $sql .= " FROM ".$this->db->prefix()."c_tva as t, ".$this->db->prefix()."c_country as c"; + $sql .= " FROM " . $this->db->prefix() . "c_tva as t, " . $this->db->prefix() . "c_country as c"; $sql .= " WHERE t.fk_pays = c.rowid"; $sql .= " AND t.active > 0"; - $sql .= " AND c.code IN (".$this->db->sanitize($country_code, 1).")"; + $sql .= " AND c.code IN (" . $this->db->sanitize($country_code, 1) . ")"; $sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC"; $resql = $this->db->query($sql); @@ -6198,65 +6240,66 @@ class Form if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $this->db->fetch_object($resql); - $this->cache_vatrates[$i]['rowid'] = $obj->rowid; + $this->cache_vatrates[$i]['rowid'] = $obj->rowid; $this->cache_vatrates[$i]['code'] = $obj->code; - $this->cache_vatrates[$i]['txtva'] = $obj->taux; + $this->cache_vatrates[$i]['txtva'] = $obj->taux; $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; - $this->cache_vatrates[$i]['localtax1'] = $obj->localtax1; - $this->cache_vatrates[$i]['localtax1_type'] = $obj->localtax1_type; - $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; - $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; + $this->cache_vatrates[$i]['localtax1'] = $obj->localtax1; + $this->cache_vatrates[$i]['localtax1_type'] = $obj->localtax1_type; + $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; + $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; - $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or * - $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1 ? $obj->localtax1 : '0').'/'.($obj->localtax2 ? $obj->localtax2 : '0').($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label + $this->cache_vatrates[$i]['label'] = $obj->taux . '%' . ($obj->code ? ' (' . $obj->code . ')' : ''); // Label must contains only 0-9 , . % or * + $this->cache_vatrates[$i]['labelallrates'] = $obj->taux . '/' . ($obj->localtax1 ? $obj->localtax1 : '0') . '/' . ($obj->localtax2 ? $obj->localtax2 : '0') . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label $positiverates = ''; if ($obj->taux) { - $positiverates .= ($positiverates ? '/' : '').$obj->taux; + $positiverates .= ($positiverates ? '/' : '') . $obj->taux; } if ($obj->localtax1) { - $positiverates .= ($positiverates ? '/' : '').$obj->localtax1; + $positiverates .= ($positiverates ? '/' : '') . $obj->localtax1; } if ($obj->localtax2) { - $positiverates .= ($positiverates ? '/' : '').$obj->localtax2; + $positiverates .= ($positiverates ? '/' : '') . $obj->localtax2; } if (empty($positiverates)) { $positiverates = '0'; } - $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label + $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label } return $num; } else { - $this->error = ''.$langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code).''; + $this->error = '' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code) . ''; return -1; } } else { - $this->error = ''.$this->db->error().''; + $this->error = '' . $this->db->error() . ''; return -2; } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Output an HTML select vat rate. * The name of this function should be selectVat. We keep bad name for compatibility purpose. * - * @param string $htmlname Name of HTML select field - * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. - * @param Societe $societe_vendeuse Thirdparty seller - * @param Societe $societe_acheteuse Thirdparty buyer - * @param int $idprod Id product. O if unknown of NA. - * @param int $info_bits Miscellaneous information on line (1 for NPR) - * @param int|string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) - * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. - * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - * Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle. - * Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle. - * Sinon la TVA proposee par defaut=0. Fin de regle. - * @param bool $options_only Return HTML options lines only (for ajax treatment) - * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key - * @return string + * @param string $htmlname Name of HTML select field + * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. + * @param Societe $societe_vendeuse Thirdparty seller + * @param Societe $societe_acheteuse Thirdparty buyer + * @param int $idprod Id product. O if unknown of NA. + * @param int $info_bits Miscellaneous information on line (1 for NPR) + * @param int|string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) + * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + * Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle. + * Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle. + * Sinon la TVA proposee par defaut=0. Fin de regle. + * @param bool $options_only Return HTML options lines only (for ajax treatment) + * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key + * @return string */ public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) { @@ -6282,9 +6325,9 @@ class Form // Check parameters if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) { if ($societe_vendeuse->id == $mysoc->id) { - $return .= ''.$langs->trans("ErrorYourCountryIsNotDefined").''; + $return .= '' . $langs->trans("ErrorYourCountryIsNotDefined") . ''; } else { - $return .= ''.$langs->trans("ErrorSupplierCountryIsNotDefined").''; + $return .= '' . $langs->trans("ErrorSupplierCountryIsNotDefined") . ''; } return $return; } @@ -6296,25 +6339,25 @@ class Form // Define list of countries to use to search VAT rates to show // First we defined code_country to use to find list if (is_object($societe_vendeuse)) { - $code_country = "'".$societe_vendeuse->country_code."'"; + $code_country = "'" . $societe_vendeuse->country_code . "'"; } else { - $code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente + $code_country = "'" . $mysoc->country_code . "'"; // Pour compatibilite ascendente } if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { // If option to have vat for end customer for services is on - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) { // We also add the buyer country code if (is_numeric($type)) { if ($type == 1) { // We know product is a service - $code_country .= ",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'" . $societe_acheteuse->country_code . "'"; } } elseif (!$idprod) { // We don't know type of product - $code_country .= ",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'" . $societe_acheteuse->country_code . "'"; } else { $prodstatic = new Product($this->db); $prodstatic->fetch($idprod); if ($prodstatic->type == Product::TYPE_SERVICE) { // We know product is a service - $code_country .= ",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'" . $societe_acheteuse->country_code . "'"; } } } @@ -6366,13 +6409,13 @@ class Form // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses instead // of using supplier invoices (this is a very bad idea !) if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT)) { - $title = ' title="'.dol_escape_htmltag($langs->trans('VATIsNotUsed')).'"'; + $title = ' title="' . dol_escape_htmltag($langs->trans('VATIsNotUsed')) . '"'; $disabled = true; } } if (!$options_only) { - $return .= ''; } $selectedfound = false; @@ -6386,13 +6429,13 @@ class Form $key = $rate['txtva']; $key .= $rate['nprtva'] ? '*' : ''; if ($mode > 0 && $rate['code']) { - $key .= ' ('.$rate['code'].')'; + $key .= ' (' . $rate['code'] . ')'; } if ($mode < 0) { $key = $rate['rowid']; } - $return .= '
'; - $retstring .= ''."\n"; - $retstring .= ''."\n"; - $retstring .= ''."\n"; + $retstring .= '' . "\n"; + $retstring .= '' . "\n"; + $retstring .= '' . "\n"; } else { $retstring .= "Bad value of MAIN_POPUP_CALENDAR"; } } else { // Show date with combo selects // Day - $retstring .= ''; + $retstring .= ''; if ($emptydate || $set_time == -1) { $retstring .= ''; } for ($day = 1; $day <= 31; $day++) { - $retstring .= ''; + $retstring .= ''; } $retstring .= ""; - $retstring .= ''; + $retstring .= ''; if ($emptydate || $set_time == -1) { $retstring .= ''; } // Month for ($month = 1; $month <= 12; $month++) { - $retstring .= '"; } @@ -6743,12 +6787,12 @@ class Form // Year if ($emptydate || $set_time == -1) { - $retstring .= ''; + $retstring .= ''; } else { - $retstring .= ''; + $retstring .= ''; for ($year = $syear - 10; $year < $syear + 10; $year++) { - $retstring .= ''; + $retstring .= ''; } $retstring .= "\n"; } @@ -6772,15 +6816,15 @@ class Form } } // Show hour - $retstring .= ''; + $retstring .= ''; if ($emptyhours) { $retstring .= ''; } for ($hour = $hourstart; $hour < $hourend; $hour++) { if (strlen($hour) < 2) { - $hour = "0".$hour; + $hour = "0" . $hour; } - $retstring .= ''; } @@ -6793,19 +6837,19 @@ class Form if ($m) { // Show minutes - $retstring .= ''; + $retstring .= ''; if ($emptyhours) { $retstring .= ''; } for ($min = 0; $min < 60; $min += $stepminutes) { if (strlen($min) < 2) { - $min = "0".$min; + $min = "0" . $min; } - $retstring .= ''; + $retstring .= ''; } $retstring .= ''; - $retstring .= ''; + $retstring .= ''; } if ($d && $h) { @@ -6828,10 +6872,10 @@ class Form // Generate the date part, depending on the use or not of the javascript calendar if ($addnowlink == 1) { // server time expressed in user time setup - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');'; } elseif ($addnowlink == 2) { /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix. * This break application for foreign languages. @@ -6840,10 +6884,10 @@ class Form $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; */ - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');'; } /*if ($usecalendar == "eldy") { @@ -6863,11 +6907,11 @@ class Form } //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; if ($addnowlink == 1) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();'; } elseif ($addnowlink == 2) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();'; } if ($fullday) { @@ -6881,11 +6925,11 @@ class Form } //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; if ($addnowlink == 1) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();'; } elseif ($addnowlink == 2) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();'; } if ($fullday) { $reset_scripts .= ' } '; @@ -6893,7 +6937,7 @@ class Form } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick if ($reset_scripts && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $retstring .= ' '; } @@ -6905,16 +6949,16 @@ class Form $reset_scripts = ""; // Generate the date part, depending on the use or not of the javascript calendar - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');'; // Update the hour part if ($h) { if ($fullday) { $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; } - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');'; if ($fullday) { $reset_scripts .= ' } '; } @@ -6924,14 +6968,14 @@ class Form if ($fullday) { $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; } - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');'; + $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');'; if ($fullday) { $reset_scripts .= ' } '; } } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { - $retstring .= ' '; } @@ -6943,7 +6987,7 @@ class Form if (empty($labeladddateof)) { $labeladddateof = $langs->trans("DateInvoice"); } - $retstring .= ' -