diff --git a/ChangeLog b/ChangeLog index c592a261157..2d398c83535 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,7 +25,10 @@ Following changes may create regressions for some external modules, but were nec * The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE. * The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS. * If your logo was visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible agin in menu. - +* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'. +* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. +* All properties 'type_libelle' were renamed into 'type_label'. +* Renamed property of thirdparty "statut_commercial" into "status_prospect_label" ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. @@ -42,11 +45,11 @@ FIX: #12041 FIX: #12054 FIX: #12083 FIX: #12088 +FIX: CVE-2019-17578 CVE-2019-17577 CVE-2019-17576 FIX: Clean the + of categories on the product view only in POS module FIX: access to public interface when origin email has an alias. FIX: Alias name is not into the email recipient label. FIX: allow standalone credit note even if no invoice -FIX: an admin can not access his own permissions after enabling advanced FIX: an admin can not access his own permissions after enabling advanced permissions FIX: Attachement of linked files on ticket when sending a message FIX: avoid non numeric warning @@ -115,17 +118,17 @@ FIX: #11752 FIX: #11789 FIX: #11790 FIX: #11804 list of tickets from a customer card display ALL tickets FIX: #11834 -FIX: Add char $ and ; in sanitizing of filenames. -FIX: Add comment before protected functions -FIX: Add log and type of content in dolWebsiteOutput and -FIX: Add repair.php option 'restore' to restore user picture after v10 +FIX: add char $ and ; in sanitizing of filenames +FIX: add comment before protected functions +FIX: add log and type of content in dolWebsiteOutput and +FIX: add repair.php option 'restore' to restore user picture after v10 FIX: amount opened on thirdparty card dont care of credit note not converted -FIX: Api of documents work with value 'thirdparty' +FIX: API of documents work with value 'thirdparty' FIX: author in message / ticket API -FIX: avoid sql error if fk_project is empty during update +FIX: avoid SQL error if fk_project is empty during update FIX: avoid Warning: A non-numeric value encountered -FIX: bad consistency in list of invoice for direct debit order. -FIX: Bad error management in zip compress and web site export +FIX: bad consistency in list of invoice for direct debit order +FIX: bad error management in zip compress and web site export FIX: bad substitution for extrafields type checkbox FIX: better help message with multicompany FIX: calculation of $products_dispatched @@ -134,11 +137,11 @@ FIX: Can't delete a draft leave even if it should FIX: Can't save setup of mailman module FIX: column jabberid missing FIX: Confirmation of deletion -FIX: Consistency in direct debit order lists. +FIX: Consistency in direct debit order lists FIX: Content send before header warning FIX: credit note can be split FIX: credit note used on list -FIX: Css was saved on wrong website. +FIX: CSS was saved on wrong website FIX: delivery extrafields FIX: Disabling a website does not put it offline FIX: display only stripe sources for customer @@ -155,13 +158,13 @@ FIX: Fatal situation if payment removed on expense report. Action FIX: filepath of generated documents doesn't handle products with special characters FIX: for MAIN_MAXTABS_IN_CARD = $i card FIX: gzip and bzip2 must use option -f -FIX: It was possible to create cashfence without entering data. +FIX: it was possible to create cashfence without entering data FIX: javascript error when using dol_use_jmobile=1 FIX: logout redirect to takepos.php FIX: Look and feel v10 FIX: Make protected all pfd models functions FIX: management of extrafields in modulebuilder -FIX: Missing div for buttons in tax, loan, various payment modules +FIX: missing div for buttons in tax, loan, various payment modules FIX: missing include (dol_convert_file not found) FIX: Missing some replacements in website module FIX: missing test on permission on button to delete ledger record @@ -185,13 +188,13 @@ FIX: Return code of pdf_einstein.modules.php and proformat FIX: round for application fee in stripe FIX: Sens of the balance (Debit - Credit in accountancy not contrary) FIX: Several pb in export of documents -FIX: SQL syntax error and CSRF check on vat reports +FIX: SQL syntax error and CSRF check on VAT reports FIX: takepos layout clear or focus search -FIX: too many record in sql request. Whena criteria is a filter, we must +FIX: too many record in sql request. When a criteria is a filter, we must FIX: Translation of month FIX: USEDOLIBARREDITOR not always set FIX: VAT number for Monaco (it uses FR) -FIX: vulenrability in uploading file found by 美创科技安全实验室 +FIX: vulnerability in uploading file found by 美创科技安全实验室 FIX: wrong display (and hidden input) for already dispatched quantity FIX: wrong parameters (same error in branch 9, 10, develop) FIX: Wrong variable. Must be PROJECT_HIDE_UNSELECTABLES diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index e9703fbfd6e..83951c57df7 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -61,8 +61,8 @@ $user->getrights(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } + $num = $db->num_rows($resql); $i = 0; + while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index f1e0f4f360b..9f740b5705d 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -64,22 +64,34 @@ $user->getrights(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } + $num = $db->num_rows($resql); $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + $productsid[$i] = $row[0]; + $i++; + } } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; } + while ($i < $num) { + $row = $db->fetch_row($resql); + $societesid[$i] = $row[0]; + $i++; + } } else { print "err"; } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array(); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; } + while ($i < $num) { + $row = $db->fetch_row($resql); + $commandesid[$i] = $row[0]; + $i++; + } } else { print "err"; } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 8c01eea6d99..015733ed95f 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -186,7 +186,7 @@ - + diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 7f095a744db..f568ba2b04b 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -149,9 +149,9 @@ foreach ($langstrings_3d AS $filename => $file) $keys = array_keys($langstrings_full, $value); if (count($keys)>1) { - foreach ($keys AS $key) { - $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]); - } + foreach ($keys AS $key) { + $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]); + } } } } diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index bc8fff8395c..e34cd54863b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -46,7 +46,7 @@ $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); $search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha'); // Security check -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden(); // Load variable for pagination diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2f23cd3eae8..6f30f5ac7ec 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -71,7 +71,7 @@ $search_country_id = GETPOST('search_country_id', 'int'); // Security check -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden(); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 03404bd4126..5b1fa9df4ec 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -43,7 +43,7 @@ if (! $sortorder) $sortorder="ASC"; $langs->loadLangs(array("admin","compta")); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index d9125a686c6..42b9d231fe3 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $langs->loadLangs(array("admin","compta")); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (empty($user->rights->accounting->fiscalyear->write)) accessforbidden(); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index dd62352e2b1..a02141f449e 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $langs->loadLangs(array("admin","compta")); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->fiscalyear->write) accessforbidden(); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index cc6307bae2c..ca6403279e1 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -45,7 +45,7 @@ $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' $piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) // Security check -if ($user->societe_id > 0) { +if ($user->socid > 0) { accessforbidden(); } diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 4bc60fc904f..2ed9eb4c2bd 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -83,7 +83,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', // Security check $socid = GETPOST("socid", 'int'); -// if ($user->societe_id) $socid=$user->societe_id; +// if ($user->socid) $socid=$user->socid; $lettering = new Lettering($db); $object = new Societe($db); @@ -139,7 +139,7 @@ dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'com $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index df513f8d074..b381fc597ce 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -83,7 +83,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', // Security check $socid = GETPOST("socid", 'int'); -// if ($user->societe_id) $socid=$user->societe_id; +// if ($user->socid) $socid=$user->socid; $lettering = new Lettering($db); $object = new Societe($db); @@ -138,7 +138,7 @@ dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'com $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 21cbdeb9662..0cfc0d24826 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -638,11 +638,11 @@ class AccountingAccount extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -650,34 +650,33 @@ class AccountingAccount extends CommonObject if ($mode == 0) { - $prefix=''; - if ($statut == 1) return $langs->trans('Enabled'); - elseif ($statut == 0) return $langs->trans('Disabled'); + if ($status == 1) return $langs->trans('Enabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { - if ($statut == 1) return $langs->trans('Enabled'); - elseif ($statut == 0) return $langs->trans('Disabled'); + if ($status == 1) return $langs->trans('Enabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { - if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index b4e747d65f3..9e58ffed942 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1975,7 +1975,12 @@ class BookKeepingLine public $code_journal; public $journal_label; public $piece_num; + + /** + * @var integer|string date_creation + */ public $date_creation; + public $date_modification; public $date_export; } diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index ddf3b4cf2db..599742460ae 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -34,7 +34,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->fiscalyear->write) accessforbidden(); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 26b53009fcc..0498e5e2dec 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -34,7 +34,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->fiscalyear->write) accessforbidden(); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 00c4a945ff9..62ae458d283 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -38,7 +38,7 @@ $codeventil = GETPOST('codeventil'); $id = GETPOST('id'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index c0e45916922..b3ef45c1feb 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -39,7 +39,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 6a5196288e2..9d32bbaebf4 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -72,7 +72,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index d4cc5f59388..2969f2ff0a1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -83,7 +83,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 2331111f620..8ee9f9c625d 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -42,7 +42,7 @@ $codeventil = GETPOST('codeventil'); $id = GETPOST('id'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index ea855921c5a..4efc8a15ba4 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -36,7 +36,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index c50031b82b2..56f7ee6ba96 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -67,7 +67,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 1ec89dfc9cc..f0e545f7853 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -77,7 +77,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 0eeccbd3395..8dde1d0df22 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; $langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict")); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 7063f7fd53e..e8e1da09dd0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -80,7 +80,7 @@ $now = dol_now(); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->societe_id > 0 && empty($id_journal)) +if ($user->socid > 0 && empty($id_journal)) accessforbidden(); @@ -323,11 +323,11 @@ if ($result) { if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') $reg[1] = 'SocialContribution'; - $chargestatic->lib = $langs->trans($reg[1]); + $chargestatic->label = $langs->trans($reg[1]); } else { - $chargestatic->lib = $links[$key]['label']; + $chargestatic->label = $links[$key]['label']; } - $chargestatic->ref = $chargestatic->lib; + $chargestatic->ref = $chargestatic->label; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index c61cdda4d48..a80036b3b05 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -56,7 +56,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); /* diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index a3728c7f6f9..711a54f37a6 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -56,7 +56,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); $hookmanager->initHooks(array('purchasesjournal')); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 367fa2eb817..7781d612575 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -58,7 +58,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); $hookmanager->initHooks(array('sellsjournal')); diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 7e9d7fbbd7c..63bce528ccb 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -42,7 +42,7 @@ $codeventil = GETPOST('codeventil'); $id = GETPOST('id'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index bfb6e7b02e4..a1eb1ce4a45 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -37,7 +37,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy")); if (empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 730aecf9dc1..00ac4d02d73 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -74,7 +74,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 3c61b7a0608..27cd97dfea3 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -83,7 +83,7 @@ if (! $sortorder) { } // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->bind->write) accessforbidden(); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index ead5e767243..97392b902bc 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,7 +178,7 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) $listofval = array(-1 => $langs->trans("Undefined")); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; - print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listetype)>1?1:0); + print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); print "\n"; // Amount diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 9c6f657d5e0..51f121ad903 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -118,7 +118,7 @@ if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['act control->tpl['showend']; -if (empty($user->societe_id)) { +if (empty($user->socid)) { echo '
'; if ($user->rights->adherent->creer) { diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0f2cfc52840..76556feb4ee 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -983,7 +983,7 @@ else print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; + print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; // Address print ''.$langs->trans("Address").''; @@ -1020,13 +1020,13 @@ else } // Pro phone - print ''.$langs->trans("PhonePro").''; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; // Personal phone - print ''.$langs->trans("PhonePerso").''; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").''; // Mobile phone - print ''.$langs->trans("PhoneMobile").''; + print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; // Skype if (! empty($conf->socialnetworks->enabled)) @@ -1259,7 +1259,7 @@ else print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; + print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; // Address print ''.$langs->trans("Address").''; @@ -1289,13 +1289,13 @@ else } // Pro phone - print ''.$langs->trans("PhonePro").'phone).'">'; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'phone).'">'; // Personal phone - print ''.$langs->trans("PhonePerso").'phone_perso).'">'; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'phone_perso).'">'; // Mobile phone - print ''.$langs->trans("PhoneMobile").'phone_mobile).'">'; + print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'phone_mobile).'">'; // Skype if (! empty($conf->socialnetworks->enabled)) @@ -1885,7 +1885,7 @@ else } // Create user - if (! $user->societe_id && ! $object->user_id) + if (! $user->socid && ! $object->user_id) { if ($user->rights->user->user->creer) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index fbc62083b97..f7278f9007a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -174,7 +174,7 @@ class Adherent extends CommonObject // -1:brouillon, 0:resilie, >=1:valide,paye // def in common object - //public $statut; + //public $status; public $photo; @@ -2132,7 +2132,11 @@ class Adherent extends CommonObject // Only picto if ($withpictoimg > 0) $picto=''.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).''; // Picto must be a photo - else $picto=''.Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).''; + else { + $picto=''; + $picto.=Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1); + $picto.=''; + } $result.=$picto; } if ($withpictoimg > -2 && $withpictoimg != 2) @@ -2164,94 +2168,61 @@ class Adherent extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $need_subscription 1 if member type need subscription, 0 otherwise * @param int $date_end_subscription Date fin adhesion * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) + public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0) { // phpcs:enable global $langs; $langs->load("members"); - if ($mode == 0) + + $statusType = ''; + $labelStatus = ''; + $labelStatusShort = ''; + + if ($status == -1) { - if ($statut == -1) return $langs->trans("MemberStatusDraft"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActive"); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate"); - else return $langs->trans("MemberStatusPaid"); - } - elseif ($statut == 0) return $langs->trans("MemberStatusResiliated"); + $statusType = 'status0'; + $labelStatus = $langs->trans("MemberStatusDraft"); + $labelStatusShort = $langs->trans("MemberStatusDraftShort"); } - elseif ($mode == 1) + elseif ($status >= 1) { + if ($need_subscription == 0) + { + $statusType = 'status4'; + $labelStatus = $langs->trans("MemberStatusNoSubscription"); + $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); + } + elseif (! $date_end_subscription) + { + $statusType = 'status1'; + $labelStatus = $langs->trans("MemberStatusActive"); + $labelStatusShort = $langs->trans("MemberStatusActiveShort"); + } + elseif ($date_end_subscription < time()) + { + $statusType = 'status3'; + $labelStatus = $langs->trans("MemberStatusActiveLate"); + $labelStatusShort = $langs->trans("MemberStatusActiveLateShort"); + } + else { + $statusType = 'status4'; + $labelStatus = $langs->trans("MemberStatusPaid"); + $labelStatusShort = $langs->trans("MemberStatusPaidShort"); + } + } + elseif ($status == 0) { - if ($statut == -1) return $langs->trans("MemberStatusDraftShort"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActiveShort"); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLateShort"); - else return $langs->trans("MemberStatusPaidShort"); - } - elseif ($statut == 0) return $langs->trans("MemberStatusResiliatedShort"); - } - elseif ($mode == 2) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraftShort"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscriptionShort"); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActiveShort"); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLateShort"); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaidShort"); - } - elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliatedShort"); - } - elseif ($mode == 3) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); - } - elseif ($mode == 4) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraft"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActive"); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLate"); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaid"); - } - if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliated"); - } - elseif ($mode == 5) - { - if ($statut == -1) return ''.$langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - elseif ($statut >= 1) { - if ($need_subscription == 0) return ''.$langs->trans("MemberStatusNoSubscriptionShort").' '.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return ''.$langs->trans("MemberStatusPaidShort").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - if ($statut == 0) return ''.$langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); - } - elseif ($mode == 6) - { - if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - if ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription").' '.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return $langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - if ($statut == 0) return $langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); + $statusType = 'status6'; + $labelStatus = $langs->trans("MemberStatusResiliated"); + $labelStatusShort = $langs->trans("MemberStatusResiliatedShort"); } + + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9ef8e122c9b..1357e4a3b4b 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -70,7 +70,7 @@ class AdherentStats extends Stats $this->where.= " m.statut != 0"; $this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if($this->memberid) { $this->where .= " AND m.rowid = ".$this->memberid; @@ -92,7 +92,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; $sql.= " FROM ".$this->from; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; @@ -112,7 +112,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)"; $sql.= " FROM ".$this->from; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); @@ -133,7 +133,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; $sql.= " FROM ".$this->from; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 986649d15e2..e2fc13edadf 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -431,10 +431,10 @@ class Subscription extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @return string Label */ - public function LibStatut($statut) + public function LibStatut($status) { // phpcs:enable global $langs; diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 2dd8c95923f..84fc6bc9824 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -42,7 +42,7 @@ if (empty($sortorder)) { $sortorder="ASC"; } if (empty($sortfield)) { $sortfield="d.login"; } if (! isset($statut)) { - $statut = 1 ; + $statut = 1; } if (! isset($cotis)) @@ -54,7 +54,7 @@ if (! isset($cotis)) $sql = "SELECT d.login, d.pass, d.datefin"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d "; -$sql .= " WHERE d.statut = $statut "; +$sql .= " WHERE d.statut = ".$statut; if ($cotis==1) { $sql .= " AND datefin > '".$db->idate($now)."'"; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index b858693255e..a0dc9b81a86 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -61,7 +61,7 @@ $AdherentsResilies=array(); $AdherentType=array(); -// Members list +// Type of membership $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; $sql.= " d.statut, count(d.rowid) as somme"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; @@ -71,7 +71,7 @@ $sql.= " AND d.entity IN (".getEntity('adherent').")"; $sql.= " WHERE t.entity IN (".getEntity('member_type').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; -dol_syslog("index.php::select nb of members by type", LOG_DEBUG); +dol_syslog("index.php::select nb of members per type", LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -140,6 +140,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -152,6 +153,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print '
'; print '
'; } @@ -227,10 +229,8 @@ $sql = "SELECT c.subscription, c.dateadh as dateh"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.rowid = c.fk_adherent"; -if(isset($date_select) && $date_select != '') -{ - $sql .= " AND c.dateadh LIKE '".$date_select."%'"; -} + + $result = $db->query($sql); if ($result) { @@ -251,21 +251,33 @@ if ($result) print '
'; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; print "\n"; krsort($Total); +$i = 0; foreach ($Total as $key=>$value) { - print ''; + if ($i >= 8) + { + print ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + break; + } + print ''; print ""; print ""; print ""; print ""; print "\n"; + $i++; } // Total @@ -282,7 +294,7 @@ print "
\n"; print '
'; /* - * Last modified members + * Latest modified members */ $max=5; @@ -330,7 +342,7 @@ if ($resql) print '
'; print ''; print ''; - print ''; + print ''; print ''; $i++; } diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index fafa69b8b3f..99326241485 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -37,9 +37,9 @@ $action = GETPOST('action', 'aZ09'); // Protection $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $object = new Adherent($db); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 877dde34af0..0bcc11bf351 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -681,6 +681,7 @@ while ($i < min($num, $limit)) $memberstatic->datefin= $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; + $memberstatic->morphy = $obj->morphy; if (! empty($obj->fk_soc)) { $memberstatic->fetch_thirdparty(); diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index d954484c839..b2f302fea45 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -33,10 +33,10 @@ $mode=GETPOST('mode')?GETPOST('mode'):''; // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'adherent', '', '', 'cotisation'); diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index afc2e2b5218..3c469e658e5 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -34,10 +34,10 @@ $mode=GETPOST('mode')?GETPOST('mode'):''; // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'adherent', '', '', 'cotisation'); diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 2f2c6f33920..d89a8a4a8c0 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -35,10 +35,10 @@ $userid=GETPOST('userid', 'int'); if ($userid < 0) $userid=0; $socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'adherent', '', '', 'cotisation'); diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index ac9a269bf29..5a4f84868e1 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -41,7 +41,7 @@ $cancel=GETPOST('cancel', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // Security check $result=restrictedArea($user, 'adherent', $id, 'adherent_type'); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 57031a9822f..a209a5f5590 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -208,7 +208,7 @@ print ''; print ''; print "\n"; -$sql = "SELECT rowid, code as encoding, libelle, coder, example"; +$sql = "SELECT rowid, code as encoding, libelle as label, coder, example"; $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " ORDER BY code"; @@ -225,7 +225,7 @@ if ($resql) $obj = $db->fetch_object($resql); print '
'.$langs->trans("Subscriptions").''.$langs->trans("Number").''.$langs->trans("Year").''.$langs->trans("Subscriptions").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
...
$key".$Number[$key]."".price($value)."".price(price2num($value/$Number[$key], 'MT'))."
'.$staticmember->getNomUrl(1, 32).''.$statictype->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 5).''.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).'
'.$langs->trans("Example").''.$langs->trans("CodeBarGenerator").'
'; - print $obj->libelle; + print $obj->label; print "\n"; print $langs->trans('BarcodeDesc'.$obj->encoding); //print "L'EAN se compose de 8 caracteres, 7 chiffres plus une cle de controle.
"; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 26ea1b12a29..43f3fe0584a 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -183,16 +183,6 @@ elseif ($action == 'set_BOM_FREE_TEXT') { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action=="setshippableiconinlist") { - // Activate Set Shippable Icon In List - $setshippableiconinlist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SHIPPABLE_BOM_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } } @@ -314,244 +304,217 @@ foreach ($dirmodels as $reldir) print "

\n"; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +/* + * Document templates generators + */ + +print load_fiche_titre($langs->trans("BOMsModelModule"), '', ''); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) { - /* - * Document templates generators - */ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} - print load_fiche_titre($langs->trans("BOMsModelModule"), '', ''); - // Load array def with activated templates - $def = array(); - $sql = "SELECT nom"; - $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; - $resql=$db->query($sql); - if ($resql) +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) { - $i = 0; - $num_rows=$db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } - } - else - { - dol_print_error($db); - } + $dir = dol_buildpath($reldir."core/modules/bom".$valdir); - - print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
\n"; - print "\n"; - print ''; - print ''; - print '\n"; - print '\n"; - print ''; - print ''; - print "\n"; - - clearstatcache(); - - foreach ($dirmodels as $reldir) - { - foreach (array('','/doc') as $valdir) + if (is_dir($dir)) { - $dir = dol_buildpath($reldir."core/modules/bom".$valdir); - - if (is_dir($dir)) + $handle=opendir($dir); + if (is_resource($handle)) { - $handle=opendir($dir); - if (is_resource($handle)) + while (($file = readdir($handle))!==false) { - while (($file = readdir($handle))!==false) + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - $filelist[]=$file; - } - closedir($handle); - arsort($filelist); + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - foreach($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + require_once $dir.'/'.$file; + $module = new $classname($db); - require_once $dir.'/'.$file; - $module = new $classname($db); + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + if ($modulequalified) + { + $var = !$var; + print ''; - if ($modulequalified) - { - $var = !$var; - print ''; + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } - // Active - if (in_array($name, $def)) - { - print ''; - } - else - { - print '"; - } + // Default + print ''; - // Default - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip.='

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

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } + print "\n"; + } + } } } } } } - - print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print '
'; - print (empty($module->name)?$name:$module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'; + if ($conf->global->BOM_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - if ($conf->global->BOM_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } - else - { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; - print "
"; - - /* - * Other options - */ - - print load_fiche_titre($langs->trans("OtherOptions"), '', ''); - print ''; - print ''; - print ''; - print ''; - print "\n"; - print "\n"; - - $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); - $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); - $htmltext = ''.$langs->trans("AvailableVariables").':
'; - foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; - $htmltext.='
'; - - print ''; - print ''; - print ''; - print '\n"; - print ''; - - //Use draft Watermark - - print ""; - print ''; - print ""; - print '\n"; - print ''; - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; - print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; - $variablename='BOM_FREE_TEXT'; - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) - { - print ''; - } - else - { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); - } - print '
'; - print ''; - print "
'; - print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; - print '
'; - print ''; - print ''; - print ''; - print "
'; - print '
'; } +print ''; +print "
"; + /* - * Notifications + * Other options */ -/* -print load_fiche_titre($langs->trans("Notifications"), '', ''); + +print load_fiche_titre($langs->trans("OtherOptions"), '', ''); print ''; print ''; print ''; -print ''; -print ''; +print ''; +print "\n"; print "\n"; +$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + +print ''; +print ''; +print ''; print '\n"; +print ''; + +//Use draft Watermark + +print ""; +print ''; +print ""; +print '\n"; +print ''; print '
'.$langs->trans("Parameter").' '.$langs->trans("Value").' 
'; -print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; +$variablename='BOM_FREE_TEXT'; +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) +{ + print ''; +} +else +{ + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); +} print '
'; +print ''; print "
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; +print '
'; +print ''; +print ''; +print ''; +print "
'; -*/ +print '
'; + // End of page llxFooter(); diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 4f1fad15343..e5acf71857e 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -18,10 +18,10 @@ * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * -* @author PrestaShop SA -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice */ @@ -395,52 +395,6 @@ class PrestaShopWebservice self::checkStatusCode($request['status_code']);// check the response validity return self::parseXML($request['response']); } - - /** - * Delete (DELETE) a resource. - * Unique parameter must take :

- * 'resource' => Resource name
- * 'id' => ID or array which contains IDs of a resource(s) you want to delete

- * - * delete(array('resource' => 'orders', 'id' => 1)); - * // Following code will not be executed if an exception is thrown. - * echo 'Successfully deleted.'; - * } - * catch (PrestaShopWebserviceException $ex) - * { - * echo 'Error : '.$ex->getMessage(); - * } - * ?> - * - * - * @param array $options Array representing resource to delete. - * @return boolean True - */ - public function delete($options) - { - if (isset($options['url'])) { - $url = $options['url']; - } elseif (isset($options['resource']) && isset($options['id'])) { - if (is_array($options['id'])) - $url = $this->url.'/api/'.$options['resource'].'/?id=['.implode(',', $options['id']).']'; - else - $url = $this->url.'/api/'.$options['resource'].'/'.$options['id']; - } - if (isset($options['id_shop'])) { - $url .= '&id_shop='.$options['id_shop']; - } - if (isset($options['id_group_shop'])) { - $url .= '&id_group_shop='.$options['id_group_shop']; - } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE')); - self::checkStatusCode($request['status_code']);// check the response validity - return true; - } } /** diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index daa0c896809..04accc01bbf 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -75,8 +75,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); @@ -260,7 +260,7 @@ if ($action == 'create') { dol_fiche_head(array(), ''); - print ''."\n"; + print '
'."\n"; //unset($fields[]); @@ -296,7 +296,7 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
' . "\n"; + print '
' . "\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; @@ -448,7 +448,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; print '
'; - print '
'."\n"; + print '
'."\n"; // Common attributes //$keyforbreak='fieldkeytoswithonsecondcolumn'; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 09ba5f7224f..e8b2e280a7f 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -78,9 +78,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'emailcollector', $id, ''); diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 58f107dfdf5..adb54c7434f 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -71,9 +71,9 @@ if (! $sortorder) $sortorder="ASC"; // Protection if external user $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index de9d1677932..531e53ac459 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -129,7 +129,7 @@ foreach ($modulesdir as $dir) if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0; // We discard modules according to property disabled - if (! empty($objMod->hidden)) $modulequalified=0; + //if (! empty($objMod->hidden)) $modulequalified=0; if ($modulequalified > 0) { @@ -214,15 +214,17 @@ asort($orders); //var_dump($modules); +unset($objMod); $i=0; foreach($orders as $tmpkey => $tmpvalue) { - $objMod = $modules[$tmpkey]; - if ($objMod->numero == $id) + $tmpMod = $modules[$tmpkey]; + if ($tmpMod->numero == $id) { $key = $i; $modName = $filename[$tmpkey]; $dirofmodule = $dirmod[$tmpkey]; + $objMod = $tmpMod; break; } $i++; @@ -233,25 +235,7 @@ $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$ -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc'; -$head[$h][1] = $langs->trans("Description"); -$head[$h][2] = 'desc'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature'; -$head[$h][1] = $langs->trans("TechnicalServicesProvided"); -$head[$h][2] = 'feature'; -$h++; - -if ($objMod->isCoreOrExternalModule() == 'external') -{ - $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=changelog'; - $head[$h][1] = $langs->trans("ChangeLog"); - $head[$h][2] = 'changelog'; - $h++; -} +$head = modulehelp_prepare_head($objMod); // Check filters $modulename=$objMod->getName(); diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php new file mode 100644 index 00000000000..06c59338e58 --- /dev/null +++ b/htdocs/admin/mrp.php @@ -0,0 +1,522 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/mrp.php + * \ingroup mrp + * \brief Setup page of module MRP + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scan_dir', 'alpha'); +$type = 'mrp'; + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') +{ + $maskconstmrp=GETPOST('maskconstMo', 'alpha'); + $maskmrp=GETPOST('maskMo', 'alpha'); + + if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +elseif ($action == 'specimen') +{ + $modele=GETPOST('module', 'alpha'); + + $mo = new MO($db); + $mrp->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($mrp, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +elseif ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +elseif ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); + } +} + +// Set default model +elseif ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "MRP_MO_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->MRP_MO_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +elseif ($action == 'setmod') +{ + // TODO Check if numbering module chosen can be activated + // by calling method canBeActivated + + dolibarr_set_const($db, "MRP_MO_ADDON", $value, 'chaine', 0, '', $conf->entity); +} + +elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK') +{ + $draft = GETPOST("MRP_MO_DRAFT_WATERMARK"); + $res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +elseif ($action == 'set_MRP_MO_FREE_TEXT') +{ + $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$form=new Form($db); + +$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + +llxHeader("", $langs->trans("MrpSetupPage")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup'); + +$head = mrpAdminPrepareHead(); + +dol_fiche_head($head, 'settings', $langs->trans("MOs"), -1, 'mrp'); + +/* + * MOs Numbering model + */ + +print load_fiche_titre($langs->trans("MOsNumberingModules"), '', ''); + +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/mrp/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $mrp=new MO($db); + $mrp->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $mrp->type=0; + $nextval=$module->getNextValue($mysoc, $mrp); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } +} +print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->MRP_MO_ADDON == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

\n"; + + +/* + * Document templates generators + */ + +print load_fiche_titre($langs->trans("MOsModelModule"), '', ''); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/mrp".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + if ($conf->global->MRP_MO_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; +print "
"; + +/* + * Other options + */ + +print load_fiche_titre($langs->trans("OtherOptions"), '', ''); +print ''; +print ''; +print ''; +print ''; +print "\n"; +print "\n"; + +$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + +print ''; +print ''; +print ''; +print '\n"; +print ''; + +//Use draft Watermark + +print ""; +print ''; +print ""; +print '\n"; +print ''; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; +$variablename='MRP_MO_FREE_TEXT'; +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) +{ + print ''; +} +else +{ + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); +} +print '
'; +print ''; +print "
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftMOs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; +print '
'; +print ''; +print ''; +print ''; +print "
'; +print '
'; + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 6d1a5c57cf6..52de58b80b8 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -236,7 +236,7 @@ foreach($listofnotifiedevents as $notifiedevent) $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. $arrayemail=explode(',', $value); $showwarning=0; - foreach($arrayemail as $key=>$valuedet) + foreach($arrayemail as $keydet => $valuedet) { $valuedet=trim($valuedet); if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++; diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 9bbe81993c4..c0d08f4b505 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -35,10 +35,10 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } // Load translation files required by the page diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index 1fedf9e40de..06bed7a3f3a 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -35,10 +35,10 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $sortfield = GETPOST("sortfield", 'alpha'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 4d234e266e8..52ef490ceae 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -458,7 +458,7 @@ if ($mode == 'searchkey') //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder; $title = $langs->trans("TranslationKeySearch"); if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')'; - print print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit)."\n"; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit); print ''; print ''; @@ -466,7 +466,7 @@ if ($mode == 'searchkey') print '
'; print ''; print ''; - print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder).''; + print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 0343fecf69d..5ea6ee66dd9 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -421,7 +421,7 @@ $h++; dol_fiche_head($head, 'website', '', -1); -print $langs->trans("WebsiteSetupDesc").'
'; +print ''.$langs->trans("WebsiteSetupDesc").'
'; print "
\n"; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 0247514b2a4..f4c9076fbd9 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -102,6 +102,7 @@ class DolibarrApi unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); + unset($object->table_rowid); // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses unset($object->linkedObjects); @@ -127,13 +128,14 @@ class DolibarrApi unset($object->timespent_withhour); unset($object->timespent_fk_user); unset($object->timespent_note); + unset($object->fk_delivery_address); unset($object->statuts); unset($object->statuts_short); unset($object->statuts_logo); unset($object->statuts_long); - unset($object->labelstatut); - unset($object->labelstatut_short); + unset($object->labelStatus); + unset($object->labelStatusShort); unset($object->element); unset($object->fk_element); @@ -146,6 +148,11 @@ class DolibarrApi unset($object->skip_update_total); unset($object->context); + unset($object->next_prev_filter); + + if ($object->table_element != 'ticket') { + unset($object->comments); + } // Remove the $oldcopy property because it is not supported by the JSON // encoder. The following error is generated when trying to serialize @@ -178,6 +185,7 @@ class DolibarrApi unset($object->lines[$i]->cond_reglement); unset($object->lines[$i]->fk_delivery_address); unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); unset($object->lines[$i]->thirdparty); unset($object->lines[$i]->user); unset($object->lines[$i]->model_pdf); diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 6223744955e..50102b76b93 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -390,7 +390,7 @@ class Setup extends DolibarrApi public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - $sql = "SELECT t.code, t.libelle, t.description, t.tracking"; + $sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql.= " WHERE t.active = ".$active; // Add sql filters diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 2a734b9336d..7a9ef9ad24d 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -55,6 +55,12 @@ require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +$url = $_SERVER['PHP_SELF']; +// Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases) +if (! empty($conf->global->MAIN_NGINX_FIX)) +{ + $url = (isset($_SERVER['SCRIPT_URI']) && $_SERVER["SCRIPT_URI"] !== null) ? $_SERVER["SCRIPT_URI"] : $_SERVER['PHP_SELF']; +} // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) @@ -67,7 +73,7 @@ if (empty($conf->global->MAIN_MODULE_API)) } // Test if explorer is not disabled -if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($conf->global->API_EXPLORER_DISABLED)) +if (preg_match('/api\/index\.php\/explorer/', $url) && ! empty($conf->global->API_EXPLORER_DISABLED)) { $langs->load("admin"); dol_syslog("Call Dolibarr API interfaces with module REST disabled"); @@ -91,7 +97,7 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($ $reg=array(); -preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg); +preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); // .../index.php/categories?sortfield=t.rowid&sortorder=ASC diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 7c2f1b42f32..7d49d253755 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -60,8 +60,8 @@ foreach($object->fields as $key => $val) if (empty($action) && empty($id) && empty($ref)) $action='view'; // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); // Load object diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 04c195c08ff..0e34cd9b989 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -128,7 +128,13 @@ class Asset extends CommonObject public $note_public; public $note_private; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $tms; /** diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index d1fa8c1e04b..976b8974f5a 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -40,8 +40,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); // Get parameters diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index f3758ebca8e..f3c385831a1 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -34,7 +34,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'asset', $id, ''); $object = new Asset($db); diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index bd2d19bbc87..697f3becd9b 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -72,9 +72,9 @@ if (! $sortorder) $sortorder="ASC"; // Protection if external user $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'asset', $id,''); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index 0c03619d31c..dce1daaa3ca 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -46,8 +46,8 @@ $hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_module $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); // Load object diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 459bd2d8edc..916939b378e 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -615,7 +615,7 @@ if ($rowid > 0) if (empty($reshook)) { print '

'; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->element]['label'] as $key=>$label) { if (isset($_POST["options_" . $key])) { if (is_array($_POST["options_" . $key])) { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 906040a6bd9..4981c05afd7 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -100,7 +100,12 @@ class BlockedLog */ public $fk_user = 0; + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_modification; public $date_object = 0; diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 87fb55a6541..c38d0a82a69 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -53,8 +53,8 @@ else $search_agenda_label=GETPOST('search_agenda_label'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 17fae31ef7d..231679f7b3a 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -70,8 +70,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); @@ -125,9 +125,11 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $idprod=GETPOST('idprod', 'int'); - $qty=GETPOST('qty', 'int'); - $efficiency=GETPOST('efficiency', 'int'); + $idprod = GETPOST('idprod', 'int'); + $qty = GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = GETPOST('efficiency', 'int'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -138,17 +140,27 @@ if (empty($reshook)) $error++; } - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->qty = $qty; - $bomline->efficiency = $efficiency; - - $result = $bomline->create($user); - if ($result <= 0) + if (! $error) { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; + $bomline = new BOMLine($db); + $bomline->fk_bom = $id; + $bomline->fk_product = $idprod; + $bomline->qty = $qty; + $bomline->qty_frozen = $qty_frozen; + $bomline->disable_stock_change = $disable_stock_change; + $bomline->efficiency = $efficiency; + + $result = $bomline->create($user); + if ($result <= 0) + { + setEventMessages($bomline->error, $bomline->errors, 'errors'); + $action = ''; + } + else + { + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -160,6 +172,8 @@ if (empty($reshook)) // Set if we used free entry or predefined product $qty=GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency=GETPOST('efficiency', 'int'); if ($qty == '') { @@ -170,6 +184,8 @@ if (empty($reshook)) $bomline = new BOMLine($db); $bomline->fetch($lineid); $bomline->qty = $qty; + $bomline->qty_frozen = $qty_frozen; + $bomline->disable_stock_change = $disable_stock_change; $bomline->efficiency = $efficiency; $result = $bomline->update($user); @@ -178,6 +194,11 @@ if (empty($reshook)) setEventMessages($bomline->error, $bomline->errors, 'errors'); $action = ''; } + else + { + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -294,12 +315,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } // Confirmation of validation if ($action == 'validate') @@ -647,14 +662,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // ancre // Documents - /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref . '/' . $objref . '.pdf'; $filedir = $conf->bom->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->bom->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - */ + $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); @@ -678,17 +692,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } //Select mail models is same action as presend - /* - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; - // Presend form - $modelmail='inventory'; - $defaulttopic='InformationMessage'; - $diroutput = $conf->product->dir_output.'/inventory'; - $trackid = 'stockinv'.$object->id; + // Presend form + $modelmail='bom'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->bom->dir_output; + $trackid = 'bom'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - */ + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 826222af8b0..f0dac37a5a0 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -41,8 +41,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); // Get parameters diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 6e192a06545..0775c2cc370 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -73,9 +73,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'bom', $id, ''); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 481d8f1d799..e733b96d12b 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -47,8 +47,8 @@ $hookmanager->initHooks(array('bomnote','globalcard')); // Note that conf->h $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); // Load object diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 471fb4f2cce..6b629fd2852 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -260,7 +260,7 @@ class Boms extends DolibarrApi throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error); } - return array( + return array( 'success' => array( 'code' => 200, 'message' => 'BOM deleted' @@ -281,12 +281,53 @@ class Boms extends DolibarrApi // phpcs:enable $object = parent::_cleanObjectDatas($object); - /*unset($object->note); - unset($object->address); + unset($object->rowid); + unset($object->canvas); + + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->statut); + unset($object->state); + unset($object->state_id); + unset($object->state_code); + unset($object->region); + unset($object->region_code); + unset($object->country); + unset($object->country_id); + unset($object->country_code); unset($object->barcode_type); unset($object->barcode_type_code); unset($object->barcode_type_label); - unset($object->barcode_type_coder);*/ + unset($object->barcode_type_coder); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_account); + unset($object->comments); + unset($object->note); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->shipping_method_id); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i=0; $i < $nboflines; $i++) + { + $this->_cleanObjectDatas($object->lines[$i]); + + unset($object->lines[$i]->lines); + unset($object->lines[$i]->note); + } + } return $object; } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 02e39149364..4a623c3f36d 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -112,7 +112,13 @@ class BOM extends CommonObject public $description; public $note_public; public $note_private; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $tms; public $fk_user_creat; public $fk_user_modif; @@ -240,9 +246,10 @@ class BOM extends CommonObject unset($object->import_key); // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - + $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; + // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { @@ -808,43 +815,19 @@ class BOM extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) + if (empty($this->labelStatus)) { global $langs; //$langs->load("mrp"); - $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode); } /** @@ -1059,12 +1042,14 @@ class BOMLine extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), - 'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), + 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), + 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), + 'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); @@ -1073,6 +1058,8 @@ class BOMLine extends CommonObject public $fk_product; public $description; public $qty; + public $qty_frozen; + public $disable_stock_change; public $efficiency; public $position; public $import_key; @@ -1339,47 +1326,7 @@ class BOMLine extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("mrp"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } - - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } + return ''; } /** diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index cd654c7a596..9f6bfee98f2 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -63,11 +63,13 @@ if ($nolinesbefore) { print ''; if ($conf->global->PRODUCT_USE_UNITS) { - print ''; + print ''; } + print ''; + print ''; print ''; print ''; print ''; @@ -109,6 +111,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) $coldisplay++; print ''; + if($conf->global->PRODUCT_USE_UNITS) { $coldisplay++; @@ -118,7 +121,14 @@ if($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; +print ''; +$coldisplay++; +print ''; + +$coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index d887b9ab68d..c7fc4f73cd7 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -116,6 +116,14 @@ if ($conf->global->PRODUCT_USE_UNITS) print ''; } +$coldisplay++; +print ''; + +$coldisplay++; +print ''; + $coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 721cc5b501f..138a0b9aa58 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -59,6 +59,13 @@ if ($conf->global->PRODUCT_USE_UNITS) print ''; } +// Qty frozen +print ''; + +// Disable stock change +print ''; + +// Efficiency print ''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f68372c721d..330f8ef8a33 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -87,6 +87,16 @@ if($conf->global->PRODUCT_USE_UNITS) } print ''; } + +print ''; +print ''; + print ''; // Force warehouse (this is not a default value) print ' diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index cb7b7dd2f10..813364d18a5 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -85,7 +85,7 @@ $object->fetch($facid); for($i=0;$i < $tab_size;$i++) { $remise = $tab[$i]['remise']; - ?> + ?> @@ -93,7 +93,7 @@ $object->fetch($facid); - diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index e8c16712b74..fcbd95e8f29 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -36,16 +36,16 @@ $langs->loadLangs(array("main","bills","banks")); - montantTva() ) { - echo (''); - } - else - { - echo (''); - } - ?> +montantTva() ) { + echo (''); +} +else +{ + echo (''); +} +?> - getsetPaymentMode() == 'DIF' ) { - echo (''); - } else { - echo (''); - } +getsetPaymentMode() == 'DIF' ) { + echo (''); +} else { + echo (''); +} - // Affichage du montant rendu (reglement en especes) - if ( $obj_facturation->montantRendu() ) { - echo (''); - } +// Affichage du montant rendu (reglement en especes) +if ( $obj_facturation->montantRendu() ) { + echo (''); +} - ?> +?>
'.$langs->trans('Qty').''; - print ''; - print $langs->trans('Unit'); - print ''; + print ''; + print $langs->trans('Unit'); + print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).' 
'; print ''; +print ''; +print ''; print ''; print 'qty_frozen?' checked="checked"':'')).'>'; +print 'disable_stock_change?' checked="checked"':'')).'">'; +print ''; print ''.$langs->trans('Unit').''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; +$coldisplay++; +echo $line->qty_frozen ? yn($line->qty_frozen) : ''; +print ''; +$coldisplay++; +echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price +print ''; $coldisplay++; echo $line->efficiency; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 8a26b12f15b..2a5758e61d2 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -66,10 +66,11 @@ function printBookmarksList() $ret.= ''."\n"; $ret.= '
'; + $ret.= ''; $ret.= '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); } else { if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); } print $langs->trans("Yes").'
'; print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 2f8a993829e..a8119225db9 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -194,9 +194,9 @@ class Facturation { if ($poscart[$key]['id'] != $aArticle) { - $newposcart[$j]=$poscart[$key]; - $newposcart[$j]['id']=$j; - $j++; + $newposcart[$j]=$poscart[$key]; + $newposcart[$j]['id']=$j; + $j++; } } unset($poscart); diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index e8dad4d2fb1..77de0e4ed8e 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -56,30 +56,33 @@ $langs->loadLangs(array("main","bills","cashdesk"));
currency);?>
trans("Invoice"); ?>numInvoice(); ?>
trans("TotalHT"); ?>prixTotalHt(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?>
'.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("VAT").''.$langs->trans("NoVAT").'
'.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("VAT").''.$langs->trans("NoVAT").'
trans("TotalTTC"); ?> prixTotalTtc(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?>
trans("PaymentMode"); ?> loadLangs(array("main","bills","banks")); ?>
'.$langs->trans("DateDue").''.$obj_facturation->paiementLe().'
'.$langs->trans("Received").''.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("DateDue").''.$obj_facturation->paiementLe().'
'.$langs->trans("Received").''.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("Change").''.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("Change").''.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d60b3251f0d..f184f1b433f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -779,9 +779,9 @@ class Categorie extends CommonObject $sql .= " AND c.fk_categorie = ".$this->id; $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; // Protection for external users - if (($type == 'customer' || $type == 'supplier') && $user->societe_id > 0) + if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { - $sql.= " AND o.rowid = ".$user->societe_id; + $sql.= " AND o.rowid = ".$user->socid; } if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->order($sortfield, $sortorder); @@ -1018,11 +1018,11 @@ class Categorie extends CommonObject * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * - * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). + * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...) * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. * $markafterid can be an : * - int (id of category) - * - string (categories ids seprated by comma) + * - string (categories ids separated by comma) * - array (list of categories ids) * @param int $include [=0] Removed or 1=Keep only * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 6def65666a0..754b846576d 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -136,7 +136,7 @@ if ($object->id) } $morehtmlref.='
'; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); /* * Confirmation de la suppression de photo diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 3c9c7eb64e4..1c082dfe332 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -207,7 +207,7 @@ foreach ($ways as $way) } $morehtmlref.='
'; -dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); print '
'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index fb246b5358b..45926847df4 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -226,7 +226,7 @@ foreach ($ways as $way) } $morehtmlref.='
'; -dol_banner_tab($object, 'label', $linkback, ($user->societe_id?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'label', $linkback, ($user->socid?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1); /* diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6e8c5535f03..6b75f5b4a50 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -69,9 +69,9 @@ $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fullda // Security check $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -if ($user->societe_id && $socid) $result = restrictedArea($user, 'societe', $socid); +if ($user->socid && $socid) $result = restrictedArea($user, 'societe', $socid); $error=GETPOST("error"); $donotclearsession=GETPOST('donotclearsession')?GETPOST('donotclearsession'):0; @@ -94,7 +94,7 @@ if ($id > 0 && $action!='add') { $ret1 = $object->fetch_userassigned(); } if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); + dol_print_error('', $object->error); } } @@ -861,11 +861,11 @@ if ($action == 'create') if (GETPOST('datep', 'int', 1)) $datep=dol_stringtotime(GETPOST('datep', 'int', 1), 0); print ''.$langs->trans("DateActionStart").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldayend'); } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); } else { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); } print ''; @@ -1024,8 +1024,8 @@ if ($action == 'create') $events=array(); $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); //For external user force the company to user company - if (!empty($user->societe_id)) { - print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300'); + if (!empty($user->socid)) { + print $form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300'); } else { print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300'); } @@ -1582,19 +1582,20 @@ if ($id > 0) if ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -1611,7 +1612,7 @@ if ($id > 0) $morehtmlref.=''; - dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 871ec6b9ed2..a07e4ceba1a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -45,43 +45,67 @@ class ActionComm extends CommonObject */ public $table_element = 'actioncomm'; + /** + * @var string Name of id column + */ public $table_rowid = 'id'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + * @var string Name of icon for actioncomm object. Filename of icon is object_action.png */ public $picto = 'action'; /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int + * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 1; /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user, 2=Same than 1 but accept record if fksoc is empty - * @var integer + * @var integer 0=Default + * 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * 2=Same than 1 but accept record if fksoc is empty */ public $restrictiononfksoc = 2; /** - * Id of the event - * @var int + * @var int Id of the event */ public $id; /** - * Id of the event. Use $id as possible - * @var int + * @var int Id of the event. Use $id as possible */ public $ref; - public $type_id; // Id into parent table llx_c_actioncomm (used only if option to use type is set) - public $type_code; // Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + /** + * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_id; + + /** + * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + */ + public $type_code; + + /** + * @var string Type label + */ public $type_label; - public $type; // Label into parent table llx_c_actioncomm (used only if option to use type is set) - public $type_color; // Color into parent table llx_c_actioncomm (used only if option to use type is set) - public $code; // Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) + + /** + * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type; + + /** + * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_color; + + /** + * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) + */ + public $code; /** * @var string Agenda event label @@ -89,72 +113,56 @@ class ActionComm extends CommonObject public $label; /** - * Date creation record (datec) - * - * @var integer + * @var integer Date creation record (datec) */ public $datec; /** - * Date end record (datef) - * - * @var integer + * @var integer Date end record (datef) */ public $datef; /** - * Duration (duree) - * - * @var integer + * @var integer Duration (duree) */ public $duree; /** - * Date modification record (tms) - * - * @var integer + * @var integer Date modification record (tms) */ public $datem; /** - * Object user that create action - * @var User + * @var User Object user that create action * @deprecated * @see $authorid */ public $author; /** - * Object user that modified action - * @var User + * @var User Object user that modified action * @deprecated * @see $usermodid */ public $usermod; /** - * Id user that create action - * @var int + * @var int Id user that create action */ public $authorid; /** - * Id user that modified action - * @var int + * @var int Id user that modified action */ public $usermodid; /** - * Date action start (datep) - * - * @var integer + * @var integer Date action start (datep) */ public $datep; /** - * Date action end (datep2) - * - * @var integer + * @var integer Date action end (datep2) */ public $datep2; @@ -163,90 +171,178 @@ class ActionComm extends CommonObject * @deprecated */ public $durationp = -1; - public $fulldayevent = 0; // 1=Event on full day /** - * Milestone - * @var int + * @var int 1=Event on full day + */ + public $fulldayevent = 0; + + /** + * @var int Milestone * @deprecated Milestone is already event with end date = start date */ public $punctual = 1; - public $percentage; // Percentage - public $location; // Location - public $transparency; // Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) - public $priority; // Small int (0 By default) + /** + * @var integer Percentage + */ + public $percentage; - public $userassigned = array(); // Array of user ids - public $userownerid; // Id of user owner = fk_user_action into table - public $userdoneid; // Id of user done (deprecated) + /** + * @var string Location + */ + public $location; - public $socpeopleassigned = array(); // Array of contact ids + /** + * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) + */ + public $transparency; - public $otherassigned = array(); // Array of other contact emails (not user, not contact) + /** + * @var int (0 By default) + */ + public $priority; + + /** + * @var int[] Array of user ids + */ + public $userassigned = array(); + + /** + * @var int Id of user owner = fk_user_action into table + */ + public $userownerid; + + /** + * @var int Id of user done (deprecated) + * @deprecated + */ + public $userdoneid; + + /** + * @var int[] Array of contact ids + */ + public $socpeopleassigned = array(); + + /** + * @var int[] Array of other contact emails (not user, not contact) + */ + public $otherassigned = array(); - /** - * Object user of owner - * @var User + /** + * @var User Object user of owner * @deprecated * @see userownerid */ public $usertodo; /** - * Object user that did action - * @var User + * @var User Object user that did action * @deprecated * @see userdoneid */ public $userdone; + /** + * @var int thirdparty id linked to action + */ public $socid; + + /** + * @var int socpeople id linked to action + */ public $contactid; /** - * Company linked to action (optional) - * @var Societe|null + * @var Societe|null Company linked to action (optional) * @deprecated * @see socid */ public $societe; /** - * Contact linked to action (optional) - * @var Contact|null + * @var Contact|null Contact linked to action (optional) * @deprecated * @see contactid */ public $contact; // Properties for links to other objects + /** + * @var int Id of linked object + */ public $fk_element; // Id of record - public $elementid; // Id of record alternative for API - public $elementtype; // Type of record. This if property ->element of object linked to. - // Ical + /** + * @var int Id of record alternative for API + */ + public $elementid; + + /** + * @var string Type of record. This if property ->element of object linked to. + */ + public $elementtype; + + /** + * @var string Ical name + */ public $icalname; + + /** + * @var string Ical color + */ public $icalcolor; + /** + * @var array Actions + */ public $actions=array(); - // Fields for emails + /** + * @var string Email msgid + */ public $email_msgid; + + /** + * @var string Email from + */ public $email_from; + + /** + * @var string Email sender + */ public $email_sender; + + /** + * @var string Email to + */ public $email_to; + + /** + * @var string Email tocc + */ public $email_tocc; + /** + * @var string Email tobcc + */ public $email_tobcc; + + /** + * @var string Email subject + */ public $email_subject; + + /** + * @var string Email errors to + */ public $errors_to; /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { @@ -484,9 +580,9 @@ class ActionComm extends CommonObject return $this->id; } else - { - $this->db->rollback(); - return -1; + { + $this->db->rollback(); + return -1; } } else @@ -1043,7 +1139,7 @@ class ActionComm extends CommonObject return $resarray; } else - { + { return $db->lasterror(); } } @@ -1067,13 +1163,13 @@ class ActionComm extends CommonObject $sql = "SELECT count(a.id) as nb"; } $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE 1 = 1"; if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if ($user->socid) $sql.=" AND a.fk_soc = ".$user->socid; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; $resql=$this->db->query($sql); @@ -1344,7 +1440,6 @@ class ActionComm extends CommonObject $linkstart = ''; $linkend = ''; } - //print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto; if ($withpicto == 2) { @@ -1463,7 +1558,7 @@ class ActionComm extends CommonObject $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; $sql.= " u.firstname, u.lastname, u.email,"; $sql.= " s.nom as socname,"; - $sql.= " c.id as type_id, c.code as type_code, c.libelle"; + $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; @@ -1568,7 +1663,7 @@ class ActionComm extends CommonObject $event['location']=$obj->location; $event['transparency']=(($obj->transparency > 0)?'OPAQUE':'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) $event['punctual']=$obj->punctual; - $event['category']=$obj->libelle; // libelle type action + $event['category']=$obj->type_label; $event['email']=$obj->email; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); @@ -1579,6 +1674,22 @@ class ActionComm extends CommonObject $event['created']=$this->db->jdate($obj->datec)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); $event['modified']=$this->db->jdate($obj->datem)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); + // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties + $this->id = $obj->id; + $this->fetch_userassigned(); + + $assignedUserArray = array(); + + foreach($this->userassigned as $key => $value) + { + $assignedUser = new User($this->db); + $assignedUser->fetch($value['id']); + + $assignedUserArray[$key]=$assignedUser; + } + + $event['assignedUsers']=$assignedUserArray; + if ($qualified && $datestart) { $eventarray[]=$event; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 652e0d80966..f3fa2cd47c1 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -338,6 +338,7 @@ class AgendaEvents extends DolibarrApi // phpcs:enable $object = parent::_cleanObjectDatas($object); + unset($object->note); // alreaydy into note_private unset($object->usermod); unset($object->libelle); unset($object->context); @@ -350,6 +351,11 @@ class AgendaEvents extends DolibarrApi unset($object->origin_id); unset($object->ref_ext); unset($object->statut); + unset($object->state_code); + unset($object->state_id); + unset($object->state); + unset($object->region); + unset($object->region_code); unset($object->country); unset($object->country_id); unset($object->country_code); @@ -378,6 +384,9 @@ class AgendaEvents extends DolibarrApi unset($object->contact); unset($object->societe); + unset($object->actions); + unset($object->lines); + return $object; } } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 7c696b70247..5587da16556 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -379,7 +379,7 @@ class ICal return $temp; } else - { + { return false; } } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 6f0875be879..f01f49921e7 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -45,8 +45,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; -if ($user->societe_id > 0) +if ($user->socid) $socid=$user->socid; +if ($user->socid > 0) { unset($_GET["action"]); $action=''; @@ -159,7 +159,7 @@ if ($object->id > 0) } $morehtmlref.='
'; - dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d503c1bc71d..031918b194b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -67,7 +67,7 @@ if (! $sortfield) $sortfield="a.datec"; // Security check $socid = GETPOST("search_socid", "int")?GETPOST("search_socid", "int"):GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -519,14 +519,14 @@ if (! empty($actioncode)) elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; else { - if (is_array($actioncode)) - { + if (is_array($actioncode)) + { $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } + else + { $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } + } } } } @@ -614,7 +614,7 @@ if ($resql) $event->type_label=$obj->type_label; $event->type_color=$obj->type_color; - $event->libelle=$obj->label; + $event->libelle=$obj->label; // deprecated $event->label=$obj->label; $event->percentage=$obj->percent; $event->authorid=$obj->fk_user_author; // user id of creator @@ -720,7 +720,7 @@ if ($showbirthday) $event->datep=dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output $event->datef=$event->datep; $event->type_code='BIRTHDAY'; - $event->libelle=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->label=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); $event->percentage=100; $event->fulldayevent=1; @@ -949,9 +949,9 @@ if (count($listofextcals)) $event->datef=$dateend+$usertime; $event->type_code="ICALEVENT"; - if($icalevent['SUMMARY']) $event->libelle=$icalevent['SUMMARY']; - elseif($icalevent['DESCRIPTION']) $event->libelle=dol_nl2br($icalevent['DESCRIPTION'], 1); - else $event->libelle = $langs->trans("ExtSiteNoLabel"); + if($icalevent['SUMMARY']) $event->label=$icalevent['SUMMARY']; + elseif($icalevent['DESCRIPTION']) $event->label=dol_nl2br($icalevent['DESCRIPTION'], 1); + else $event->label = $langs->trans("ExtSiteNoLabel"); $event->date_start_in_calendar=$event->datep; @@ -1554,7 +1554,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Show title $titletoshow = $daterange; - $titletoshow.=($titletoshow?' ':'').$event->libelle; + $titletoshow.=($titletoshow?' ':'').($event->label?$event->label:$event->libelle); if ($event->type_code == 'ICALEVENT') print $titletoshow; else @@ -1729,11 +1729,24 @@ function dol_color_minus($color, $minus, $minusunit = 16) */ function sort_events_by_date($a, $b) { - if($a->datep != $b->datep) - { - return $a->datep - $b->datep; - } + if($a->datep != $b->datep) + { + return $a->datep - $b->datep; + } - // If both events have the same start time, longest first - return $b->datef - $a->datef; + // If both events have the same start time, longest first + + if(! is_numeric($b->datef)) + { + // when event B have no end timestamp, event B should sort be before event A (All day events on top) + return 1; + } + + if(! is_numeric($a->datef)) + { + // when event A have no end timestamp , event A should sort be before event B (All day events on top) + return -1; + } + + return $b->datef - $a->datef; } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index c873adee9de..a88ff67fd91 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -39,10 +39,10 @@ $langs->load("commercial"); $id = GETPOST('id', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -102,7 +102,7 @@ if (! empty($conf->projet->enabled)) } $morehtmlref.='
'; -dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); +dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index a7fe41a478c..65852d053b4 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -110,7 +110,7 @@ if (! $sortfield) // Security check $socid = GETPOST("search_socid", 'int')?GETPOST("search_socid", 'int'):GETPOST("socid", 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -138,13 +138,16 @@ $arrayfields=array( 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -485,7 +488,7 @@ if ($resql) if (! empty($arrayfields['a.tms']['checked'])) print ''; if (! empty($arrayfields['a.percent']['checked'])) { print ''; - print $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2); + $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2); print ajax_combobox('selectstatus'); print ''; } @@ -699,15 +702,15 @@ if ($resql) // Linked object if (! empty($arrayfields['a.fk_element']['checked'])) { - print ''; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''; + print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print ''; } // Extra fields diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 286863c7dc6..134e239b66f 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -65,7 +65,7 @@ if (! $sortfield) $sortfield="a.datec"; // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -616,12 +616,12 @@ $typeofevents=array(); // Load array of colors by type $colorsbytype=array(); $labelbytype=array(); -$sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm"; +$sql="SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; $resql=$db->query($sql); while ($obj = $db->fetch_object($resql)) { $colorsbytype[$obj->code]=$obj->color; - $labelbytype[$obj->code]=$obj->libelle; + $labelbytype[$obj->code]=$obj->label; } // Loop on each user to show calendar diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index fc343f443a2..3280ddc7af4 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -65,7 +65,7 @@ if (! $sortfield) $sortfield="a.datec"; // Security check $socid = GETPOST("search_socid", "int")?GETPOST("search_socid", "int"):GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -418,14 +418,14 @@ if (! empty($actioncode)) elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; else { - if (is_array($actioncode)) - { + if (is_array($actioncode)) + { $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } + else + { $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } + } } } } @@ -683,16 +683,16 @@ while($currentdaytoshow<$lastdaytoshow) { { foreach ($eventarray as $daykey => $notused) { - // Get all assigned users for each event - foreach ($eventarray[$daykey] as $index => $event) - { - $event->fetch_userassigned(); + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); $listofuserid=$event->userassigned; foreach($listofuserid as $userid => $tmp) { if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } - } + } } } /* Use this list to have for all users */ @@ -752,12 +752,12 @@ while($currentdaytoshow<$lastdaytoshow) { // Load array of colors by type $colorsbytype=array(); $labelbytype=array(); - $sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; + $sql="SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; $resql=$db->query($sql); while ($obj = $db->fetch_object($resql)) { $colorsbytype[$obj->code]=$obj->color; - $labelbytype[$obj->code]=$obj->libelle; + $labelbytype[$obj->code]=$obj->label; } // Loop on each user to show calendar diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 8cc1774cba2..c6549c5c39a 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -49,7 +49,7 @@ if (! $sortfield) $sortfield="a.datep"; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'agenda', $socid, '', 'myactions'); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 576851b7e2e..a0263065dee 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -59,7 +59,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails"); // Security check $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -if ($user->societe_id > 0) $id=$user->societe_id; +if ($user->socid > 0) $id=$user->socid; $result = restrictedArea($user, 'societe', $id, '&societe'); $action = GETPOST('action', 'aZ09'); @@ -240,7 +240,7 @@ if ($object->id > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -387,7 +387,7 @@ if ($object->id > 0) print ''; - print "
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } @@ -401,7 +401,7 @@ if ($object->id > 0) print '
'; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } @@ -565,7 +565,7 @@ if ($object->id > 0) if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; } print '
"; + print ""; } print '
'; @@ -1274,7 +1274,7 @@ if ($object->id > 0) } // Add invoice - if ($user->societe_id == 0) + if ($user->socid == 0) { if (! empty($conf->deplacement->enabled) && $object->status==1) { @@ -1297,8 +1297,8 @@ if ($object->id > 0) { if ($object->client != 0 && $object->client != 2) { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; } else print ''; } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 0e0354a5641..6c0aea2f935 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -47,7 +47,7 @@ $begin=GETPOST('begin', 'alpha'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, ''); @@ -59,13 +59,13 @@ llxHeader('', $langs->trans("Contacts")); if ($type == "c" || $type == "p") { - $label = $langs->trans("Customers"); - $urlfiche="card.php"; + $label = $langs->trans("Customers"); + $urlfiche="card.php"; } if ($type == "f") { - $label = $langs->trans("Suppliers"); - $urlfiche="card.php"; + $label = $langs->trans("Suppliers"); + $urlfiche="card.php"; } /* @@ -88,29 +88,29 @@ if ($socid) $sql.= " AND s.rowid = ".$socid; if (dol_strlen($stcomm)) { - $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); + $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); } if (! empty($search_lastname)) { - $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; } if (! empty($search_firstname)) { - $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; + $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; } if (! empty($search_company)) { - $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; + $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (! empty($contactname)) // acces a partir du module de recherche { - $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.name"; + $sortorder = "ASC"; } $sql.= $db->order($sortfield, $sortorder); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 43af4f8f1c0..245d3874d92 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -51,10 +51,10 @@ $bid=GETPOST('bid', 'int'); // Securite acces client $socid=GETPOST('socid', 'int'); -if (isset($user->societe_id) && $user->societe_id > 0) +if (isset($user->socid) && $user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $max=3; @@ -120,6 +120,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -132,6 +133,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print '
'; print '
'; } @@ -559,10 +561,10 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; $sql.= ", s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY s.datec DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 1049431b7f2..d9fbd9a37b2 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -41,7 +41,7 @@ if (! empty($conf->categorie->enabled)) { } // Security check -if (! $user->rights->mailing->lire || $user->societe_id > 0) +if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // Load variable for pagination diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 33de68f22a1..714a84fe95a 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->load("mails"); -if (! $user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->societe_id > 0)) accessforbidden(); +if (! $user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) accessforbidden(); $id=(GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int')); $action=GETPOST('action', 'alpha'); @@ -851,7 +851,7 @@ else setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"]=''; } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 998f4a6c202..819e0acf562 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("mails"); // Security check -if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden(); +if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // Load variable for pagination @@ -479,14 +479,13 @@ if ($object->fetch($id) >= 0) { $num = $db->num_rows($resql); - $param = "&id=".$object->id; + $param = "&id=".$object->id; //if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname); if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname); if ($search_email) $param.= "&search_email=".urlencode($search_email); if ($search_other) $param.= "&search_other=".urlencode($search_other); - if ($page) $param.= "&page=".urlencode($page); print '
'; print ''; @@ -500,6 +499,7 @@ if ($object->fetch($id) >= 0) $morehtmlcenter=''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition">'.$langs->trans("TargetsReset").''; } $morehtmlcenter.=' id.'">'.$langs->trans("Download").''; + print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); print '
'; @@ -560,6 +560,8 @@ if ($object->fetch($id) >= 0) print ''; print ''; + if ($page) $param.= "&page=".urlencode($page); + print ''; print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 41f74846125..32637096910 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -67,7 +67,12 @@ class Mailing extends CommonObject public $user_creat; public $user_valid; + /** + * @var integer|string date_creation + */ public $date_creat; + + public $date_valid; public $extraparams=array(); @@ -618,48 +623,24 @@ class Mailing extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; - $langs->load('mails'); + $langs->load("mailing"); - if ($mode == 0 || $mode == 1) - { - return $langs->trans($this->statuts[$statut]); - } - elseif ($mode == 2) - { - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); - } - elseif ($mode == 3) - { - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - } - elseif ($mode == 4) - { - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); - } - elseif ($mode == 5) - { - if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut == 2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut == 3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - } + $labelStatus = $langs->trans($this->statuts[$status]); + $labelStatusShort = $langs->trans($this->statuts[$status]); + + $statusType = 'status'.$status; + if ($status == 2) $statusType = 'status3'; + if ($status == 3) $statusType = 'status6'; + + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } @@ -667,58 +648,37 @@ class Mailing extends CommonObject * Renvoi le libelle d'un statut donne * TODO Add class mailin_target.class.php * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param string $desc Desc error * @return string Label */ - public static function libStatutDest($statut, $mode = 0, $desc = '') + public static function libStatutDest($status, $mode = 0, $desc = '') { global $langs; - $langs->load('mails'); + $langs->load("mails"); - if ($mode == 0) - { - return $langs->trans('MailingStatusError'); - } - elseif ($mode == 1) - { - return $langs->trans('MailingStatusSent'); - } - elseif ($mode == 2) - { - if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); - } - elseif ($mode == 3) - { - if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); - } - elseif ($mode == 4) - { - if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); - } - elseif ($mode == 5) - { - if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); - } - elseif ($mode == 6) - { - if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + $labelStatus = array(); + $labelStatusShort = array(); + + $labelStatus[-1] = $langs->trans('MailingStatusError'); + $labelStatus[1] = $langs->trans('MailingStatusSent'); + $labelStatus[2] = $langs->trans('MailingStatusRead'); + $labelStatus[3] = $langs->trans('MailingStatusNotContact'); + $labelStatusShort[-1] = $langs->trans('MailingStatusError'); + $labelStatusShort[1] = $langs->trans('MailingStatusSent'); + $labelStatusShort[2] = $langs->trans('MailingStatusRead'); + $labelStatusShort[3] = $langs->trans('MailingStatusNotContact'); + + $statusType = 'status'.$status; + if ($status == -1) $statusType = 'status8'; + if ($status == 1) $statusType = 'status6'; + if ($status == 2) $statusType = 'status4'; + + $param = array(); + if ($status == - 1) { + $param = array('badgeParams'=>array('attr'=>array('title'=>$desc))); } + return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode, '', $param); } } diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 0f3e42d366f..701dd2d4716 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -60,6 +60,7 @@ print '
'; // Recherche emails print '
'; print ''; + print '
'; print ''; print ''; print ''; - print "
'.$langs->trans("SearchAMailing").'
'; @@ -68,7 +69,7 @@ print '
'; print '
'; print $langs->trans("Other").':

\n"; + print "

\n"; //} @@ -131,7 +132,7 @@ if (is_resource($handle)) } else { - dol_print_error($db); + dol_print_error($db); } print ''; } @@ -160,6 +161,7 @@ $sql.= " ORDER BY m.date_creat DESC"; $sql.= " LIMIT ".$limit; $result=$db->query($sql); if ($result) { + print '
'; print ''; print ''; print ''; @@ -193,7 +195,7 @@ if ($result) { { print ''; } - print "
'.$langs->trans("LastMailings", $limit).'
'.$langs->trans("None").'

"; + print "

"; $db->free($result); } else diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 7b270e460c8..c0b01050d8f 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -33,7 +33,7 @@ $id=GETPOST('id'); $langs->load("mails"); // Security check -if (! $user->rights->mailing->lire || $user->societe_id > 0) +if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden(); @@ -57,7 +57,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) + { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright.=')   '; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 429e7f3dacf..c99048a8955 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -33,9 +33,9 @@ $langs->loadLangs(array('orders', 'companies')); $id = GETPOST('id', 'int'); $_socid = GETPOST("id", 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { - $_socid = $user->societe_id; + $_socid = $user->socid; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 70cd74ac149..17a4c485b3e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -9,10 +9,10 @@ * Copyright (C) 2010-2018 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cedric Salvador - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Ferran Marcet - * Copyright (C) 2016 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2016 Marcos García + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +58,7 @@ if (!empty($conf->variants->enabled)) { } // Load translation files required by the page -$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings')); +$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->margin->enabled)) $langs->load('margins'); @@ -86,7 +86,7 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($co $NBLINES = 4; // Security check -if (! empty($user->societe_id)) $socid = $user->societe_id; +if (! empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); @@ -121,6 +121,7 @@ $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; $usercancreateintervention = $user->rights->ficheinter->creer; +$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -165,7 +166,7 @@ if (empty($reshook)) if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference - $date_delivery = dol_mktime(12, 0, 0, + $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int') @@ -173,7 +174,7 @@ if (empty($reshook)) if (!empty($object->date_livraison) && !empty($date_delivery)) { //Attempt to get the date without possible hour rounding errors - $old_date_delivery = dol_mktime(12, 0, 0, + $old_date_delivery = dol_mktime(12, 0, 0, dol_print_date($object->date_livraison, '%m'), dol_print_date($object->date_livraison, '%d'), dol_print_date($object->date_livraison, '%Y') @@ -458,91 +459,91 @@ if (empty($reshook)) $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + $srcobject->fetch_lines(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; - } - - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - - // Date start - $date_start = false; - if ($lines[$i]->date_debut_prevue) - $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) - $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) - $date_start = $lines[$i]->date_start; - - // Date end - $date_end = false; - if ($lines[$i]->date_fin_prevue) - $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) - $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) - $date_end = $lines[$i]->date_end; - - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) - $error ++; - } else { - setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + + // Date start + $date_start = false; + if ($lines[$i]->date_debut_prevue) + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) + $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) + $date_start = $lines[$i]->date_start; + + // Date end + $date_end = false; + if ($lines[$i]->date_fin_prevue) + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) + $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) + $date_end = $lines[$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; + } + + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error ++; + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; @@ -919,8 +920,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer @@ -1324,17 +1325,17 @@ if (empty($reshook)) $object->setProject(GETPOST('projectid', 'int')); } - // Delai de livraison + // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); } - // Origine de la propale + // Origin of the commercial proposal elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int')); } - // Conditions de reglement + // Terms of payment elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } @@ -1347,7 +1348,7 @@ if (empty($reshook)) $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } - // Mode de reglement + // Payment choice elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } @@ -1412,7 +1413,7 @@ if (empty($reshook)) } } - // Bascule du statut d'un contact + // Toggle the status of a contact elseif ($action == 'swapstatut') { if ($object->fetch($id) > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); @@ -1421,7 +1422,7 @@ if (empty($reshook)) } } - // Efface un contact + // Delete a contact elseif ($action == 'deletecontact') { $object->fetch($id); $result = $object->delete_contact($lineid); @@ -1599,7 +1600,7 @@ if ($action == 'create') $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print ''; - // Ligne info remises tiers + // Third party discounts info line print '' . $langs->trans('Discounts') . ''; $absolute_discount = $soc->getAvailableDiscounts(); @@ -1716,7 +1717,7 @@ if ($action == 'create') print $doleditor->Create(1); // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print '' . $langs->trans('NotePrivate') . ''; @@ -1786,7 +1787,7 @@ if ($action == 'create') /* - * Combobox pour la fonction de copie + * Combobox for copy function */ if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print ''; @@ -1883,7 +1884,7 @@ if ($action == 'create') if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { $formquestion[] = array('type' => 'date','name' => 'date_delivery','label' => $langs->trans("DeliveryDate"),'value' => $object->date_livraison); } - // Paiement incomplet. On demande si motif = escompte ou autre + // Incomplete payment. We ask if reason = discount or other $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } @@ -1926,7 +1927,7 @@ if ($action == 'create') elseif ($action == 'validate') { $error = 0; - // We verifie whether the object is provisionally numbering + // We verify whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); @@ -2499,13 +2500,23 @@ if ($action == 'create') print '' . $langs->trans('SendMail') . ''; } - // Create an order + // Create a sale order if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateorder) { print '' . $langs->trans("AddOrder") . ''; } } + // Create a purchase order + if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) + { + if (! empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if ($usercancreatepurchaseorder) { + print '' . $langs->trans("AddPurchaseOrder") . ''; + } + } + } + // Create an intervention if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateintervention) { diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 7afb14a8da2..1337c62da94 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -227,7 +227,7 @@ class Proposals extends DolibarrApi } if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->propal->getLinesArray(); $result = array(); @@ -255,7 +255,7 @@ class Proposals extends DolibarrApi $result = $this->propal->fetch($id); if (! $result) { - throw new RestException(404, 'Commercial Proposal not found'); + throw new RestException(404, 'Commercial Proposal not found'); } if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a55b4a28172..0df1af873a8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -95,8 +95,17 @@ class Propal extends CommonObject */ public $socid; + /** + * ID of the contact + * @var int + */ public $contactid; public $author; + + /** + * Ref from thirdparty + * @var string + */ public $ref_client; /** @@ -192,8 +201,8 @@ class Propal extends CommonObject public $lines = array(); public $line; - public $labelstatut=array(); - public $labelstatut_short=array(); + public $labelStatus=array(); + public $labelStatusShort=array(); public $specimen; @@ -240,7 +249,7 @@ class Propal extends CommonObject * @param int $socid Id third party * @param int $propalid Id proposal */ - public function __construct($db, $socid = "", $propalid = 0) + public function __construct($db, $socid = 0, $propalid = 0) { global $conf,$langs; @@ -1686,13 +1695,13 @@ class Propal extends CommonObject $line->fk_product = $objp->fk_product; - $line->ref = $objp->product_ref; // TODO deprecated + $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // TODO deprecated + $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit $line->product_tobatch = $objp->product_tobatch; - $line->fk_product_type = $objp->fk_product_type; // TODO deprecated + $line->fk_product_type = $objp->fk_product_type; // deprecated $line->fk_unit = $objp->fk_unit; $line->weight = $objp->weight; $line->weight_units = $objp->weight_units; @@ -1714,9 +1723,9 @@ class Propal extends CommonObject // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$i] = $line; @@ -3200,40 +3209,40 @@ class Propal extends CommonObject /** * Return label of a status (draft, validated, ...) * - * @param int $statut id statut + * @param int $status Id status * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 1) + public function LibStatut($status, $mode = 1) { // phpcs:enable global $conf; // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("propal"); - $this->labelstatut[0]=$langs->trans("PropalStatusDraft"); - $this->labelstatut[1]=$langs->trans("PropalStatusValidated"); - $this->labelstatut[2]=$langs->trans("PropalStatusSigned"); - $this->labelstatut[3]=$langs->trans("PropalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("PropalStatusBilled"); - $this->labelstatut_short[0]=$langs->trans("PropalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("PropalStatusValidatedShort"); - $this->labelstatut_short[2]=$langs->trans("PropalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("PropalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort"); + $this->labelStatus[0]=$langs->trans("PropalStatusDraft"); + $this->labelStatus[1]=$langs->trans("PropalStatusValidated"); + $this->labelStatus[2]=$langs->trans("PropalStatusSigned"); + $this->labelStatus[3]=$langs->trans("PropalStatusNotSigned"); + $this->labelStatus[4]=$langs->trans("PropalStatusBilled"); + $this->labelStatusShort[0]=$langs->trans("PropalStatusDraftShort"); + $this->labelStatusShort[1]=$langs->trans("PropalStatusValidatedShort"); + $this->labelStatusShort[2]=$langs->trans("PropalStatusSignedShort"); + $this->labelStatusShort[3]=$langs->trans("PropalStatusNotSignedShort"); + $this->labelStatusShort[4]=$langs->trans("PropalStatusBilledShort"); } $statusType=''; - if ($statut==self::STATUS_DRAFT) $statusType='status0'; - elseif ($statut==self::STATUS_VALIDATED) $statusType='status1'; - elseif ($statut==self::STATUS_SIGNED) $statusType='status3'; - elseif ($statut==self::STATUS_NOTSIGNED) $statusType='status5'; - elseif ($statut==self::STATUS_BILLED) $statusType='status6'; + if ($status==self::STATUS_DRAFT) $statusType='status0'; + elseif ($status==self::STATUS_VALIDATED) $statusType='status1'; + elseif ($status==self::STATUS_SIGNED) $statusType='status3'; + elseif ($status==self::STATUS_NOTSIGNED) $statusType='status5'; + elseif ($status==self::STATUS_BILLED) $statusType='status6'; - return dolGetStatus($this->labelstatut[$statut], $this->labelstatut_short[$statut], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -3254,7 +3263,7 @@ class Propal extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -3263,7 +3272,7 @@ class Propal extends CommonObject $sql.= $clause." p.entity IN (".getEntity('propal').")"; if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED; if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED; - if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; + if ($user->socid) $sql.= " AND p.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -3272,17 +3281,17 @@ class Propal extends CommonObject $now=dol_now(); $delay_warning = 0; - $statut = 0; + $status = 0; $label = $labelShort = ''; if ($mode == 'opened') { $delay_warning=$conf->propal->cloture->warning_delay; - $statut = self::STATUS_VALIDATED; + $status = self::STATUS_VALIDATED; $label = $langs->trans("PropalsToClose"); $labelShort = $langs->trans("ToAcceptRefuse"); } if ($mode == 'signed') { $delay_warning=$conf->propal->facturation->warning_delay; - $statut = self::STATUS_SIGNED; + $status = self::STATUS_SIGNED; $label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered $labelShort = $langs->trans("ToBill"); } @@ -3291,8 +3300,8 @@ class Propal extends CommonObject $response->warning_delay = $delay_warning/60/60/24; $response->label = $label; $response->labelShort = $labelShort; - $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals'; - $response->url_late = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc'; + $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$status.'&mainmenu=commercial&leftmenu=propals'; + $response->url_late = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$status.'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc'; $response->img = img_object('', "propal"); // This assignment in condition is not a bug. It allows walking the results. @@ -3403,7 +3412,7 @@ class Propal extends CommonObject { $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; - $line->product_ref='SPECIMEN'; + $line->product_ref='SPECIMEN'; } $this->lines[$xnbp]=$line; @@ -3433,7 +3442,7 @@ class Propal extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -3919,7 +3928,7 @@ class PropaleLigne extends CommonObjectLine if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index bd0f57bc801..0859bdb7974 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -112,7 +112,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 96673084580..14f5913c4ce 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -41,7 +41,7 @@ $lineid=GETPOST('lineid', 'int'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); @@ -170,20 +170,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index eca5ce52fa7..55a21445be2 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -46,9 +46,9 @@ $ref = GETPOST('ref', 'alpha'); // Security check $socid=''; -if (! empty($user->societe_id)) +if (! empty($user->socid)) { - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'propal', $id); @@ -125,20 +125,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index a1104682904..d802548ac6b 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -38,10 +38,10 @@ $langs->loadLangs(array('propal', 'companies')); // Security check $socid=GETPOST('socid', 'int'); -if (isset($user->societe_id) && $user->societe_id > 0) +if (isset($user->socid) && $user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'propal'); @@ -87,7 +87,7 @@ $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal').")"; -if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND p.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND p.fk_statut IN (0,1,2,3,4)"; $sql.= " GROUP BY p.fk_statut"; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 108a09e7d07..1e27f187488 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -40,7 +40,7 @@ $ref=GETPOST('ref', 'alpha'); $socid=GETPOST('socid', 'int'); // Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); @@ -86,20 +86,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 919ad77168d..a83d7ee5161 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -112,7 +112,7 @@ if (! $sortorder) $sortorder='DESC'; $module='propal'; $dbtable=''; $objectid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; if (! empty($socid)) { $objectid=$socid; @@ -139,6 +139,7 @@ $fieldstosearchall = array( 'p.ref_client'=>'CustomerRef', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", 'p.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; @@ -279,8 +280,9 @@ $sql.= ' u.login'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -693,7 +695,7 @@ if ($resql) print ''; print ''; } - // Date cloture + // Date cloture if (! empty($arrayfields['p.date_cloture']['checked'])) { print ''; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 2a3f0438ad0..ee9d9bd9c4f 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -41,7 +41,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'propale', $id, 'propal'); $object = new Propal($db); @@ -101,20 +101,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 1d81b553f7a..a37006d60fb 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -42,10 +42,10 @@ $object_status=GETPOST('object_status'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -94,7 +94,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; @@ -134,7 +134,7 @@ if (! $mesg) $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, 0); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; @@ -173,7 +173,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); $fileurl_avg=''; -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4de75dc3225..ccc62ab98c4 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -29,11 +29,8 @@ if (empty($conf) || ! is_object($conf)) { exit; } -?> - - -\n"; global $user; @@ -45,51 +42,46 @@ $langs->load("propal"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> - - trans("Proposal"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + print ''; + print ''.$langs->trans("Proposal"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } - ?> - - getNomUrl(1); ?> - ref_client; ?> - date, 'day'); ?> - rights->propale->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> - getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - -'; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date, 'day').''; + print ''; + if ($user->rights->propale->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + print ''; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - ?> - - trans("Total"); ?> - - - - - - - -'; + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''; + print ''.price($total).''; + print ''; + print ''; + print "\n"; } -?> - +print "\n"; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index cdd94c9cf6c..485771939c4 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; $langs->load("propal"); -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index c1339f7ebe9..07741635bcc 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -32,10 +32,10 @@ if (! empty($conf->facture->enabled)) $langs->load("bills"); // Security check $socid = $_GET["socid"]; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->socid; } diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 7f16ce6b8b0..9605281d6ca 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -32,10 +32,10 @@ if (! empty($conf->facture->enabled)) $langs->load("bills"); // Security check $socid = $_GET["socid"]; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->socid; } diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index a704a4be173..32c6869d576 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -33,9 +33,9 @@ $id=GETPOST("id", 'int'); $socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $backtopage = GETPOST('backtopage', 'alpha'); @@ -116,7 +116,7 @@ if ($socid > 0) dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 002eb7288e2..523c6ebc7b1 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -40,9 +40,9 @@ $backtopage=GETPOST('backtopage', 'alpha'); // Security check $socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } @@ -252,7 +252,7 @@ if ($socid > 0) dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3854c51e29d..7fd0d7326c4 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -82,8 +82,8 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty( $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if (! empty($user->societe_id)) - $socid = $user->societe_id; +if (! empty($user->socid)) + $socid = $user->socid; $result = restrictedArea($user, 'commande', $id); $object = new Commande($db); @@ -106,6 +106,8 @@ $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancr $usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send); +$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; + $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissionedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php @@ -1801,7 +1803,7 @@ if ($action == 'create' && $usercancreate) print ''; // Note private - if (empty($user->societe_id)) { + if (empty($user->socid)) { print ''; print '' . $langs->trans('NotePrivate') . ''; print ''; @@ -2566,6 +2568,16 @@ if ($action == 'create' && $usercancreate) print '' . $langs->trans("AddAction") . ''; }*/ + // Create a purchase order + if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) + { + if (! empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if ($usercancreatepurchaseorder) { + print '' . $langs->trans("AddPurchaseOrder") . ''; + } + } + } + // Create intervention if ($conf->ficheinter->enabled) { $langs->load("interventions"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4cc922a8cbf..6e01ba2f5e2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -53,19 +53,22 @@ class Commande extends CommonOrder public $table_element='commande'; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = 'commandedet'; + /** + * @var string Name of class line + */ public $class_element_line = 'OrderLine'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Field name with ID of parent key if this field has a parent */ public $fk_element = 'fk_commande'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + * @var string String with name of icon for commande class. Here is object_order.png */ public $picto = 'order'; @@ -87,13 +90,23 @@ class Commande extends CommonOrder protected $table_ref_field = 'ref'; /** - * Client ID - * @var int + * @var int Thirparty ID */ public $socid; + /** + * @var string Thirparty ref of order + */ public $ref_client; + + /** + * @var string Internal ref for order + */ public $ref_int; + + /** + * @var int Contact ID + */ public $contactid; /** @@ -103,10 +116,9 @@ class Commande extends CommonOrder public $statut; /** - * Billed - * @var int + * @var int Status Billed or not */ - public $billed; // billed or not + public $billed; /** * @var int Draft Status of the order @@ -115,25 +127,22 @@ class Commande extends CommonOrder public $cond_reglement_code; /** - * @var int ID + * @var int bank account ID */ public $fk_account; /** - * It holds the label of the payment mode. Use it in case translation cannot be found. - * @var string + * @var string It holds the label of the payment mode. Use it in case translation cannot be found. */ public $mode_reglement; /** - * Payment mode id - * @var int + * @var int Payment mode id */ public $mode_reglement_id; /** - * Payment mode code - * @var string + * @var string Payment mode code */ public $mode_reglement_code; @@ -157,9 +166,13 @@ class Commande extends CommonOrder public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; - public $date; // Date commande + /** + * @var int Date of order + */ + public $date; /** + * @var int Date of order * @deprecated * @see $date */ @@ -182,7 +195,14 @@ class Commande extends CommonOrder public $linked_objects=array(); + /** + * @var int User author ID + */ public $user_author_id; + + /** + * @var int User validator ID + */ public $user_valid; /** @@ -192,7 +212,7 @@ class Commande extends CommonOrder // Multicurrency /** - * @var int ID + * @var int Currency ID */ public $fk_multicurrency; @@ -202,6 +222,9 @@ class Commande extends CommonOrder public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** + * @var Commande clone of order object + */ public $oldcopy; //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) @@ -3393,7 +3416,7 @@ class Commande extends CommonOrder $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -3402,7 +3425,7 @@ class Commande extends CommonOrder $sql.= $clause." c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0"; $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected - if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; + if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -3469,13 +3492,13 @@ class Commande extends CommonOrder /** * Return label of status * - * @param int $statut Id statut + * @param int $status Id status * @param int $billed If invoiced * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @param int $donotshowbilled Do not show billed status after order status * @return string Label of status */ - public function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) + public function LibStatut($status, $billed, $mode, $donotshowbilled = 0) { // phpcs:enable global $langs, $conf; @@ -3483,49 +3506,49 @@ class Commande extends CommonOrder $billedtext = ''; if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):''); - if ($statut==self::STATUS_CANCELED){ - $labelstatut = $langs->trans('StatusOrderCanceled'); - $labelstatutShort = $langs->trans('StatusOrderCanceledShort'); + if ($status==self::STATUS_CANCELED){ + $labelStatus = $langs->trans('StatusOrderCanceled'); + $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); $statusType='status5'; } - elseif ($statut==self::STATUS_DRAFT){ - $labelstatut = $langs->trans('StatusOrderDraft'); - $labelstatutShort = $langs->trans('StatusOrderDraftShort'); + elseif ($status==self::STATUS_DRAFT){ + $labelStatus = $langs->trans('StatusOrderDraft'); + $labelStatusShort = $langs->trans('StatusOrderDraftShort'); $statusType='status0'; } - elseif ($statut==self::STATUS_VALIDATED){ - $labelstatut = $langs->trans('StatusOrderValidated').$billedtext; - $labelstatutShort = $langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($status==self::STATUS_VALIDATED){ + $labelStatus = $langs->trans('StatusOrderValidated').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; $statusType='status1'; } - elseif ($statut==self::STATUS_SHIPMENTONPROCESS){ - $labelstatut = $langs->trans('StatusOrderSentShort').$billedtext; - $labelstatutShort = $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($status==self::STATUS_SHIPMENTONPROCESS){ + $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; $statusType='status3'; } - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ - $labelstatut = $langs->trans('StatusOrderToBill'); - $labelstatutShort = $langs->trans('StatusOrderToBillShort'); + elseif ($status==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelStatus = $langs->trans('StatusOrderToBill'); + $labelStatusShort = $langs->trans('StatusOrderToBillShort'); $statusType='status4'; } - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ - $labelstatut = $langs->trans('StatusOrderProcessed').$billedtext; - $labelstatutShort = $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($status==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; $statusType='status6'; } - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ - $labelstatut = $langs->trans('StatusOrderDelivered'); - $labelstatutShort = $langs->trans('StatusOrderDelivered'); + elseif ($status==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelStatus = $langs->trans('StatusOrderDelivered'); + $labelStatusShort = $langs->trans('StatusOrderDelivered'); $statusType='status6'; } else{ - $labelstatut = $langs->trans('Unknown'); - $labelstatutShort = ''; + $labelStatus = $langs->trans('Unknown'); + $labelStatusShort = ''; $statusType=''; $mode = 0; } - return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } @@ -3774,7 +3797,7 @@ class Commande extends CommonOrder $sql = "SELECT count(co.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as co"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 10276e34c0e..0311f4c49ed 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -212,7 +212,7 @@ class CommandeStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 57e37f9f903..97890c9d2ef 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -40,7 +40,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'commande', $id, ''); $object = new Commande($db); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 2f275adadb9..bcb445c546c 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -33,10 +33,10 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action=GETPOST('action', 'aZ09'); // Secrutiy check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } if (! $user->rights->facture->creer) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index fa825086c4a..565583e1fae 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -45,9 +45,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref'); // Security check -if ($user->societe_id) +if ($user->socid) { - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'commande', $id, ''); diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 2149c48121b..da1a4fc55df 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -42,10 +42,10 @@ $langs->loadLangs(array('orders', 'bills')); // Security check $socid=GETPOST('socid', 'int'); -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } @@ -92,7 +92,7 @@ $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('societe').")"; -if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY c.fk_statut"; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 7d8e319c5ae..4ca81f77771 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -42,7 +42,7 @@ $id = GETPOST("id", 'int'); $ref=GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'commande', $comid, ''); $object = new Commande($db); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 115bc46813a..df596b6d52f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -88,7 +88,7 @@ $search_project=GETPOST('search_project', 'alpha'); // Security check $id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int')); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'commande', $id, ''); $diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; @@ -120,6 +120,7 @@ $fieldstosearchall = array( 'c.ref_client'=>'RefCustomerOrder', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", 'c.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; @@ -768,6 +769,7 @@ if ($resql) $total=0; $subtotal=0; $productstat_cache=array(); + $getNomUrl_cache=array(); $generic_commande = new Commande($db); $generic_product = new Product($db); @@ -784,11 +786,14 @@ if ($resql) $text_warning=''; $nbprod=0; - $companystatic->id=$obj->socid; + $companystatic->id = $obj->socid; $companystatic->code_client = $obj->code_client; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->email=$obj->email; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->email = $obj->email; + if (!isset($getNomUrl_cache[$obj->socid])) { + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + } $generic_commande->id=$obj->rowid; $generic_commande->ref=$obj->ref; @@ -973,7 +978,7 @@ if ($resql) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - print $companystatic->getNomUrl(1, 'customer'); + print $getNomUrl_cache[$obj->socid]; // If module invoices enabled and user with invoice creation permissions if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 2cb69bd698b..5b8fe052b06 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -42,7 +42,7 @@ $action=GETPOST('action', 'alpha'); // Security check $socid=0; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'commande', $id, ''); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index fae23fa8bcd..35756a56487 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -139,7 +139,7 @@ if (($action == 'create' || $action == 'add') && !$error) // Security check $fieldid = GETPOST('ref', 'alpha')?'ref':'rowid'; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; @@ -503,7 +503,7 @@ if ($action == 'create' && !$error) print ''; // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print ''.$langs->trans('NotePrivate').''; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 696823f4e41..bdf277bc375 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -43,10 +43,10 @@ $object_status=GETPOST('object_status'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -101,7 +101,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; @@ -144,7 +144,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; @@ -185,7 +185,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index cbecd9cbc05..f9d7e44794c 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -73,7 +73,7 @@ $arrayfields=array( if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) { +if ($user->socid > 0) { accessforbidden(); } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index b82cee983f9..b5839db2200 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -41,7 +41,7 @@ $ref=GETPOST('ref'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); $fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); $year_start=GETPOST('year_start'); @@ -306,7 +306,7 @@ else $log="graph.php: min=".$min." max=".$max; dol_syslog($log); -// CRED PART + // CRED PART // Chargement du tableau des années $tblyear[0] = array(); $tblyear[1] = array(); @@ -393,7 +393,7 @@ else unset($tblyear[1]); unset($tblyear[2]); -// DEDBT PART + // DEDBT PART // Chargement du tableau des années $tblyear[0] = array(); $tblyear[1] = array(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 61278b9b9f5..d2b998be2d9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -66,12 +66,12 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); $fieldtype = (! empty($ref) ? 'ref' :'rowid'); if ($fielvalue) { - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); } else { - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque'); } @@ -157,13 +157,16 @@ $arrayfields=array( 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile'?1:0), 'position'=>1020), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -1312,33 +1315,33 @@ if ($resql) // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { - print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print "\n"; + print ''; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; if (! $i) $totalarray['nbfield']++; } // Date value if (! empty($arrayfields['b.datev']['checked'])) { - print ''; - print ''.dol_print_date($db->jdate($objp->dv), "day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print "\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print ''.dol_print_date($db->jdate($objp->dv), "day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; } // Payment type @@ -1349,7 +1352,7 @@ if ($resql) if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } // Num cheque diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 41275ec2a40..c9c5a0f77fe 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque'); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index fb6d723ad7e..702d3bbc113 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -47,12 +47,9 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); // Security check -if (isset($_GET["id"]) || isset($_GET["ref"])) -{ - $id = isset($_GET["id"])?GETPOST("id"):(isset($_GET["ref"])?GETPOST("ref"):''); -} -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +$id = GETPOST("id", 'int') ? GETPOST("id", 'int'): GETPOST('ref', 'alpha'); +$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; + $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $object = new Account($db); @@ -79,12 +76,12 @@ if ($action == 'add') // Create account $object = new Account($db); - $object->ref = dol_sanitizeFileName(trim($_POST["ref"])); - $object->label = trim($_POST["label"]); - $object->courant = $_POST["type"]; - $object->clos = $_POST["clos"]; - $object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; - $object->url = $_POST["url"]; + $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); + $object->label = trim(GETPOST("label", 'alphanohtml')); + $object->courant = $_POST["type"]; + $object->clos = $_POST["clos"]; + $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); + $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim($_POST["bank"]); $object->code_banque = trim($_POST["code_banque"]); @@ -93,27 +90,34 @@ if ($action == 'add') $object->cle_rib = trim($_POST["cle_rib"]); $object->bic = trim($_POST["bic"]); $object->iban = trim($_POST["iban"]); - $object->domiciliation = trim($_POST["domiciliation"]); + $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim($_POST["proprio"]); - $object->owner_address = trim($_POST["owner_address"]); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alpha'); - if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; } else { $object->account_number = $account_number; } + $account_number = GETPOST('account_number', 'alphanohtml'); + if (empty($account_number) || $account_number == '-1') + { + $object->account_number = ''; + } + else + { + $object->account_number = $account_number; + } $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } $object->solde = $_POST["solde"]; - $object->date_solde = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int')); $object->currency_code = trim($_POST["account_currency_code"]); - $object->state_id = $_POST["account_state_id"]; - $object->country_id = $_POST["account_country_id"]; + $object->state_id = GETPOST("account_state_id", 'int'); + $object->country_id = GETPOST("account_country_id", 'int'); $object->min_allowed = GETPOST("account_min_allowed", 'int'); $object->min_desired = GETPOST("account_min_desired", 'int'); - $object->comment = trim(GETPOST("account_comment")); + $object->comment = trim(GETPOST("account_comment", 'none')); $object->fk_user_author = $user->id; @@ -176,14 +180,14 @@ if ($action == 'update') // Update account $object = new Account($db); - $object->fetch(GETPOST("id")); + $object->fetch(GETPOST("id", 'int')); - $object->ref = dol_string_nospecial(trim($_POST["ref"])); - $object->label = trim($_POST["label"]); + $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); + $object->label = trim(GETPOST("label", 'alphanohtml')); $object->courant = $_POST["type"]; $object->clos = $_POST["clos"]; - $object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; - $object->url = trim($_POST["url"]); + $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); + $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim($_POST["bank"]); $object->code_banque = trim($_POST["code_banque"]); @@ -192,10 +196,10 @@ if ($action == 'update') $object->cle_rib = trim($_POST["cle_rib"]); $object->bic = trim($_POST["bic"]); $object->iban = trim($_POST["iban"]); - $object->domiciliation = trim($_POST["domiciliation"]); + $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim($_POST["proprio"]); - $object->owner_address = trim($_POST["owner_address"]); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); $account_number = GETPOST('account_number', 'alpha'); if (empty($account_number) || $account_number == '-1') @@ -211,12 +215,12 @@ if ($action == 'update') $object->currency_code = trim($_POST["account_currency_code"]); - $object->state_id = $_POST["account_state_id"]; - $object->country_id = $_POST["account_country_id"]; + $object->state_id = GETPOST("account_state_id", 'int'); + $object->country_id = GETPOST("account_country_id", 'int'); $object->min_allowed = GETPOST("account_min_allowed", 'int'); $object->min_desired = GETPOST("account_min_desired", 'int'); - $object->comment = trim(GETPOST("account_comment")); + $object->comment = trim(GETPOST("account_comment", 'none')); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { @@ -289,7 +293,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> } else { - setEventMessages($account->error, $account->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action=''; } } @@ -410,10 +414,15 @@ if ($action == 'create') { print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + + $arrayselected = array(); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); - foreach($cats as $cat) { - $arrayselected[] = $cat->id; + if (is_array($cats)) + { + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print ""; @@ -625,8 +634,8 @@ else print ''.$langs->trans("Conciliable").''; print ''; $conciliate=$object->canBeConciliated(); - if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; - elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; + if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; + elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5cd3902b7d1..57cff121010 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1082,38 +1082,27 @@ class Account extends CommonObject /** * Return label of given object status * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; $langs->load('banks'); - if ($statut == self::STATUS_OPEN) { + if ($status == self::STATUS_OPEN) { $label = $langs->trans("StatusAccountOpened"); - $picto = img_picto($label, 'statut4'); + $labelshort = $langs->trans("StatusAccountOpened"); + $statusType = 'status4'; } else { $label = $langs->trans("StatusAccountClosed"); - $picto = img_picto($label, 'statut5'); + $labelshort = $langs->trans("StatusAccountClosed"); + $statusType = 'status5'; } - if ($mode == 2) { - return $picto.' '.$label; - } elseif ($mode == 3) { - return $picto; - } elseif ($mode == 4) { - return $picto.' '.$label; - } elseif ($mode == 5) { - return $label.' '.$picto; - } elseif ($mode == 6) { - return $label.' '.$picto; - } - - //There is no short mode for this label - return $label; + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } @@ -1199,7 +1188,7 @@ class Account extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT b.rowid, b.datev as datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; @@ -1255,7 +1244,7 @@ class Account extends CommonObject // phpcs:enable global $user; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT count(b.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; @@ -1294,7 +1283,7 @@ class Account extends CommonObject global $db, $conf, $user; //Protection against external users - if ($user->societe_id) { + if ($user->socid) { return 0; } @@ -1371,10 +1360,10 @@ class Account extends CommonObject $linkstart = 'global->BANK_SHOW_ORDER_OPTION) + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', + $conf->global->BANK_SHOW_ORDER_OPTION) ); } } @@ -2318,11 +2307,11 @@ class AccountLine extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -2330,33 +2319,33 @@ class AccountLine extends CommonObject /* if ($mode == 0) { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); + if ($status==0) return $langs->trans("ActivityCeased"); + if ($status==1) return $langs->trans("InActivity"); } if ($mode == 1) { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); + if ($status==0) return $langs->trans("ActivityCeased"); + if ($status==1) return $langs->trans("InActivity"); } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 5) { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + if ($status==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($status==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index ed94c8e4700..ca3acd59e42 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -523,46 +523,46 @@ class PaymentVarious extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id status + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } elseif ($mode == 4) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } } diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 32bfe66f7d1..1a250a83b10 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -46,14 +46,12 @@ if (isset($_SESSION['DolMessage'])) { } // Security check -if ($user->societe_id) { +if ($user->socid) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } -if ($user->societe_id) - $socid = $user->societe_id; -$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', - $fieldtype); +if ($user->socid) + $socid = $user->socid; // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -69,8 +67,10 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id) - $object->fetch($id); +if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); + +$result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); + /* * Actions @@ -105,14 +105,14 @@ if ($id > 0 || !empty($ref)) { // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', - $sortfield, - (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { $totalsize+=$file['size']; } + $morehtmlref = ''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 4ad0fe0e261..15f6a1236d5 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -40,7 +40,7 @@ if (isset($_GET["account"]) || isset($_GET["ref"])) $id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); } $fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $account=GETPOST("account"); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 389cde747af..7e96ddf31be 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -53,7 +53,7 @@ $cancel=GETPOST('cancel', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); $fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 6a143d4a8d1..524e3f44cbc 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -50,7 +50,7 @@ $search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opene $optioncss = GETPOST('optioncss', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; if (! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with list of banks accounting account allowed to manager of chart account if (! $allowed) $result=restrictedArea($user, 'banque'); @@ -98,13 +98,16 @@ $arrayfields=array( 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ae01b761b1b..cb029902372 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -57,7 +57,7 @@ $newbankreceipt=GETPOST('newbankreceipt', 'alpha'); // Security check $fieldid = (! empty($ref)?$ref:$id); $fieldname = isset($ref)?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname); if ($user->rights->banque->consolidate && $action == 'dvnext' && ! empty($dvid)) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index eeea2b72ce5..7ca62b67ab8 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -42,7 +42,7 @@ if (isset($_GET["account"]) || isset($_GET["ref"])) $id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); } $fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); @@ -258,7 +258,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) { $socialcontribstatic->ref=$obj->ref; $socialcontribstatic->id=$obj->objid; - $socialcontribstatic->lib=$obj->type; + $socialcontribstatic->label=$obj->type; $ref = $socialcontribstatic->getNomUrl(1, 24); $totalpayment = -1*$socialcontribstatic->getSommePaiement(); // Payment already done @@ -322,7 +322,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print ""; - print "
"; + print "
"; } else { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 9260ee3f1f9..30472729d92 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -57,7 +57,7 @@ $category_transaction = GETPOST("category_transaction", 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', '', ''); $object = new PaymentVarious($db); @@ -427,19 +427,20 @@ if ($id) $morehtmlref.=$langs->trans('Project') . ' '; if ($user->rights->banque->modifier) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index a196540d484..7070946e2c7 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', '', ''); // Get parameters @@ -92,19 +92,20 @@ if ($object->id) $morehtmlref.=$langs->trans('Project') . ' : '; if ($user->rights->banque->modifier && 0) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 4cc64bb830e..7498872881d 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -35,7 +35,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', '', ''); /* @@ -61,19 +61,20 @@ if (! empty($conf->projet->enabled)) $morehtmlref.=$langs->trans('Project') . ' : '; if ($user->rights->banque->modifier && 0) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 6c15c40ecaa..cad88367aa0 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -35,7 +35,7 @@ $langs->loadLangs(array("compta","banks","bills","accountancy")); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', '', ''); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 6b767bc3949..e0461d35368 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -90,9 +90,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'monmodule', $id, ''); @@ -322,7 +322,7 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +//if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -336,13 +336,9 @@ print ''; print ''; print ''; -$newcardbutton=''; -//if ($user->rights->monmodule->creer) - //{ -$newcardbutton=''.$langs->trans('New').''; -$newcardbutton.= ''; -$newcardbutton.= ''; -//} +$permforcashfence = 1; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit); @@ -389,12 +385,18 @@ print ''; foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -416,15 +418,15 @@ print ''."\n"; print ''; foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; - } + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -467,25 +469,21 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield=(empty($val['css'])?'':$val['css']); + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 87db81bf98d..00d77987d08 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -87,7 +87,13 @@ class CashControl extends CommonObject public $cheque; public $card; public $date_valid; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_modification; const STATUS_DRAFT = 0; @@ -311,47 +317,20 @@ class CashControl extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); - $this->labelstatus[0] = $langs->trans('Draft'); - $this->labelstatus[1] = $langs->trans('Closed'); + $this->labelStatus[0] = $langs->trans('Draft'); + $this->labelStatus[1] = $langs->trans('Closed'); + $this->labelStatusShort[0] = $langs->trans('Draft'); + $this->labelStatusShort[1] = $langs->trans('Closed'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status0'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 01cda8871b5..5fe9853ec54 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -45,7 +45,7 @@ $hookmanager->initHooks(array('specialexpensesindex')); $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); $mode=GETPOST("mode", 'alpha'); @@ -138,7 +138,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; - $sql = "SELECT c.id, c.libelle as lib,"; + $sql = "SELECT c.id, c.libelle as label,"; $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; $sql.= " pct.code as payment_code,"; @@ -185,12 +185,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // Label print ''; // Type - print ''; + print ''; // Expected to pay print ''; // Ref payment diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index b7652587826..15f3504268b 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -30,10 +30,10 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action=GETPOST('action', 'aZ09'); // Secrutiy check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } if (! $user->rights->facture->lire) diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index adb5a74425c..dd56e611545 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -40,7 +40,7 @@ $langs->load("trips"); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); $action = GETPOST('action', 'alpha'); @@ -287,7 +287,7 @@ if ($action == 'create') print ''; // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print ''; @@ -385,7 +385,7 @@ elseif ($id) print ""; // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print '"; @@ -3332,7 +3334,7 @@ if ($action == 'create') print $doleditor->Create(1); // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print ''; print ''; print '\n"; - if (! $i) $totalarray['nbfield']++; + print '\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.nom']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.total']['checked'])) { - print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; - $totalarray['val']['f.total'] += $objp->total; + print ''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; + $totalarray['val']['f.total'] += $objp->total; } if (! empty($arrayfields['f.tva']['checked'])) { - print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; - $totalarray['val']['f.tva'] += $objp->total_vat; + print ''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; + $totalarray['val']['f.tva'] += $objp->total_vat; } if (! empty($arrayfields['f.total_ttc']['checked'])) { - print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; + print ''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''."\n"; - if (! $i) $totalarray['nbfield']++; + print ''."\n"; + if (! $i) $totalarray['nbfield']++; } // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''."\n"; - if (! $i) $totalarray['nbfield']++; + print ''."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['recurring']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.frequency']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.unit_frequency']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.nb_gen_done']['checked'])) { @@ -586,10 +587,10 @@ if ($resql) // Date last generation if (! empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } // Date next generation if (! empty($arrayfields['f.date_when']['checked'])) @@ -611,17 +612,17 @@ if ($resql) } if (! empty($arrayfields['f.datec']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.tms']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } $obj = $objp; @@ -632,12 +633,11 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status - if (! empty($arrayfields['status']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; + if (! empty($arrayfields['status']['checked'])) { + print ''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; $i=0; while ($i < $totalarray['nbfield']) { - $i++; - if ($i == 1) - { + $i++; + if ($i == 1) + { if ($num < $limit && empty($offset)) print ''; else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''; - elseif ($totalarray['totallocaltax2field'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - elseif ($totalarray['totalamfield'] == $i) print ''; - elseif ($totalarray['totalrtpfield'] == $i) print ''; - else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''; + elseif ($totalarray['totallocaltax2field'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + elseif ($totalarray['totalamfield'] == $i) print ''; + elseif ($totalarray['totalrtpfield'] == $i) print ''; + else print ''; } print ''; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index beeb5f730ab..ff71b1ff9af 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -43,7 +43,7 @@ $action=GETPOST('action', 'alpha'); // Security check $socid=0; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'facture', $id, ''); $object = new Facture($db); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 45bbfc3eef3..485401d340e 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -47,7 +47,7 @@ $socid=GETPOST('socid', 'int'); $action=GETPOST('action', 'alpha'); $fieldid = (! empty($ref)?'ref':'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $object = new Facture($db); @@ -189,20 +189,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index d475c5c3e5f..5f81d34a092 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -41,10 +41,10 @@ $object_status=GETPOST('object_status'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -159,7 +159,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; @@ -233,48 +233,45 @@ foreach ($tmp_companies as $value) { print '
'; -//if (empty($socid)) -//{ - // Show filter box - print '
'; - print ''; - print '
'; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + else print ''; + print '
'; $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->libelle; - $socialcontrib->lib=$obj->libelle; + $socialcontrib->ref=$obj->label; + $socialcontrib->label=$obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.$obj->lib.''.$obj->label.''.price($obj->total).'
'.$langs->trans('NotePrivate').'
'.$langs->trans("NotePrivate").''; @@ -415,9 +415,9 @@ elseif ($id) } else { - /* - * Confirm delete trip - */ + /* + * Confirm delete trip + */ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index de32cb9c3eb..0601c62fd80 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -89,11 +89,11 @@ class Deplacement extends CommonObject public $statuts=array(); public $statuts_short=array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + */ public function __construct($db) { $this->db = $db; @@ -249,13 +249,13 @@ class Deplacement extends CommonObject } } - /** - * Load an object from database - * - * @param int $id Id of record to load - * @param string $ref Ref of record - * @return int <0 if KO, >0 if OK - */ + /** + * Load an object from database + * + * @param int $id Id of record to load + * @param string $ref Ref of record + * @return int <0 if KO, >0 if OK + */ public function fetch($id, $ref = '') { $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams"; @@ -293,12 +293,12 @@ class Deplacement extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); @@ -336,46 +336,46 @@ class Deplacement extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id status + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } elseif ($mode == 4) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==2 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } } @@ -413,9 +413,9 @@ class Deplacement extends CommonObject */ public function listOfTypes($active = 1) { - global $langs; + global $langs; - $ret=array(); + $ret=array(); $sql = "SELECT id, code, label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees"; diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 3f2faa267ea..96c8013c18c 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 0208f9da89f..659744a2ba0 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', '', ''); $sortfield = GETPOST("sortfield", 'alpha'); @@ -143,11 +143,11 @@ $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user"; $sql.= " AND d.entity = ".$conf->entity; if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_soc = ".$socid; $sql.= $db->order("d.tms", "DESC"); $sql.= $db->plimit($max, 0); diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index 510675265a0..28d1d8e68da 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -32,7 +32,7 @@ $langs->load("trips"); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 9b5b2b7d9c9..6d5d952d104 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -36,7 +36,7 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', '', ''); $search_ref=GETPOST('search_ref', 'int'); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 54e1cd1524e..ccb2ecb60fe 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -38,12 +38,12 @@ $socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; $id = GETPOST('id', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); // Other security check @@ -162,7 +162,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fe88c9ec717..7296bc524e2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -14,7 +14,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +130,7 @@ $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatede // Security check $fieldid = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid = $user->societe_id; +if ($user->socid) $socid = $user->socid; $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -809,14 +809,16 @@ if (empty($reshook)) // Total credit note and deposit $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; - $resql = $db->query($sql); - if (!empty($resql)) { - while ($obj = $db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; - } else dol_print_error($db); + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; + $sql .= " WHERE fk_facture = " . $object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -1516,7 +1518,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, @@ -2726,7 +2728,7 @@ if ($action == 'create') $text.=' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
'; } @@ -3274,12 +3276,12 @@ if ($action == 'create') print '
'; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; $liste = ModelePDFFactures::liste_modeles($db); - if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)){ // Hidden conf - $paramkey='FACTURE_ADDON_PDF_'.$object->type; - $curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF; - } - else{ - $curent = $conf->global->FACTURE_ADDON_PDF; + if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)){ + // Hidden conf + $paramkey='FACTURE_ADDON_PDF_'.$object->type; + $curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF; + } else { + $curent = $conf->global->FACTURE_ADDON_PDF; } print $form->selectarray('model', $liste, $curent); print "
'; @@ -3458,7 +3460,7 @@ elseif ($id > 0 || ! empty($ref)) // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); - if ($user->societe_id > 0 && $user->societe_id != $object->socid) + if ($user->socid > 0 && $user->socid != $object->socid) { accessforbidden('', 0, 1); } @@ -3803,19 +3805,20 @@ elseif ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($usercancreate) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -4544,7 +4547,7 @@ elseif ($id > 0 || ! empty($ref)) } print '
' . price($sign * $objp->amount) . ''; - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print 'rowid.'">'; print img_delete(); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 654af5aeaac..da5ad40002b 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -415,7 +415,7 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } - /** + /** * Delete a contact type of given invoice * * @param int $id Id of invoice to update @@ -529,10 +529,9 @@ class Invoices extends DolibarrApi // update bank account if (!empty($this->invoice->fk_account)) { - if($this->invoice->setBankAccount($this->invoice->fk_account) == 0) - { - throw new RestException(400, $this->invoice->error); - } + if ($this->invoice->setBankAccount($this->invoice->fk_account) == 0) { + throw new RestException(400, $this->invoice->error); + } } if($this->invoice->update(DolibarrApiAccess::$user)) @@ -566,7 +565,7 @@ class Invoices extends DolibarrApi throw new RestException(500); } - return array( + return array( 'success' => array( 'code' => 200, 'message' => 'Invoice deleted' @@ -909,18 +908,18 @@ class Invoices extends DolibarrApi $result = $this->invoice->fetch($id); - if( ! $result ) { + if (! $result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($this->invoice); } - /** + /** * Create a discount (credit available) for a credit note or a deposit. * * @param int $id Invoice ID diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0cb6921a6f3..ac39b84e428 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -862,10 +862,10 @@ class Facture extends CommonInvoice if (! $error && ! $notrigger) { - // Call trigger - $result=$this->call_trigger('BILL_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result=$this->call_trigger('BILL_CREATE', $user); + if ($result < 0) $error++; + // End call triggers } if (! $error) @@ -1127,7 +1127,7 @@ class Facture extends CommonInvoice { $line = new FactureLigne($this->db); - $line->libelle = $object->lines[$i]->libelle; + $line->libelle = $object->lines[$i]->libelle; // deprecated $line->label = $object->lines[$i]->label; $line->desc = $object->lines[$i]->desc; $line->subprice = $object->lines[$i]->subprice; @@ -1551,7 +1551,7 @@ class Facture extends CommonInvoice $line->product_type = $objp->product_type; // Type of line $line->ref = $objp->product_ref; // Ref product $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // TODO deprecated + $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; // Label product $line->product_desc = $objp->product_desc; // Description product $line->fk_product_type = $objp->fk_product_type; // Type of product @@ -1605,9 +1605,9 @@ class Facture extends CommonInvoice // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$i] = $line; @@ -2545,7 +2545,7 @@ class Facture extends CommonInvoice if (empty($final)) $this->situation_final = 0; else $this->situation_final = 1; - $this->setFinal($user); + $this->setFinal($user); } } } @@ -2587,10 +2587,12 @@ class Facture extends CommonInvoice $next_invoice->brouillon = 1; foreach ($next_invoice->lines as $line) { - $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, - $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, - $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, - $line->fk_unit); + $result = $next_invoice->updateline( + $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit + ); if ($result < 0) { @@ -3959,7 +3961,7 @@ class Facture extends CommonInvoice $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -3968,7 +3970,7 @@ class Facture extends CommonInvoice $sql.= $clause." f.paye=0"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; - if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; + if ($user->socid) $sql.= " AND f.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -4209,7 +4211,7 @@ class Facture extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 5fb26a21cd6..72bb79545e5 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -45,7 +45,7 @@ $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'facture', $id); $object = new Facture($db); @@ -163,20 +163,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 9527f66b79e..36f768991f8 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -49,9 +49,9 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) +if ($user->socid) { - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'facture', $id, ''); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fb56ccb916f..2c5cd1a87c7 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -58,7 +58,7 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoice $id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); $lineid=GETPOST('lineid', 'int'); $ref=GETPOST('ref', 'alpha'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); @@ -1039,7 +1039,7 @@ if ($action == 'create') print $doleditor->Create(1); // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print '
'; @@ -1242,19 +1242,20 @@ else $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index e13dc30204f..09873f5ee61 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -58,7 +58,7 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoice $id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); $lineid=GETPOST('lineid', 'int'); $ref=GETPOST('ref', 'alpha'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); @@ -223,8 +223,9 @@ $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended, $sql.= " f.datec, f.tms,"; $sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -513,68 +514,68 @@ if ($resql) if (! empty($arrayfields['f.titre']['checked'])) { - print '
'; - print $invoicerectmp->getNomUrl(1); - print ""; - print "'; + print $invoicerectmp->getNomUrl(1); + print ""; + print "'.$companystatic->getNomUrl(1, 'customer').''.$companystatic->getNomUrl(1, 'customer').''.price($objp->total).''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_vat).''.price($objp->total_ttc).''.price($objp->total_ttc).''; - print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); - print ''; + print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); + print ''; - print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); - print ''; + print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); + print ''.yn($objp->frequency?1:0).''.yn($objp->frequency?1:0).''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); - print ''; + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); + print ''; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print ''; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print ''; - print dol_print_date($db->jdate($objp->tms), 'dayhour'); - print ''; + print dol_print_date($db->jdate($objp->tms), 'dayhour'); + print ''; - print $invoicerectmp->getLibStatut(3, 0); - print ''; + print $invoicerectmp->getLibStatut(3, 0); + print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4642c0b7da1..ae24277a896 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -128,7 +128,7 @@ $pagenext = $page + 1; // Security check $fieldid = (! empty($ref)?'ref':'rowid'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $diroutputmassaction=$conf->facture->dir_output . '/temp/massgeneration/'.$user->id; @@ -400,8 +400,9 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -1346,32 +1347,31 @@ if ($resql) // Show total line if (isset($totalarray['totalhtfield']) - || isset($totalarray['totalvatfield']) - || isset($totalarray['totallocaltax1field']) - || isset($totalarray['totallocaltax2field']) - || isset($totalarray['totalttcfield']) - || isset($totalarray['totalamfield']) - || isset($totalarray['totalrtpfield']) - ) - { + || isset($totalarray['totalvatfield']) + || isset($totalarray['totallocaltax1field']) + || isset($totalarray['totallocaltax2field']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).'
'; - print ''; - // Company - print ''; - // User - print ''; - // Status - print ''; - // Year - print ''; - print ''; - print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; - if ($mode == 'customer') $filter='s.client in (1,2,3)'; - if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); - print '
'.$langs->trans("CreatedBy").''; - print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print '
'.$langs->trans("Status").''; - if ($mode == 'customer') - { - $liststatus=array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); - } - if ($mode == 'supplier') - { - $liststatus=array('0'=>$langs->trans("BillStatusDraft"),'1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); - } - print '
'.$langs->trans("Year").''; - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; - arsort($arrayyears); - print $form->selectarray('year', $arrayyears, $year, 0); - print '
'; - print ''; - print '

'; -//} +// Show filter box +print '
'; +print ''; +print ''; +print ''; +// Company +print ''; +// User +print ''; +// Status +print ''; +// Year +print ''; +print ''; +print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; +if ($mode == 'customer') $filter='s.client in (1,2,3)'; +if ($mode == 'supplier') $filter='s.fournisseur = 1'; +print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); +print '
'.$langs->trans("CreatedBy").''; +print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); +print '
'.$langs->trans("Status").''; +if ($mode == 'customer') +{ + $liststatus=array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); +} +if ($mode == 'supplier') +{ + $liststatus=array('0'=>$langs->trans("BillStatusDraft"),'1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); +} +print '
'.$langs->trans("Year").''; +if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; +if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; +arsort($arrayyears); +print $form->selectarray('year', $arrayyears, $year, 0); +print '
'; +print '
'; +print '

'; print '
'; print ''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index b48c0478609..d2cad75ca77 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -24,11 +24,7 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - - - -\n"; global $user; global $noMoreLinkedObjectBlockAfter; @@ -40,73 +36,70 @@ $langs->load("bills"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> - - - - - - - - - -element.'" data-id="'.$objectlink->id.'" >'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - ?> - - - - - - - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } -?> - +print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index f6f854d9635..cb16ce407f8 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -24,11 +24,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("bills"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> + if ($user->rights->facture->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + ?> - 1) { @@ -75,6 +75,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index c56b663a77b..8531249afdb 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -56,10 +56,10 @@ $bid=GETPOST('bid', 'int'); // Security check $socid=''; -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $max=3; @@ -115,6 +115,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print '
type) { - case Facture::TYPE_REPLACEMENT: - echo $langs->trans("InvoiceReplacement"); - break; - case Facture::TYPE_CREDIT_NOTE: - echo $langs->trans("InvoiceAvoir"); - break; - case Facture::TYPE_DEPOSIT: - echo $langs->trans("InvoiceDeposit"); - break; - case Facture::TYPE_PROFORMA: - echo $langs->trans("InvoiceProForma"); - break; - case Facture::TYPE_SITUATION: - echo $langs->trans("InvoiceSituation"); - break; - default: - echo $langs->trans("CustomerInvoice"); - break; - } - ?>getNomUrl(1); ?>ref_client; ?>date, 'day'); ?>rights->facture->lire) { - $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) // If not abandonned - { - $total = $total + $sign * $objectlink->total_ht; - echo price($objectlink->total_ht); - } - else - { - echo ''.price($objectlink->total_ht).''; - } - } ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; + switch ($objectlink->type) { + case Facture::TYPE_REPLACEMENT: + echo $langs->trans("InvoiceReplacement"); + break; + case Facture::TYPE_CREDIT_NOTE: + echo $langs->trans("InvoiceAvoir"); + break; + case Facture::TYPE_DEPOSIT: + echo $langs->trans("InvoiceDeposit"); + break; + case Facture::TYPE_PROFORMA: + echo $langs->trans("InvoiceProForma"); + break; + case Facture::TYPE_SITUATION: + echo $langs->trans("InvoiceSituation"); + break; + default: + echo $langs->trans("CustomerInvoice"); + break; + } + print ''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; + if ($user->rights->facture->lire) { + $sign = 1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; + if ($objectlink->statut != 3) { + // If not abandonned + $total = $total + $sign * $objectlink->total_ht; + echo price($objectlink->total_ht); + } + else + { + echo ''.price($objectlink->total_ht).''; + } + } + print ''.$objectlink->getLibStatut(3).''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'
trans("Total"); ?>
'.$langs->trans("Total").''.price($total).'
trans("RepeatableInvoice"); ?> getNomUrl(1); ?> date_when, 'day'); ?> rights->facture->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; $i=0; foreach($listofsearchfields as $key => $value) @@ -127,6 +128,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print ''; print '
'; } @@ -165,6 +167,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $num = $db->num_rows($resql); + print '
'; print ''; print ''; print ''; @@ -216,7 +219,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; } - print "
'.$langs->trans("CustomersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("NoInvoice").'

"; + print "

"; $db->free($resql); } else @@ -251,6 +254,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $num = $db->num_rows($resql); + print '
'; print ''; print ''; print ''; @@ -303,7 +307,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { print ''; } - print "
'.$langs->trans("SuppliersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("NoInvoice").'

"; + print "

"; $db->free($resql); } else @@ -620,12 +624,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $chargestatic=new ChargeSociales($db); $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; - $sql.= " cc.libelle,"; + $sql.= " cc.libelle as label,"; $sql.= " SUM(pc.amount) as sumpaid"; $sql.= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid"; $sql.= " WHERE c.fk_type = cc.id"; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('tax').')'; $sql.= " AND c.paye = 0"; // Add where from hooks $parameters=array(); @@ -657,8 +661,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $obj = $db->fetch_object($resql); $chargestatic->id=$obj->rowid; - $chargestatic->ref=$obj->libelle; - $chargestatic->lib=$obj->libelle; + $chargestatic->ref=$obj->rowid; + $chargestatic->label=$obj->label; $chargestatic->paye=$obj->paye; print ''; @@ -668,6 +672,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''.price($obj->sumpaid).''; print ''.$chargestatic->getLibStatut(3).''; print ''; + $tot_ttc+=$obj->amount; $i++; } @@ -953,7 +958,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $facstatic=new FactureFournisseur($db); - $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; $sql.= ", ff.date_lim_reglement"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid, s.email"; @@ -1070,9 +1075,8 @@ if ($resql) { $obj = $db->fetch_object($resql); - print ''.dol_print_date($db->jdate($obj->da), "day").''; - print ''.$obj->libelle.' '.$obj->label.''; + print ''.$obj->label.''; $i++; } $db->free($resql); diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 55f5c82a72a..54a8513fc0c 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -45,7 +45,7 @@ $date_endday=GETPOST('date_endday'); $date_endyear=GETPOST('date_endyear'); // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); @@ -100,7 +100,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; -$sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle,"; +$sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle as label,"; $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; $sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,"; @@ -158,7 +158,7 @@ if ($result) $tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier; $tabfac[$obj->rowid]["type"] = $obj->type; - $tabfac[$obj->rowid]["lib"] = $obj->libelle; + $tabfac[$obj->rowid]["lib"] = $obj->label; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; if ($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 74032e34d18..f6cc0ec03b6 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -47,7 +47,7 @@ $date_endday=GETPOST('date_endday'); $date_endyear=GETPOST('date_endyear'); // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index e7762b834e4..4acb3f108a3 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -40,7 +40,7 @@ $lttype=GETPOST('localTaxType', 'int'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $object = new Localtax($db); diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 97f97bbc735..c31a02b5b33 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -82,7 +82,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index c02de96035d..6fa963ad25e 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -76,7 +76,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 0b0716b53a9..cfa1d492a60 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -29,7 +29,7 @@ $langs->load("compta"); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt=GETPOST("localTaxType"); diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 5e89f68e8ba..0c49f23dc3d 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -94,7 +94,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) @@ -320,323 +320,318 @@ else $span=$columns; if ($modetax != 1) $span+=2; - //if ($modetax == 0 || $modetax == 2) - //{ - // Customers invoices - print ''; - print ''.$elementcust.''; - print ''.$productcust.''; - if ($modetax != 2) print ''.$amountcust.''; - if ($modetax != 1) print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - print ''.$langs->trans("BI").''; - print ''.$vatcust.''; - print ''; + // Customers invoices + print ''; + print ''.$elementcust.''; + print ''.$productcust.''; + if ($modetax != 2) print ''.$amountcust.''; + if ($modetax != 1) print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + print ''.$langs->trans("BI").''; + print ''.$vatcust.''; + print ''; - $LT=0; - $sameLT=false; - foreach(array_keys($x_coll) as $rate) + $LT=0; + $sameLT=false; + foreach(array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; + + if (is_array($x_both[$rate]['coll']['detail'])) { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; - - if (is_array($x_both[$rate]['coll']['detail'])) + // VAT Rate + if($rate!=0){ + print ""; + print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; + print ''."\n"; + } + foreach($x_both[$rate]['coll']['detail'] as $index => $fields) { - // VAT Rate - if($rate!=0){ - print ""; - print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; - print ''."\n"; - } - foreach($x_both[$rate]['coll']['detail'] as $index => $fields) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; + + + print ''; + + // Ref + print ''.$fields['link'].''; + + // Description + print ''; + if ($fields['pid']) { - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''.$fields['link'].''; - - // Description - print ''; - if ($fields['pid']) - { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) - { - if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; - - // Total HT - if ($modetax != 2) - { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - } - print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $payment_static->id=$fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); - } - else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; - } - print ''; - } - - // Total collected - print ''; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT')); - print ''; - - // Localtax - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat, 'MT')); - //print price($fields['vat']); - print ''; - print ''; - - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); } + else + { + if ($type) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) + { + if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; + + // Total HT + if ($modetax != 2) + { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + } + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else { + print price($fields['payment_amount']); + if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; + } + print ''; + } + + // Total collected + print ''; + $temp_ht=$fields['totalht']; + if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT')); + print ''; + + // Localtax + print ''; + $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; + print price(price2num($temp_vat, 'MT')); + //print price($fields['vat']); + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } } - - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) - { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { - print ''; - print ' '; - print ''.$langs->trans("Total").':'; - if ($modetax == 0) - { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; + print ' '; + print ' '; } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; + } - // Blank line - print ' '; - print ''; - $diff=$x_coll_sum; - //} + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax == 0) + { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - //if($conf->global->$calc ==0 || $conf->global->$calc == 1){ - echo ''; - //print table headers for this quadri - expenses now - print ''; - print ''; - print ''; - if ($modetax != 1) + // Blank line + print ''; + print '
'.$elementsup.''.$productsup.'
 
'; + $diff=$x_coll_sum; + + echo ''; + //print table headers for this quadri - expenses now + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''."\n"; + + foreach(array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + if (is_array($x_both[$rate]['paye']['detail'])) { - print ''; - print ''; - } - print ''; - print ''; - print ''."\n"; - - foreach(array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; - - if (is_array($x_both[$rate]['paye']['detail'])) + if($rate!=0){ + print ""; + print ''; + print ''."\n"; + } + foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) { - if($rate!=0){ - print ""; - print ''; - print ''."\n"; - } - foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; + + + print ''; + + // Ref + print ''; + + // Description + print ''; - print ''; - - // Ref - print ''; - - // Description - print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; - - // Total HT - if ($modetax != 2) - { - print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { - print ''; - } - - // VAT paid - print ''; - - // Localtax - print ''; - print ''; - - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; } + + // VAT paid + print ''; + + // Localtax + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } } - - // Total suppliers for this vat rate - print ''; - print ''; - print ''; - if ($modetax != 1) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; } - if (count($x_paye) == 0) { // Show a total line if nothing shown - print ''; - print ''; - print ''; - if ($modetax != 1) { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } - print '
'.$elementsup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatsup.'
'.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatsup.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; + if ($fields['pid']) { - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + } + else + { + if ($type) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print '
'.$fields['link'].''; - if ($fields['pid']) + // Total HT + if ($modetax != 2) + { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NA"); } else { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; + } } print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id=$fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NA"); - } - else - { - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; - } - } - print ''; - $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; - $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print '
'; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; + $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print '
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).'
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'
'; - //} + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } + + print ''; // Total to pay print '

'; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index d0377ad9ff1..5590a45f97f 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -59,9 +59,9 @@ $multicurrency_amounts=array(); $multicurrency_amountsresttopay=array(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $object=new Facture($db); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index e11da654bdd..1fd4f735a50 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -44,7 +44,7 @@ $confirm=GETPOST('confirm', 'alpha'); $backtopage=GETPOST('backtopage', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); @@ -220,7 +220,7 @@ print $form->editfieldval("Date", 'datep', $object->date, $object, $user->rights print ''; // Payment type (VIR, LIQ, ...) -$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle; +$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_label; print ''.$langs->trans('PaymentMode').''.$labeltype; print $object->num_paiement?' - '.$object->num_paiement:''; print ''; @@ -429,7 +429,7 @@ print '
'; if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->societe_id == 0 && $object->statut == 0 && $_GET['action'] == '') + if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { if ($user->rights->facture->paiement) { @@ -438,7 +438,7 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) } } -if ($user->societe_id == 0 && $action == '') +if ($user->socid == 0 && $action == '') { if ($user->rights->facture->paiement) { diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 3afce69e94b..f91ac35f678 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -43,7 +43,7 @@ $confirm=GETPOST('confirm', 'alpha'); // Security check $fieldname = (! empty($ref)?'ref':'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); $sortfield=GETPOST('sortfield', 'alpha'); @@ -770,12 +770,12 @@ else print '
'; -if ($user->societe_id == 0 && ! empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque) +if ($user->socid == 0 && ! empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque) { print ''.$langs->trans('Validate').''; } -if ($user->societe_id == 0 && ! empty($object->id) && $user->rights->banque->cheque) +if ($user->socid == 0 && ! empty($object->id) && $user->rights->banque->cheque) { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 940013df44e..6f0438644a6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -506,7 +506,7 @@ class RemiseCheque extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT b.rowid, b.datev as datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -561,7 +561,7 @@ class RemiseCheque extends CommonObject // phpcs:enable global $user; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT count(b.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index cdbc56896cb..bbec9e1fba7 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories', 'compta', 'bills')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', ''); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 396432545d9..2201412f3f8 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('banks', 'categories', 'bills')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'banque', '', ''); $search_ref = GETPOST('search_ref', 'alpha'); diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 37614f7e36e..4363f39216f 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -41,7 +41,14 @@ class Cpaiement public $table_element = 'c_paiement'; public $code; + + /** + * @deprecated + * @see $label + */ public $libelle; + public $label; + public $type; public $active; public $accountancy_code; @@ -80,6 +87,9 @@ class Cpaiement if (isset($this->libelle)) { $this->libelle = trim($this->libelle); } + if (isset($this->label)) { + $this->label = trim($this->label); + } if (isset($this->type)) { $this->type = trim($this->type); } @@ -100,7 +110,6 @@ class Cpaiement // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; $sql.= 'code,'; $sql.= 'libelle,'; @@ -108,10 +117,7 @@ class Cpaiement $sql.= 'active,'; $sql.= 'accountancy_code,'; $sql.= 'module'; - - $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?getEntity('c_paiement'):$this->entity).','; $sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").','; $sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").','; @@ -119,8 +125,6 @@ class Cpaiement $sql .= ' '.(! isset($this->active)?'NULL':$this->active).','; $sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'").','; $sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'"); - - $sql .= ')'; $this->db->begin(); @@ -173,7 +177,7 @@ class Cpaiement $sql = 'SELECT'; $sql .= ' t.id,'; $sql .= " t.code,"; - $sql .= " t.libelle,"; + $sql .= " t.libelle as label,"; $sql .= " t.type,"; $sql .= " t.active,"; $sql .= " t.accountancy_code,"; @@ -195,7 +199,8 @@ class Cpaiement $this->id = $obj->id; $this->code = $obj->code; - $this->libelle = $obj->libelle; + $this->libelle = $obj->label; + $this->label = $obj->label; $this->type = $obj->type; $this->active = $obj->active; $this->accountancy_code = $obj->accountancy_code; @@ -238,6 +243,9 @@ class Cpaiement if (isset($this->libelle)) { $this->libelle = trim($this->libelle); } + if (isset($this->label)) { + $this->label = trim($this->label); + } if (isset($this->type)) { $this->type = trim($this->type); } @@ -361,6 +369,7 @@ class Cpaiement $this->code = ''; $this->libelle = ''; + $this->label = ''; $this->type = ''; $this->active = ''; $this->accountancy_code = ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index e6d2a27087c..e4a4a275029 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -78,7 +78,7 @@ class Paiement extends CommonObject /** * @var string type libelle */ - public $type_libelle; + public $type_label; /** * @var string type code @@ -160,7 +160,7 @@ class Paiement extends CommonObject public function fetch($id, $ref = '', $fk_bank = '') { $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,'; - $sql.= ' c.code as type_code, c.libelle as type_libelle,'; + $sql.= ' c.code as type_code, c.libelle as type_label,'; $sql.= ' p.num_paiement as num_payment, p.note,'; $sql.= ' b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; @@ -188,7 +188,7 @@ class Paiement extends CommonObject $this->montant = $obj->amount; // deprecated $this->amount = $obj->amount; $this->note = $obj->note; - $this->type_libelle = $obj->type_libelle; + $this->type_label = $obj->type_label; $this->type_code = $obj->type_code; $this->statut = $obj->statut; $this->ext_payment_id = $obj->ext_payment_id; diff --git a/htdocs/compta/paiement/index.php b/htdocs/compta/paiement/index.php index fa47915f216..89136ec5712 100644 --- a/htdocs/compta/paiement/index.php +++ b/htdocs/compta/paiement/index.php @@ -19,7 +19,7 @@ require '../../main.inc.php'; // Security check -if (!$user->admin && $user->societe_id > 0) +if (!$user->admin && $user->socid > 0) accessforbidden(); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 090cc7c83fb..7913d1f8dea 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -51,7 +51,7 @@ $month = GETPOST('month', 'int'); $year = GETPOST('year', 'int'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'facture', $facid, ''); $paymentstatic=new Paiement($db); diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 35325dce4cb..0140031431f 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -34,10 +34,10 @@ if (! $user->rights->facture->lire) accessforbidden(); $action=GETPOST('action', 'aZ09'); $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $dir = $conf->facture->dir_output.'/payments'; diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 120e326d6a2..e3c23041ec8 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -32,10 +32,10 @@ if (! $user->rights->facture->lire) accessforbidden(); $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 91000f2a822..238ac01fd1a 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -36,9 +36,9 @@ $amounts = array(); // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } @@ -168,20 +168,20 @@ if ($action == 'create') $charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype; $total = $charge->amount; - if (! empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ' '."\n"; + } print load_fiche_titre($langs->trans("DoPayment")); print "
\n"; @@ -202,9 +202,9 @@ if ($action == 'create') print ''; print ''; - print '\n"; + print '\n"; print '\n"; - print '\n"; + print '\n"; /*print '\n"; print '';*/ diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 605f5cec3bc..ecc3a23430a 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -39,7 +39,7 @@ $langs->loadLangs(array('bills', 'banks', 'companies')); $id=GETPOST("id", 'int'); $action=GETPOST('action', 'aZ09'); $confirm=GETPOST('confirm'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); @@ -221,7 +221,7 @@ dol_fiche_end(); */ $disable_delete = 0; -$sql = 'SELECT f.rowid as scid, f.libelle, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type'; +$sql = 'SELECT f.rowid as scid, f.libelle as label, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql.= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id'; $sql.= ' AND f.entity = '.$conf->entity; @@ -259,11 +259,11 @@ if ($resql) print "\n"; // Type print '\n"; // Label - print ''; + print ''; // Expected to pay print ''; // Status @@ -299,7 +299,7 @@ print '
'; /* if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->societe_id == 0 && $object->statut == 0 && $_GET['action'] == '') + if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { if ($user->rights->facture->paiement) { diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index ecea96b7a09..eb18618ab62 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('banks', 'categories', 'widthdrawals')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ea5a4e8d07c..6c60cdaa059 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -37,7 +37,7 @@ if (!$user->rights->prelevement->bons->lire) accessforbidden(); // Security check -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Get supervariables $action = GETPOST('action', 'alpha'); @@ -271,7 +271,7 @@ if ($id > 0 || $ref) print '
'; -/* print '';*/ diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 5f2d73af0aa..f1c3f70c53a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -69,7 +69,7 @@ class BonPrelevement extends CommonObject public $total; public $fetched; public $statut; // 0-Wait, 1-Trans, 2-Done - public $labelstatut=array(); + public $labelStatus=array(); public $invoice_in_error=array(); public $thirdparty_in_error=array(); @@ -1686,7 +1686,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_END_TO_END != "" ) ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; @@ -1718,8 +1718,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; - // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; + // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_USTRD != "" ) ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135) ).''.$CrLf; // 140 max $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1887,15 +1887,15 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; -/* $XML_SEPA_INFO .= ' '.$CrLf; + /* $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; -*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf;*/ + $XML_SEPA_INFO .= ' SLEV'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -1995,55 +1995,55 @@ class BonPrelevement extends CommonObject /** * Return status label for a status * - * @param int $statut id statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatut)) + if (empty($this->labelStatus)) { global $langs; $langs->load("withdrawals"); - $this->labelstatut[0]=$langs->trans("StatusWaiting"); - $this->labelstatut[1]=$langs->trans("StatusTrans"); - $this->labelstatut[2]=$langs->trans("StatusCredited"); + $this->labelStatus[0]=$langs->trans("StatusWaiting"); + $this->labelStatus[1]=$langs->trans("StatusTrans"); + $this->labelStatus[2]=$langs->trans("StatusCredited"); } if ($mode == 0 || $mode == 1) { - return $this->labelstatut[$statut]; + return $this->labelStatus[$status]; } elseif ($mode == 2) { - if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status]; + elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status]; + elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status]; } elseif ($mode == 3) { - if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1'); - elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3'); - elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6'); + if ($status==0) return img_picto($this->labelStatus[$status], 'statut1'); + elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3'); + elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status]; + elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status]; + elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status]; } elseif ($mode == 5) { - if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1'); + elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3'); + elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6'); } elseif ($mode == 6) { - if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1'); + elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3'); + elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6'); } } } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 3b0f61b17a0..467351e3110 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -132,36 +132,36 @@ class LignePrelevement /** * Return status label for a status * - * @param int $statut id statut + * @param int $status Id status * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); // Waiting + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); // Credited + elseif ($status==3) return img_picto($langs->trans($this->statuts[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); // Refused } elseif ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut1'); + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut6'); + elseif ($status==3) return img_picto($langs->trans($this->statuts[$status]), 'statut8'); } elseif ($mode == 3) { - if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + if ($status==0) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut1'); + elseif ($status==2) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut6'); + elseif ($status==3) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut8'); } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 3aaad5662a3..c4cad05d1f6 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 4ea74e83b4f..52b312e6b4c 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -36,7 +36,7 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); $status = GETPOST('status', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index fbc36418222..334e36c5a68 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories', 'companies', 'withdrawals', 'bills')); // Securite acces client -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id', 'int'); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 24aa2f9bcb9..17e8dcebe98 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array("banks","categories",'withdrawals','bills')); // Securite acces client -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id', 'int'); @@ -223,7 +223,7 @@ if ($resql) } else { - print ''; + print ''; } if ($num > 0) diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index c8914b41f26..01fde1b2450 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array("banks","categories",'withdrawals','bills')); // Security check -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id', 'int'); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 80d7abb4f0a..3af40c84dcb 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', ''); @@ -71,7 +71,7 @@ $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); - +print '
'; print '
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Type")."".$charge->type_libelle."
'.$langs->trans("Type")."".$charge->type_label."
'.$langs->trans("Period")."".dol_print_date($charge->periode, 'day')."
'.$langs->trans("Label").''.$charge->lib."
'.$langs->trans("Label").''.$charge->label."
'.$langs->trans("DateDue")."".dol_print_date($charge->date_ech,'day')."
'.$langs->trans("Amount")."".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'; - print $socialcontrib->type_libelle; + print $socialcontrib->type_label; /*print $socialcontrib->type;*/ print "'.$objp->libelle.''.$objp->label.''.price($objp->sc_amount).'
'.$langs->trans("TransMetod").''; print $form->selectarray("methode", $object->methodes_trans); print '
'.$langs->trans("File").''; + /*print '
'.$langs->trans("File").''; print ''; print '
'; print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print ''; @@ -85,7 +85,7 @@ print ''; print ''; print '
'.$langs->trans("Statistics").'
'.$langs->trans("AmountToWithdraw").''; print price($bprev->SommeAPrelever(), '', '', 1, -1, -1, 'auto'); -print '

'; +print '

'; @@ -116,6 +116,7 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + print '
'; print ''; print ''; print ''; @@ -162,7 +163,7 @@ if ($resql) { print ''; } - print "
'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')
'.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).'

"; + print "

"; } else { @@ -189,6 +190,7 @@ if ($result) $i = 0; print"\n\n"; + print '
'; print ''; print ''; print ''; @@ -216,7 +218,7 @@ if ($result) print "\n"; $i++; } - print "
'.$langs->trans("LastWithdrawalReceipt", $limit).''.$langs->trans("Date").'

"; + print "

"; $db->free($result); } else diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 41ac08b0fb2..454861dea73 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadlangs(array('banks', 'categories', 'bills', 'withdrawals')); // Security check -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Get supervariables $action = GETPOST('action', 'alpha'); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 2ffb8def303..c016f1e6c02 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -34,7 +34,7 @@ $langs->loadLangs(array('banks', 'withdrawals', 'companies', 'categories')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 6cde242ae93..4235f5d7fc3 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -35,7 +35,7 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 0dd5087869c..1b9396a411a 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 6fc1a3b16b2..88a72344f52 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -35,7 +35,7 @@ if (! empty($conf->facture->enabled)) $langs->load("bills"); $id = GETPOST('id')?GETPOST('id', 'int'):GETPOST('socid', 'int'); // Security check -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); @@ -96,7 +96,7 @@ if ($id > 0) $head = societe_prepare_head($object); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 1); + dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 1); dol_fiche_end(); if (! empty($conf->facture->enabled) && $user->rights->facture->lire) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 928776aa06e..c85894c60d6 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -50,7 +50,7 @@ $showaccountdetail = GETPOST('showaccountdetail', 'aZ09')?GETPOST('showaccountde // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); @@ -1132,11 +1132,11 @@ else while ($i < $num) { $obj = $db->fetch_object($result); - $amount += $obj->amount; - $total_ht += $obj->amount; - $total_ttc += $obj->amount; - $subtotal_ht += $obj->amount; - $subtotal_ttc += $obj->amount; + $amount += -$obj->amount; + $total_ht += -$obj->amount; + $total_ttc += -$obj->amount; + $subtotal_ht += -$obj->amount; + $subtotal_ttc += -$obj->amount; $i++; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 5efa036055f..33609f98997 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -98,7 +98,7 @@ $nbofyear = ($year_end - $year_start) + 1; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); @@ -480,10 +480,10 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $obj = $db->fetch_object($result); if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; - $encaiss[$obj->dm] += $obj->amount; + $encaiss[$obj->dm] += -$obj->amount; if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; - $encaiss_ttc[$obj->dm] += $obj->amount; + $encaiss_ttc[$obj->dm] += -$obj->amount; $i++; } @@ -749,17 +749,17 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $sql.= " AND fk_statut in (1,2)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == 'RECETTES-DEPENSES') { + } elseif ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; $sql.= " WHERE p.entity IN (".getEntity('donation').")"; $sql.= " AND fk_statut >= 2"; - if (! empty($date_start) && ! empty($date_end)) - $sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'"; - } + if (! empty($date_start) && ! empty($date_end)) { + $sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'"; + } + } $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 8b8f7126568..9af5a559f5e 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -130,7 +130,7 @@ if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING'; if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta", 'alpha'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) accessforbidden(); if (! $user->rights->accounting->comptarapport->lire) accessforbidden(); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index cc6280070a0..f35b145b969 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -49,7 +49,7 @@ $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); $object = new ChargeSociales($db); @@ -167,7 +167,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) else { $object->type = $actioncode; - $object->lib = GETPOST('label'); + $object->label = GETPOST('label', 'alpha'); $object->date_ech = $dateech; $object->periode = $dateperiod; $object->amount = $amount; @@ -242,12 +242,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char { $object->paye = 0; $object->id = $object->ref = null; - $object->lib = $langs->trans("CopyOf").' '.$object->lib; - if (GETPOST('clone_for_next_month') != '') - { - $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); + if (GETPOST('clone_label', 'alphanohtml')) { + $object->label = GETPOST('clone_label', 'alphanohtml'); + } + else { + $object->label = $langs->trans("CopyOf").' '.$object->label; + } + + if (GETPOST('clone_for_next_month', 'int')) { $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); + $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); + } + else { + $newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int')); + $newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int')); + if ($newdateperiod) $object->periode = $newdateperiod; + if ($newdateech) $object->date_ech = $newdateech; } if ($object->check()) @@ -414,12 +425,20 @@ if ($id > 0) // Clone confirmation if ($action === 'clone') { - $formclone=array( - array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1), - + $formquestion=array( + array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label), ); + if (! empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX)) + { + $formquestion[]=array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1); + } + else + { + $formquestion[]=array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); + $formquestion[]=array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("DateDue"), 'value' => -1); + } - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formclone, 'yes'); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation de la suppression de la charge @@ -445,8 +464,8 @@ if ($id > 0) $morehtmlref='
'; // Ref customer - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project if (! empty($conf->projet->enabled)) { @@ -454,19 +473,20 @@ if ($id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->tax->charges->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -494,7 +514,7 @@ if ($id > 0) print ''; // Type - print '"; + print '"; print ""; // Period end date diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index c5a882283c7..85643d084ff 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -55,16 +55,27 @@ class ChargeSociales extends CommonObject protected $table_ref_field = 'ref'; public $date_ech; - public $lib; + public $label; public $type; - public $type_libelle; + public $type_label; public $amount; public $paye; public $periode; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_modification; public $date_validation; + /** + * @deprecated Use label instead + */ + public $lib; + /** * @var int account ID */ @@ -106,7 +117,7 @@ class ChargeSociales extends CommonObject public function fetch($id, $ref = '') { $sql = "SELECT cs.rowid, cs.date_ech"; - $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; + $sql.= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; $sql.= ", cs.fk_account, cs.fk_mode_reglement"; $sql.= ", c.libelle"; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; @@ -128,9 +139,10 @@ class ChargeSociales extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->date_ech = $this->db->jdate($obj->date_ech); - $this->lib = $obj->lib; + $this->lib = $obj->label; + $this->label = $obj->label; $this->type = $obj->fk_type; - $this->type_libelle = $obj->libelle; + $this->type_label = $obj->libelle; $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; @@ -203,7 +215,7 @@ class ChargeSociales extends CommonObject $sql.= " VALUES (".$this->type; $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); - $sql.= ", '".$this->db->escape($this->lib)."'"; + $sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'"; $sql.= ", '".$this->db->idate($this->date_ech)."'"; $sql.= ", '".$this->db->idate($this->periode)."'"; $sql.= ", '".price2num($newamount)."'"; @@ -323,7 +335,7 @@ class ChargeSociales extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql.= " SET libelle='".$this->db->escape($this->lib)."'"; + $sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'"; $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; $sql.= ", periode='".$this->db->idate($this->periode)."'"; $sql.= ", amount='".price2num($this->amount, 'MT')."'"; @@ -459,12 +471,12 @@ class ChargeSociales extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - public function LibStatut($statut, $mode = 0, $alreadypaid = -1) + public function LibStatut($status, $mode = 0, $alreadypaid = -1) { // phpcs:enable global $langs; @@ -474,38 +486,38 @@ class ChargeSociales extends CommonObject if ($mode == 0 || $mode == 1) { - if ($statut == 0) return $langs->trans("Unpaid"); - elseif ($statut == 1) return $langs->trans("Paid"); + if ($status == 0) return $langs->trans("Unpaid"); + elseif ($status == 1) return $langs->trans("Paid"); } elseif ($mode == 2) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 3) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 4) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 5) { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 6) { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } else return "Error, mode/status not found"; @@ -543,15 +555,15 @@ class ChargeSociales extends CommonObject } - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref=$this->label; $label = ''.$langs->trans("ShowSocialContribution").''; if (! empty($this->ref)) $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->lib)) - $label .= '
'.$langs->trans('Label') . ': ' . $this->lib; - if (! empty($this->type_libelle)) - $label .= '
'.$langs->trans('Type') . ': ' . $this->type_libelle; + if (! empty($this->label)) + $label .= '
'.$langs->trans('Label') . ': ' . $this->label; + if (! empty($this->type_label)) + $label .= '
'.$langs->trans('Type') . ': ' . $this->type_label; $linkclose=''; if (empty($notooltip) && $user->rights->facture->lire) @@ -677,12 +689,12 @@ class ChargeSociales extends CommonObject $this->ref = 'SPECIMEN'; $this->specimen=1; $this->paye = 0; - $this->date = time(); + $this->date = dol_now(); $this->date_ech=$this->date+3600*24*30; $this->periode=$this->date+3600*24*30; $this->amount=100; - $this->lib = 0; + $this->label = 'Social contribution label'; $this->type = 1; - $this->type_libelle = 'Social contribution label'; + $this->type_label = 'Type of social contribution'; } } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index e13738fd5f4..4fb2f27b53f 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -236,7 +236,7 @@ class PaymentSocialContribution extends CommonObject $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= " pt.code as type_code, pt.libelle as type_label,"; $sql.= ' b.fk_account'; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; @@ -267,7 +267,7 @@ class PaymentSocialContribution extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->type_code = $obj->type_code; - $this->type_libelle = $obj->type_libelle; + $this->type_label = $obj->type_label; $this->bank_account = $obj->fk_account; $this->bank_line = $obj->fk_bank; @@ -592,7 +592,7 @@ class PaymentSocialContribution extends CommonObject { $socialcontrib = new ChargeSociales($this->db); $socialcontrib->fetch($key); - $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''), 'sc'); + $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_label.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_label)?' ('.$socialcontrib->lib.')':''), 'sc'); if ($result <= 0) dol_print_error($this->db); } } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index b3fb1cf697b..4a714df8bae 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -47,7 +47,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); @@ -108,8 +108,8 @@ if ($object->id) $morehtmlref='
'; // Label of social contribution - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 3d59e2b229c..e449f907bc8 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -39,7 +39,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); $object = new ChargeSociales($db); @@ -79,8 +79,8 @@ dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, 'bill'); $morehtmlref='
'; // Label of social contribution -$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); +$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 56493f3bf7c..6fbf174abc5 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -42,7 +42,7 @@ $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'sclist'; // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $search_ref = GETPOST('search_ref', 'int'); @@ -110,8 +110,8 @@ $chargesociale_static=new ChargeSociales($db); llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid as id, cs.fk_type as type, "; -$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; -$sql.= " c.libelle as type_lib,"; +$sql.= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; +$sql.= " c.libelle as type_label,"; $sql.= " SUM(pc.amount) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; @@ -261,8 +261,8 @@ if ($resql) $chargesociale_static->id=$obj->id; $chargesociale_static->ref=$obj->id; - $chargesociale_static->lib=$obj->libelle; - $chargesociale_static->type_libelle=$obj->type_lib; + $chargesociale_static->label=$obj->label; + $chargesociale_static->type_label=$obj->type_label; print '
'; @@ -272,10 +272,10 @@ if ($resql) print ''; // Label - print ''; + print ''; // Type - print ''; + print ''; // Date end period print '\n"; - $sql = "SELECT c.id, c.libelle as lib,"; - $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql = "SELECT c.id, c.libelle as type_label,"; + $sql.= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; $sql.= " pct.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; @@ -162,10 +162,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - print ''; - // Ref payment + $payment_sc_static->id=$obj->pid; $payment_sc_static->ref=$obj->pid; + + print ''; + // Ref payment print '\n"; // Date payment print ''; @@ -176,12 +178,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // Label print ''; // Type - print ''; + print ''; // Date $date=$obj->periode; if (empty($date)) $date=$obj->date_ech; diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 0cd02bc04bd..08ddd9a576e 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -107,7 +107,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -241,165 +241,163 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') } -if ($modecompta == 'CREANCES-DETTES') -{ -print '
'.$langs->trans("Type")."".$object->type_libelle."
'.$langs->trans("Type")."".$object->type_label."
'.dol_trunc($obj->libelle, 42).''.dol_trunc($obj->label, 42).''.$obj->type_lib.''.$obj->type_label.''; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index caf11a6ea3b..d22bd80722a 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); $mode=GETPOST("mode", 'alpha'); @@ -126,8 +126,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "
'.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->libelle; - $socialcontrib->lib=$obj->libelle; + $socialcontrib->ref=$obj->rowid; + $socialcontrib->label=$obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.$obj->lib.''.$obj->type_label.'
'; -print ''; -print ''; -print ''; -$i=0; -while($i < 12) -{ - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - print ''; - $i++; -} -print ''; +if ($modecompta == 'CREANCES-DETTES') { + print '
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
'; + print ''; + print ''; + print ''; + $i=0; + while($i < 12) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + print ''; + $i++; + } + print ''; -$sql = "SELECT fd.tva_tx AS vatrate,"; -$sql .= " fd.product_type AS product_type,"; -$sql .= " cc.label AS country,"; -for ($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; -$sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; -$sql.= " AND f.fk_statut in (1,2)"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; -} else { - $sql.= " AND f.type IN (0,1,2,3,5)"; -} -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; -$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; + $sql = "SELECT fd.tva_tx AS vatrate,"; + $sql .= " fd.product_type AS product_type,"; + $sql .= " cc.label AS country,"; + for ($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; + $sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; + $sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; + $sql.= " AND f.fk_statut in (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND f.type IN (0,1,2,5)"; + } else { + $sql.= " AND f.type IN (0,1,2,3,5)"; + } + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; + $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; -dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql)) { - print ''; - if ($obj->product_type == 0) { - print ''; - } else { - print ''; + dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql)) { + print ''; + if ($obj->product_type == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + } + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; } - print ''; + $db->free($resql); + + // Total + print ''; + print ''; + print ''; for($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; print ''; + } else { + print $db->lasterror(); // Show last sql error } - $db->free($resql); - // Total - print ''; - print ''; - print ''; - for($i = 0; $i < 12; $i++) { + + print ''; + print ''; + print ''; + $i=0; + while($i < 12) + { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; + $i++; } - print ''; - print ''; -} else { - print $db->lasterror(); // Show last sql error -} + print ''; + $sql2 = "SELECT ffd.tva_tx AS vatrate,"; + $sql2 .= " ffd.product_type AS product_type,"; + $sql2 .= " cc.label AS country,"; + for($i = 1; $i <= 12; $i ++) { + $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql2 .= " SUM(ffd.total_ht) as total"; + $sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; + $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; + $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; + $sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; + $sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; + $sql.= " AND ff.fk_statut in (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND ff.type IN (0,1,2,5)"; + } else { + $sql.= " AND ff.type IN (0,1,2,3,5)"; + } + $sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; + $sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; -print ''; -print ''; -print ''; -$i=0; -while($i < 12) -{ - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - print ''; - $i++; -} -print ''; - -$sql2 = "SELECT ffd.tva_tx AS vatrate,"; -$sql2 .= " ffd.product_type AS product_type,"; -$sql2 .= " cc.label AS country,"; -for($i = 1; $i <= 12; $i ++) { - $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql2 .= " SUM(ffd.total_ht) as total"; -$sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; -$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; -$sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; -$sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; -$sql.= " AND ff.fk_statut in (1,2)"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND ff.type IN (0,1,2,5)"; -} else { - $sql.= " AND ff.type IN (0,1,2,3,5)"; -} -$sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; -$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; - -//print $sql2; -dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); -$resql2 = $db->query($sql2); -if ($resql2) { - $num = $db->num_rows($resql2); - $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql2)) { - print ''; - if ($obj->product_type == 0) { - print ''; - } else { - print ''; + //print $sql2; + dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + $resql2 = $db->query($sql2); + if ($resql2) { + $num = $db->num_rows($resql2); + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql2)) { + print ''; + if ($obj->product_type == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + } + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; } - print ''; + $db->free($resql2); + + // Total + print ''; + print ''; + print ''; for($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; print ''; + } else { + print $db->lasterror(); // Show last sql error } - $db->free($resql2); - - // Total - print ''; - print ''; - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - } - print ''; - print ''; -} else { - print $db->lasterror(); // Show last sql error -} -print "
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$obj->country . '' . price($obj->$monthj) . '' . price($obj->total) . '
' .$obj->country . '
' . price($obj->$monthj) . '' . price($totalpermonth[$j]) . '' . price($obj->total) . '' . price($totalpermonth['total']) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . price($totalpermonth[$j]) . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . price($totalpermonth['total']) . '
' . $langs->trans("TotalHT") . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $obj->country . '' . price($obj->$monthj) . '' . price($obj->total) . '
' . $obj->country . '
' . price($obj->$monthj) . '' . price($totalpermonth[$j]) . '' . price($obj->total) . '' . price($totalpermonth['total']) . '
' . price($totalpermonth[$j]) . '' . price($totalpermonth['total']) . '
\n"; + print "\n"; } else { // $modecompta != 'CREANCES-DETTES' // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 8a97be4d252..138bff4a525 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -36,7 +36,7 @@ $langs->loadLangs(array("products","categories","errors",'accountancy')); // Security pack (data & check) $socid = GETPOST('socid', 'int'); -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); @@ -240,7 +240,7 @@ if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -326,7 +326,7 @@ if ($modecompta == 'CREANCES-DETTES') // Array header print ""; -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Product"), $_SERVER["PHP_SELF"], "ref", @@ -336,7 +336,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans('Quantity'), $_SERVER["PHP_SELF"], "qty", @@ -346,7 +346,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"], "qty", @@ -356,7 +356,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans('AmountHT'), $_SERVER["PHP_SELF"], "amount", @@ -366,7 +366,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "amount_ttc", @@ -376,7 +376,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"], "amount_ttc", diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 8973c92f68f..286e6aeb29a 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -35,7 +35,7 @@ $langs->load("accountancy"); $socid = GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 139e9f22160..68f9e0d9f99 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -57,7 +57,7 @@ if (GETPOST('subcat', 'alpha') === 'yes') { } // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index cf1f49ae1a8..ac3e800e6e4 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -98,7 +98,7 @@ if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING'; if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta", 'alpha'); // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); @@ -172,7 +172,7 @@ if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; } elseif ($modecompta=="RECETTES-DEPENSES") { @@ -187,7 +187,7 @@ elseif ($modecompta=="RECETTES-DEPENSES") $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; } elseif ($modecompta=="BOOKKEEPING") { diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index e58fa66acaf..dbbaa8d56fc 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -40,7 +40,7 @@ if (empty($refund)) $refund=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $object = new Tva($db); diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 576ea819fda..e97e4554b41 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -90,7 +90,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index d26d8954cc4..d3a5b60d7ba 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -48,7 +48,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', $id, 'vat', 'charges'); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index d6019c1eef5..1ed3658b37a 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -76,7 +76,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 667cffd065b..6190a30f316 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -34,7 +34,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $object = new Tva($db); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index cffa9152a92..e27093ff89f 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -36,7 +36,7 @@ $langs->loadLangs(array('compta', 'bills')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $search_ref = GETPOST('search_ref', 'int'); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index bb9067d5a04..791c360ff67 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -91,7 +91,7 @@ if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 30efcd28632..8ffc88d1a14 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -84,7 +84,7 @@ else $search_agenda_label=GETPOST('search_agenda_label'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index 921535bf20f..35772ee6f34 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -135,13 +135,15 @@ echo $this->control->tpl['ajax_selectcountry']; -control->tpl['contact_element'])) { ?> -control->tpl['contact_element'] as $element) { ?> - - - - - +control->tpl['contact_element'])) { + foreach ($this->control->tpl['contact_element'] as $element) { + print ''; + print ''.$element['linked_element_label'].''; + print ''.$element['linked_element_value'].''; + print ''; + } +} ?> trans("DolibarrLogin"); ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index a9ccf9bff3d..8ab92047daa 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -24,17 +24,14 @@ if (empty($conf) || ! is_object($conf)) $contact = $GLOBALS['objcanvas']->control->object; -?> - -control->tpl['showhead']; ?> +print "\n"; +echo $this->control->tpl['showhead']; -control->tpl['error'], $this->control->tpl['errors']); -?> -control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; ?> -control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> +if (! empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; +if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> @@ -134,29 +131,27 @@ dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors'
-control->tpl['showend']; ?> +control->tpl['showend']; -societe_id)) { ?> -
+if (empty($user->socid)) { + print '
'; + if ($user->rights->societe->contact->creer) { + print ''.$langs->trans('Modify').''; + } -rights->societe->contact->creer) { ?> -">trans('Modify'); ?> - + if (! $this->control->tpl['user_id'] && $user->rights->user->user->creer) { + print ''.$langs->trans("CreateDolibarrLogin").''; + } -control->tpl['user_id'] && $user->rights->user->user->creer) { ?> -">trans("CreateDolibarrLogin"); ?> - + if ($user->rights->societe->contact->supprimer) { + print ''.$langs->trans('Delete').''; + } -rights->societe->contact->supprimer) { ?> -">trans('Delete'); ?> - - -

-
'; +} echo $this->control->tpl['actionstodo']; echo $this->control->tpl['actionsdone']; -?> - +print "\n"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 123f9f91f5e..fe64122b52c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -74,7 +74,7 @@ if (! empty($canvas)) } // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -179,7 +179,7 @@ if (empty($reshook)) $object->socid = GETPOST("socid", 'int'); $object->lastname = GETPOST("lastname", 'alpha'); $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_id = GETPOST("civility_id", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); $object->poste = GETPOST("poste", 'alpha'); $object->address = GETPOST("address", 'alpha'); $object->zip = GETPOST("zipcode", 'alpha'); @@ -191,6 +191,7 @@ if (empty($reshook)) $object->facebook = GETPOST("facebook", 'alpha'); $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); @@ -230,6 +231,22 @@ if (empty($reshook)) // Categories association $contcats = GETPOST('contcats', 'array'); $object->setCategories($contcats); + + // Add mass emailing flag into table mailing_unsubscribe + if (GETPOST('no_email', 'int') && $object->email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if (empty($obj->nb)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } } } @@ -350,7 +367,7 @@ if (empty($reshook)) $object->socid = GETPOST("socid", 'int'); $object->lastname = GETPOST("lastname", 'alpha'); $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_id = GETPOST("civility_id", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); $object->poste = GETPOST("poste", 'alpha'); $object->address = GETPOST("address", 'alpha'); @@ -360,6 +377,7 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id", 'int'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); @@ -387,6 +405,35 @@ if (empty($reshook)) $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); + $no_email = GETPOST('no_email', 'int'); + + // Update mass emailing flag into table mailing_unsubscribe + if (GETPOSTISSET('no_email') && $object->email) + { + if ($no_email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } + else + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); + $resql=$db->query($sql); + } + + $object->no_email = $no_email; + } + $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; @@ -574,8 +621,8 @@ else } // Civility - print ''; - print $formcompany->select_civility(GETPOST("civility", 'alpha')?GETPOST("civility", 'alpha'):$object->civility_code); + print ''; + print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility_code", 'alpha'):$object->civility_code, 'civility_code'); print ''; print ''; @@ -631,7 +678,7 @@ else print $formcompany->select_state(GETPOST("state_id", 'alpha')?GETPOST("state_id", 'alpha'):$object->state_id, $object->country_code, 'state_id'); } else - { + { print $countrynotdefined; } print ''; @@ -884,8 +931,8 @@ else } // Civility - print ''; - print $formcompany->select_civility(isset($_POST["civility"])?GETPOST("civility"):$object->civility_code); + print ''; + print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility", "aZ09"):$object->civility_code, 'civility_code'); print ''; print ''; @@ -925,7 +972,7 @@ else print ''; } - print $formcompany->select_state($object->state_id, isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'state_id'); + print $formcompany->select_state(GETPOSTISSET('state_id')?GETPOST('state_id', 'alpha'):$object->state_id, $object->country_code, 'state_id'); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 3465b3478a0..033c9471f51 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -80,7 +80,7 @@ class Contact extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; public $address; @@ -88,16 +88,17 @@ class Contact extends CommonObject public $town; public $state_id; // Id of department - public $state_code; // Code of department + public $state_code; // Code of department public $state; // Label of department public $poste; // Position public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $statut; // 0=inactif, 1=actif public $code; public $email; + public $no_email; // 1 = contact has globaly unsubscribe of all mass emailings public $skype; public $photo; public $jabberid; @@ -154,7 +155,7 @@ class Contact extends CommonObject $sql = "SELECT count(sp.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -163,7 +164,7 @@ class Contact extends CommonObject } $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; + if ($user->socid > 0) $sql.=" AND sp.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -327,13 +328,13 @@ class Contact extends CommonObject $this->town=(empty($this->town)?'':$this->town); $this->country_id=($this->country_id > 0?$this->country_id:$this->country_id); if (empty($this->statut)) $this->statut = 0; - + if (empty($this->civility_code) && ! is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; elseif ($this->socid == -1) $sql .= " fk_soc=null,"; - $sql .= " civility='".$this->db->escape($this->civility_id)."'"; + $sql .= " civility='".$this->db->escape($this->civility_code)."'"; $sql .= ", lastname='".$this->db->escape($this->lastname)."'"; $sql .= ", firstname='".$this->db->escape($this->firstname)."'"; $sql .= ", address='".$this->db->escape($this->address)."'"; @@ -394,6 +395,7 @@ class Contact extends CommonObject if (! $error && $this->user_id > 0) { + // If contact is linked to a user $tmpobj = new User($this->db); $tmpobj->fetch($this->user_id); $usermustbemodified = 0; @@ -1160,11 +1162,11 @@ class Contact extends CommonObject //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code if (! empty($this->poste)) $label.= '
' . $langs->trans("Poste") . ': '.$this->poste; $label.= '
' . $langs->trans("EMail") . ': '.$this->email; - $phonelist=array(); - if ($this->phone_pro) $phonelist[]=$this->phone_pro; - if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; - if ($this->phone_perso) $phonelist[]=$this->phone_perso; - $label.= '
' . $langs->trans("Phone") . ': '.join(', ', $phonelist); + $phonelist = array(); + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $label.= '
' . $langs->trans("Phone") . ': '.implode(' ', $phonelist); $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; @@ -1253,45 +1255,35 @@ class Contact extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable global $langs; - if ($mode == 0) - { - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); - } - elseif ($mode == 1) - { - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); - } - elseif ($mode == 2) - { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - } - elseif ($mode == 3) - { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - } - elseif ($mode == 5) - { - if ($statut==0 || $statut==5) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); - elseif ($statut==1 || $statut==4) return ''.$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); - } + $labelStatus = array( + 0 => 'ActivityCeased', + 1 => 'InActivity', + 4 => 'InActivity', + 5 => 'ActivityCeased', + ); + $labelStatusShort = array( + 0 => 'ActivityCeased', + 1 => 'InActivity', + 4 => 'InActivity', + 5 => 'ActivityCeased', + ); + + $statusType = 'status4'; + if ($status==0 || $status==5) $statusType = 'status5'; + + $label = $langs->trans($labelStatus[$status]); + $labelshort = $langs->trans($labelStatusShort[$status]); + + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } @@ -1299,14 +1291,14 @@ class Contact extends CommonObject /** * Return translated label of Public or Private * - * @param int $statut Type (0 = public, 1 = private) + * @param int $status Type (0 = public, 1 = private) * @return string Label translated */ - public function LibPubPriv($statut) + public function LibPubPriv($status) { // phpcs:enable global $langs; - if ($statut=='1') return $langs->trans('ContactPrivate'); + if ($status=='1') return $langs->trans('ContactPrivate'); else return $langs->trans('ContactPublic'); } @@ -1359,18 +1351,18 @@ class Contact extends CommonObject /** * Change status of a user * - * @param int $statut Status to set + * @param int $status Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - public function setstatus($statut) + public function setstatus($status) { global $conf,$langs,$user; $error=0; // Check parameters - if ($this->statut == $statut) return 0; - else $this->statut = $statut; + if ($this->statut == $status) return 0; + else $this->statut = $status; $this->db->begin(); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index c82795b9449..4b08d3cb95a 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -121,7 +121,7 @@ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) } $morehtmlref.='
'; -dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', $morehtmlref); +dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'rowid', 'nom', $morehtmlref); print '
'; @@ -151,7 +151,7 @@ if ($object->thirdparty->fournisseur) if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']=$langs->transnoentitiesnoconv('SuppliersOrders'); // There no contact type for supplier proposals -// if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); + // if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); } print ''; @@ -170,7 +170,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic=new Fichinter($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'fichinterdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; @@ -183,7 +183,7 @@ elseif ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $documentstatic=new Facture($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facturedet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -198,7 +198,7 @@ elseif ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $documentstatic=new Propal($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'propaldet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -213,7 +213,7 @@ elseif ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $documentstatic=new Commande($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commandedet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -228,7 +228,7 @@ elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $documentstatic=new FactureFournisseur($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -256,7 +256,7 @@ elseif ($type_element == 'supplier_order') { // Supplier : Show products from orders. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $documentstatic=new CommandeFournisseur($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -272,7 +272,7 @@ elseif ($type_element == 'contract') require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $documentstatic=new Contrat($db); $documentstaticline=new ContratLigne($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, tc.libelle, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'contratdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; @@ -298,7 +298,7 @@ if (!empty($sql_select)) $sql.= " "; if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label"; $sql.= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from; -// if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql.= $where; $sql.= dolSqlDateFilter($dateprint, 0, $month, $year); if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; @@ -344,14 +344,14 @@ if ($sql_select) $num = $db->num_rows($resql); - $param="&socid=".$socid."&type_element=".$type_element; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param="&socid=".urlencode($socid)."&type_element=".urlencode($type_element); + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($sprod_fulldescr) $param.= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if ($sref) $param.= "&sref=".urlencode($sref); - if ($month) $param.= "&month=".$month; - if ($year) $param.= "&year=".$year; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($month) $param.= "&month=".urlencode($month); + if ($year) $param.= "&year=".urlencode($year); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); @@ -408,6 +408,7 @@ if ($sql_select) $documentstatic->statut=$objp->status; $documentstatic->status=$objp->status; $documentstatic->paye=$objp->paid; + $documentstatic->paid=$objp->paid; if (is_object($documentstaticline)) $documentstaticline->statut=$objp->status; @@ -573,8 +574,7 @@ if ($sql_select) */ print ''; - //print ''.$prodreftxt.''; - print ''.$objp->libelle.''; + print ''.$objp->type_contact_label.''; // Type of contact label print ''.$objp->prod_qty.''; $total_qty+=$objp->prod_qty; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index ad8bbb68e5f..8533cb13feb 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -51,7 +51,7 @@ if (! empty($canvas)) } // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission // Get parameters @@ -63,8 +63,8 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (! empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield=$conf->global->MAIN_DOC_SORT_FIELD; } - if (! empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder=$conf->global->MAIN_DOC_SORT_ORDER; } +if (! empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield=$conf->global->MAIN_DOC_SORT_FIELD; } +if (! empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder=$conf->global->MAIN_DOC_SORT_ORDER; } if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index 3cb46276d43..2546f5d19e4 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -34,7 +34,7 @@ $langs->load("companies"); // Security check $id = GETPOST("id", 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 826b5d3db39..cf2bf91bf99 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -36,7 +36,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9f3dc206447..f8d92d19b34 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -52,7 +52,7 @@ $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'contactl $id = GETPOST('id', 'int'); $contactid = GETPOST('id', 'int'); $ref = ''; // There is no ref for contacts -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $contactid, ''); $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); @@ -181,15 +181,18 @@ $arrayfields=array( 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + -$object=new Contact($db); if (($id > 0 || ! empty($ref)) && $action != 'add') { $result=$object->fetch($id, $ref); @@ -274,7 +277,7 @@ $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(" $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email, p.skype,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; -$sql.= " co.code as country_code"; +$sql.= " co.label as country, co.code as country_code"; // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -677,9 +680,9 @@ if (! empty($arrayfields['p.thirdparty']['checked'])) if (! empty($arrayfields['p.priv']['checked'])) { print ''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('search_priv', $selectarray, $search_priv, 1); - print ''; + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('search_priv', $selectarray, $search_priv, 1); + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -793,6 +796,8 @@ while ($i < min($num, $limit)) $contactstatic->phone_mobile=$obj->phone_mobile; $contactstatic->zip=$obj->zip; $contactstatic->town=$obj->town; + $contactstatic->country = $obj->country; + $contactstatic->country_code = $obj->country_code; // ID if (! empty($arrayfields['p.rowid']['checked'])) @@ -927,9 +932,9 @@ while ($i < min($num, $limit)) print ''; if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); } else print ' '; @@ -969,7 +974,7 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['p.statut']['checked'])) { - print ''.$contactstatic->getLibStatut(3).''; + print ''.$contactstatic->getLibStatut(5).''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['p.import_key']['checked'])) diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 72ee557c085..230211cca5e 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -36,7 +36,7 @@ $langs->load("companies"); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 3a09f294849..093245025cd 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -35,7 +35,7 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); @@ -319,7 +319,7 @@ else if ($action != 'edit') { // Barre d'actions - if ($user->societe_id == 0) + if ($user->socid == 0) { print '
'; diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index e96425a0dae..4eb794a3054 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -52,7 +52,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contrat', $id, ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -164,19 +164,20 @@ if ($id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->contrat->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ef57c84443b..4e0226d4cae 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -62,7 +62,7 @@ $datecontrat=''; $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'contrat', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -331,9 +331,8 @@ if (empty($reshook)) // Extrafields $array_options = array(); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used - { + // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_options = $lines[$i]->array_options; } @@ -445,13 +444,13 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $error++; - } + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $error++; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -532,7 +531,7 @@ if (empty($reshook)) $pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU'); } else - { + { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); } } @@ -728,9 +727,9 @@ if (empty($reshook)) $objectline->pa_ht=$pa_ht; if ($fk_unit > 0) { - $objectline->fk_unit = GETPOST('unit'); + $objectline->fk_unit = GETPOST('unit'); } else { - $objectline->fk_unit = null; + $objectline->fk_unit = null; } // Extrafields @@ -1257,7 +1256,7 @@ if ($action == 'create') print $doleditor->Create(1); print ''; - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''.$langs->trans("NotePrivate").''; $doleditor=new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); @@ -1419,19 +1418,20 @@ else $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->contrat->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -1890,7 +1890,7 @@ else print ''; print ''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''; print ''; - if ($user->societe_id == 0) + if ($user->socid == 0) { if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { @@ -2098,7 +2098,7 @@ else * Buttons */ - if ($user->societe_id == 0) + if ($user->socid == 0) { print '
'; @@ -2254,7 +2254,7 @@ $db->close(); if (! empty($conf->margin->enabled) && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? -?> + ?> - * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2015-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -189,6 +189,12 @@ class Contrat extends CommonObject protected $lines_id_index_mapper=array(); + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CLOSED = 2; + + + /** * Constructor * @@ -861,9 +867,9 @@ class Contrat extends CommonObject // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$pos] = $line; @@ -1881,40 +1887,31 @@ class Contrat extends CommonObject /** * Renvoi label of a given contrat status * - * @param int $statut Status id + * @param int $status Id status * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable - global $langs; - $langs->load("contracts"); - if ($mode == 0) + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } - elseif ($statut == 1) { return $langs->trans("ContractStatusValidated"); } - elseif ($statut == 2) { return $langs->trans("ContractStatusClosed"); } + global $langs; + $langs->load("contracts"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('ContractStatusDraft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('ContractStatusValidated'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->trans('ContractStatusClosed'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('ContractStatusDraft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('ContractStatusValidated'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->trans('ContractStatusClosed'); } - elseif ($mode == 1) - { - if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } - elseif ($statut == 1) { return $langs->trans("ContractStatusValidated"); } - elseif ($statut == 2) { return $langs->trans("ContractStatusClosed"); } - } - elseif ($mode == 2) - { - if ($statut == 0) { return img_picto($langs->trans('ContractStatusDraft'), 'statut0').' '.$langs->trans("ContractStatusDraft"); } - elseif ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'), 'statut4').' '.$langs->trans("ContractStatusValidated"); } - elseif ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'), 'statut6').' '.$langs->trans("ContractStatusClosed"); } - } - elseif ($mode == 3) - { - if ($statut == 0) { return img_picto($langs->trans('ContractStatusDraft'), 'statut0'); } - elseif ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'), 'statut4'); } - elseif ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'), 'statut6'); } - } - elseif ($mode == 4 || $mode == 6 || $mode == 7) + + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status6'; + + if ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; if ($mode == 4) { @@ -1924,22 +1921,20 @@ class Contrat extends CommonObject $text.=':     '; $text.=''; } - $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="paddingleft2 inline-block valigntextbottom"')).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="paddingleft2 inline-block valigntextbottom"')) : ''; - $text.=($mode == 7?'
':''); + $text.=($mode == 7?'':''); + $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode == 7?'':''); + $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode == 7?'':''); + $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode == 7?'':''); + $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; + $text.=($mode == 7?'':''); return $text; } - elseif ($mode == 5) + else { - if ($statut == 0) { return $langs->trans("ContractStatusDraft").' '.img_picto($langs->trans('ContractStatusDraft'), 'statut0'); } - elseif ($statut == 1) { return $langs->trans("ContractStatusValidated").' '.img_picto($langs->trans('ContractStatusValidated'), 'statut4'); } - elseif ($statut == 2) { return $langs->trans("ContractStatusClosed").' '.img_picto($langs->trans('ContractStatusClosed'), 'statut6'); } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } } @@ -2073,10 +2068,10 @@ class Contrat extends CommonObject /** * Return list of line rowid * - * @param int $statut Status of lines to get + * @param int $status Status of lines to get * @return array|int Array of line's rowid or <0 if error */ - public function array_detail($statut = -1) + public function array_detail($status = -1) { // phpcs:enable $tab=array(); @@ -2084,7 +2079,7 @@ class Contrat extends CommonObject $sql = "SELECT cd.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE fk_contrat =".$this->id; - if ($statut >= 0) $sql.= " AND statut = '$statut'"; + if ($status >= 0) $sql.= " AND statut = ".$status; dol_syslog(get_class($this)."::array_detail()", LOG_DEBUG); $resql=$this->db->query($sql); @@ -2162,7 +2157,7 @@ class Contrat extends CommonObject $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; $this->from.= ", ".MAIN_DB_PREFIX."contratdet as cd"; $this->from.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $this->from.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $this->from.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($mode == 'inactive') { @@ -2193,8 +2188,8 @@ class Contrat extends CommonObject } $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; - if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; $resql=$this->db->query($sql); if ($resql) @@ -2265,7 +2260,7 @@ class Contrat extends CommonObject $sql = "SELECT count(c.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -2728,65 +2723,34 @@ class ContratLigne extends CommonObjectLine /** * Return label of a contract line status * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $expired 0=Not expired, 1=Expired, -1=Both or unknown * @param string $moreatt More attribute * @return string Libelle */ - public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') + public static function LibStatut($status, $mode, $expired = -1, $moreatt = '') { // phpcs:enable global $langs; $langs->load("contracts"); - if ($mode == 0) + + if ($status == self::STATUS_INITIAL) { $labelStatus = $langs->trans("ServiceStatusInitial"); $labelStatusShort = $langs->trans("ServiceStatusInitial"); } + elseif ($status == self::STATUS_OPEN && $expired == -1) { $labelStatus = $langs->trans("ServiceStatusRunning"); $labelStatusShort = $langs->trans("ServiceStatusRunning"); } + elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } + elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } + elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } + + $statusType = 'status'.$status; + if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status3'; + if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + + $params = array(); $reg = array(); + if (preg_match('/class="(.*)"/', $moreatt, $reg)) { - if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLate"); } - elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } - } - elseif ($mode == 1) - { - if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } - elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } - } - elseif ($mode == 2) - { - if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'), 'statut0').' '.$langs->trans("ServiceStatusInitial"); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'), 'statut4').' '.$langs->trans("ServiceStatusRunning"); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'), 'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'), 'statut3').' '.$langs->trans("ServiceStatusLateShort"); } - elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'), 'statut6') .' '.$langs->trans("ServiceStatusClosed"); } - } - elseif ($mode == 3) - { - if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'), 'statut0', $moreatt); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'), 'statut4', $moreatt); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'), 'statut4', $moreatt); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'), 'statut3', $moreatt); } - elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'), 'statut6', $moreatt); } - } - elseif ($mode == 4) - { - if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'), 'statut0').' '.$langs->trans("ServiceStatusInitial"); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'), 'statut4').' '.$langs->trans("ServiceStatusRunning"); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'), 'statut4').' '.$langs->trans("ServiceStatusNotLate"); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'), 'statut3').' '.$langs->trans("ServiceStatusLate"); } - elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'), 'statut6') .' '.$langs->trans("ServiceStatusClosed"); } - } - elseif ($mode == 5) - { - if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'), 'statut0'); } - elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'), 'statut4'); } - elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'), 'statut4'); } - elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'), 'statut3'); } - elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'), 'statut6'); } + $params = array('badgeParams'=>array('css' => $reg[1])); } + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); } /** diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 85247327dda..56a0c198db3 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -43,7 +43,7 @@ $id = GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'contrat', $id); $object = new Contrat($db); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 7fbc291839d..fceba285f47 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -46,11 +46,11 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { unset($_GET["action"]); $action=''; - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'contrat', $id); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 8fd54a4f8e4..9d96ca7be5e 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -46,7 +46,7 @@ $statut=GETPOST('statut')?GETPOST('statut'):1; // Security check $socid=0; $id = GETPOST('id', 'int'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'contrat', $id); $staticcompany=new Societe($db); @@ -114,7 +114,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX $sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))"; $sql.= " AND c.entity IN (".getEntity('contract', 0).")"; -if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cd.statut"; $resql = $db->query($sql); @@ -151,7 +151,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX $sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; $sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')"; $sql.= " AND c.entity IN (".getEntity('contract', 0).")"; -if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cd.statut"; $resql = $db->query($sql); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 0fd27d29826..3df193d53d2 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -84,7 +84,7 @@ if (! $sortorder) $sortorder='DESC'; // Security check $id=GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'contrat', $id); $diroutputmassaction=$conf->contrat->dir_output . '/temp/massgeneration/'.$user->id; diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 25772c08193..e4cceff10e0 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -41,7 +41,7 @@ $id=GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'contrat', $id); $object = new Contrat($db); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index fac71516e99..a7656289fdd 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -90,7 +90,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, // Security check $contratid = GETPOST('id', 'int'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'contrat', $contratid); if ($search_status != '') @@ -705,17 +705,18 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['status']['checked'])) { - print ''; - if ($obj->cstatut == 0) // If contract is draft, we say line is also draft - { - print $contractstatic->LibStatut(0, 5); - } - else - { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); - } - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if ($obj->cstatut == 0) + { + // If contract is draft, we say line is also draft + print $contractstatic->LibStatut(0, 5); + } + else + { + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); + } + print ''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index bda12ea87cb..b52a6939882 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -23,11 +23,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Contract"); ?> getNomUrl(1); ?> date_contrat, 'day'); ?> rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) - { - $totalcontrat = 0; - foreach ($objectlink->lines as $linecontrat) { - $totalcontrat = $totalcontrat + $linecontrat->total_ht; - $total = $total + $linecontrat->total_ht; - } - echo price($totalcontrat); - } ?> + // Price of contract is not shown by default because a contract is a list of service with + // start and end date that change with time andd that may be different that the period of reference for price. + // So price of a contract does often means nothing. Prices is on the different invoices done on same contract. + if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) + { + $totalcontrat = 0; + foreach ($objectlink->lines as $linecontrat) { + $totalcontrat = $totalcontrat + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; + } + echo price($totalcontrat); + } ?> getLibStatut(7); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + '.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - + +print "\n"; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index d618a0702c8..dcb8f75c637 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -56,7 +56,7 @@ if ($action == 'add' && ! empty($permissiontoadd)) $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); - } elseif ($object->fields[$key]['type']=='price') { + } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { $value = GETPOST($key, 'alpha'); @@ -108,7 +108,6 @@ if ($action == 'update' && ! empty($permissiontoadd)) { if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); @@ -116,7 +115,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); - } elseif ($object->fields[$key]['type']=='price') { + } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { $value = GETPOST($key, 'alpha'); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 5402236f47e..92bc2ff18f6 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -57,12 +57,12 @@ if ($action == 'builddoc' && $permissioncreate) // Special case to force bank account //if (property_exists($object, 'fk_bank')) //{ - if (GETPOST('fk_bank', 'int')) { - // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (! empty($object->fk_account)) { - $object->fk_bank = $object->fk_account; - } + if (GETPOST('fk_bank', 'int')) { + // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank', 'int'); + } elseif (! empty($object->fk_account)) { + $object->fk_bank = $object->fk_account; + } //} $outputlangs = $langs; diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index a84edb0150a..1c679c88825 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -57,6 +57,24 @@ if ($action == 'addcomment') } } } +if ($action === 'updatecomment') +{ + if ($comment->fetch($idcomment) >= 0) + { + $comment->description = GETPOST('comment_description', 'none'); + if ($comment->update($user) > 0) + { + setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1#comment':'')); + exit; + } + else + { + setEventMessages($comment->error, $comment->errors, 'errors'); + $action=''; + } + } +} if ($action == 'deletecomment') { if ($comment->fetch($idcomment) >= 0) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 760a54bc7b2..90c93f6177b 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -81,78 +81,79 @@ elseif (GETPOST('linkit', 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete file/link if ($action == 'confirm_deletefile' && $confirm == 'yes') { - $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - if (GETPOST('section', 'alpha')) // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir + $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + if (GETPOST('section', 'alpha')) { + // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir + $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; + } + else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + { + $urlfile=basename($urlfile); + $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; + if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile; + } + $linkid = GETPOST('linkid', 'int'); + + if ($urlfile) { + // delete of a file + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine + $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) + + $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null)); + if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null)); // Delete file using old path + + // Si elle existe, on efface la vignette + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { - $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; - } - else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - { - $urlfile=basename($urlfile); - $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; - if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile; - } - $linkid = GETPOST('linkid', 'int'); - - if ($urlfile) // delete of a file - { - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine - $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) - - $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null)); - if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null)); // Delete file using old path - - // Si elle existe, on efface la vignette - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) + $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { - $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } - - $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } + dol_delete_file($dirthumb.$photo_vignette); } - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); + $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) + { + dol_delete_file($dirthumb.$photo_vignette); + } } - elseif ($linkid) // delete of external link - { - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; - $link = new Link($db); - $link->fetch($linkid); - $res = $link->delete($user); - $langs->load('link'); - if ($res > 0) { - setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); + } + } + elseif ($linkid) // delete of external link + { + require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + $link = new Link($db); + $link->fetch($linkid); + $res = $link->delete($user); + + $langs->load('link'); + if ($res > 0) { + setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); + } else { + if (count($link->errors)) { + setEventMessages('', $link->errors, 'errors'); } else { - if (count($link->errors)) { - setEventMessages('', $link->errors, 'errors'); - } else { - setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); - } + setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); } } + } - if (is_object($object) && $object->id > 0) - { - if ($backtopage) - { - header('Location: ' . $backtopage); - exit; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':'')); - exit; - } + if (is_object($object) && $object->id > 0) { + if ($backtopage) { + header('Location: ' . $backtopage); + exit; } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':'')); + exit; + } + } } elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7d8d621ff92..febcba244c0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1085,7 +1085,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se } else { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index d6a2ba77f05..b369550dda2 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -104,7 +104,7 @@ if (empty($url)) $langs->loadLangs(array("ecm","companies","other")); // Security check -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; //print 'xxx'.$upload_dir; diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index e812e8b9a3c..0d662b6a0bd 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -39,8 +39,8 @@ $element=GETPOST('element', 'alpha'); $object = new GenericObject($db); // Security check -if (! empty($user->societe_id)) - $socid = $user->societe_id; +if (! empty($user->socid)) + $socid = $user->socid; diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 9de6e53a0f5..eec1c9f0aca 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -36,8 +36,8 @@ $hash_algo=GETPOST('hash_algo', 'alpha'); // Security check -if (! empty($user->societe_id)) - $socid = $user->societe_id; +if (! empty($user->socid)) + $socid = $user->socid; $now = dol_now(); diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index af86e73ce2c..c104384434d 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -90,13 +90,13 @@ class box_actions extends ModeleBoxes $sql.= ", s.rowid as socid"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE a.fk_action = ta.id"; $sql.= " AND a.entity = ".$conf->entity; $sql.= " AND a.percent >= 0 AND a.percent < 100"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; $sql.= " ORDER BY a.datec DESC"; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index c18bf2f3bf3..9609f596618 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -84,7 +84,7 @@ class box_activity extends ModeleBoxes $totalnb = 0; $line = 0; $cachetime = 3600; - $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; $now = dol_now(); $nbofperiod=3; @@ -113,12 +113,12 @@ class box_activity extends ModeleBoxes { $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; $sql.= " WHERE p.entity IN (".getEntity('propal').")"; $sql.= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; $sql.= " AND p.date_cloture IS NULL"; // just unclosed $sql.= " GROUP BY p.fk_statut"; @@ -202,12 +202,12 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; $sql.= " WHERE c.entity = ".$conf->entity; $sql.= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; $sql.= " GROUP BY c.fk_statut"; $sql.= " ORDER BY c.fk_statut DESC"; @@ -286,11 +286,11 @@ class box_activity extends ModeleBoxes { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php new file mode 100644 index 00000000000..b4ac04b3051 --- /dev/null +++ b/htdocs/core/boxes/box_boms.php @@ -0,0 +1,182 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_boms.php + * \ingroup bom + * \brief Widget for latest modified BOM + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last orders + */ +class box_boms extends ModeleBoxes +{ + public $boxcode="lastboms"; + public $boximg="object_bom"; + public $boxlabel="BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->bom->read); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql.= ", c.rowid"; + $sql.= ", c.date_creation"; + $sql.= ", c.tms"; + $sql.= ", c.ref"; + $sql.= ", c.status"; + $sql.= ", c.fk_user_valid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql.= " WHERE c.fk_product = p.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " ORDER BY c.tms DESC, c.ref DESC"; + $sql.= " ".$this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + if (! empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'asis' => 1, + ); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 185f581b5c5..feb7564cdaf 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -97,11 +97,11 @@ class box_clients extends ModeleBoxes $sql.= ", s.email"; $sql.= ", s.datec, s.tms, s.status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 3)"; $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND s.rowid = $user->socid"; $sql.= " ORDER BY s.tms DESC"; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 00e3d54386c..40d809fd6e7 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -21,7 +21,7 @@ /** * \file htdocs/core/boxes/box_commandes.php * \ingroup commande - * \brief Module de generation de l'affichage de la box commandes + * \brief Widget for latest sale orders */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -102,12 +102,12 @@ class box_commandes extends ModeleBoxes $sql.= ", c.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 02ed249d3b6..c4259b6252a 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -64,7 +64,7 @@ class box_comptes extends ModeleBoxes // disable module for such cases $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('banque', $listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users + if (! in_array('banque', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users $this->hidden = ! ($user->rights->banque->lire); } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 82db6c9f240..5bdb17ba0b9 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -86,12 +86,14 @@ class box_contacts extends ModeleBoxes $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; $sql.= ", s.nom as socname, s.name_alias, s.email as semail"; $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql.= ", co.label as country, co.code as country_code"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; + if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND sp.fk_soc = ".$user->socid; $sql.= " ORDER BY sp.tms DESC"; $sql.= $this->db->plimit($max, 0); @@ -121,6 +123,8 @@ class box_contacts extends ModeleBoxes $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; + $contactstatic->country = $objp->country; + $contactstatic->country_code = $objp->country_code; $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 0d155f158e9..37fdf45f118 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -87,11 +87,11 @@ class box_contracts extends ModeleBoxes $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; $sql.= ", c.ref_customer, c.ref_supplier"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 09841f4a4a8..65724f5fa4b 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -97,12 +97,12 @@ class box_factures extends ModeleBoxes $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql.= ", f.date_lim_reglement as datelimite"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 46e2da3ab62..9eb836fe1e2 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -99,11 +99,11 @@ class box_factures_fourn extends ModeleBoxes $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 0a6c7e904a3..3c0fc6444a2 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -91,13 +91,13 @@ class box_factures_fourn_imp extends ModeleBoxes $sql.= " f.paye, f.fk_statut, f.type"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ",".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.paye=0"; $sql.= " AND fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " ORDER BY datelimite DESC, f.ref_supplier DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 3c4ba1c9736..992e1333390 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -100,15 +100,15 @@ class box_factures_imp extends ModeleBoxes $sql.= " f.paye, f.fk_statut, f.rowid as facid"; $sql.= ", sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.paye = 0"; $sql.= " AND fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index a646d6556ba..b0851ed28c0 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -92,8 +92,8 @@ class box_ficheinter extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " AND f.entity = ".$conf->entity; - if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (! $user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " ORDER BY f.tms DESC"; $sql.= $this->db->plimit($max, 0); @@ -138,7 +138,7 @@ class box_ficheinter extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="nowrap right"', - 'text' => $ficheinterstatic->getLibStatut(6), + 'text' => $ficheinterstatic->getLibStatut(3), 'asis' => 1, ); diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 6369b25987a..5f26351affe 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -88,11 +88,11 @@ class box_fournisseurs extends ModeleBoxes $sql.= " s.code_fournisseur, s.email as semail,"; $sql.= " s.logo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " ORDER BY s.tms DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index ba0e24ddaab..91ec36fd500 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -92,7 +92,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $dir=''; // We don't need a path because image file will not be saved into disk $prefix=''; $socid=0; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->facture->lire) @@ -135,7 +135,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); @@ -180,7 +181,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 4393e9db790..9be3a986fa9 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -91,7 +91,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $dir=''; // We don't need a path because image file will not be saved into disk $prefix=''; $socid=0; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->facture->lire) @@ -132,7 +132,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; $px1 = new DolGraph(); @@ -143,7 +144,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px1->SetData($data1); unset($data1); - $i=$startyear;$legend=array(); + $i=$startyear; + $legend=array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -177,7 +179,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$year.'.png'; $px2 = new DolGraph(); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 6e5bf253832..5ea1bb9f764 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -92,7 +92,7 @@ class box_graph_orders_permonth extends ModeleBoxes $dir=''; // We don't need a path because image file will not be saved into disk $prefix=''; $socid=0; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->commande->lire) @@ -135,7 +135,8 @@ class box_graph_orders_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); @@ -144,7 +145,8 @@ class box_graph_orders_permonth extends ModeleBoxes { $px1->SetData($data1); unset($data1); - $i=$startyear;$legend=array(); + $i=$startyear; + $legend=array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -178,7 +180,8 @@ class box_graph_orders_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 443f374346d..fba42b42eba 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -91,7 +91,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $dir=''; // We don't need a path because image file will not be saved into disk $prefix=''; $socid=0; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->commande->lire) @@ -134,7 +134,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=orderssuppliernbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); @@ -143,7 +144,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { $px1->SetData($data1); unset($data1); - $i=$startyear;$legend=array(); + $i=$startyear; + $legend=array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -177,7 +179,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; + // default value for customer mode + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=orderssupplieramountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 332f92b7ace..7bcc85aa47f 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -128,7 +128,7 @@ class box_graph_product_distribution extends ModeleBoxes ); - $socid=empty($user->societe_id)?0:$user->societe_id; + $socid=empty($user->socid)?0:$user->socid; $userid=0; // No filter on user creation $WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index a06c5d8ff83..150e9517c8a 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -94,7 +94,7 @@ class box_graph_propales_permonth extends ModeleBoxes $dir=''; // We don't need a path because image file will not be saved into disk $prefix=''; $socid=0; - if ($user->societe_id) $socid=$user->societe_id; + if ($user->socid) $socid=$user->socid; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->propale->lire) diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 56299c60429..de2bbd79181 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -96,9 +96,9 @@ class box_last_modified_ticket extends ModeleBoxes $sql.= " WHERE t.entity = ".$conf->entity; // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) { - $sql.= " AND t.fk_soc= ".$user->societe_id; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql.= " AND t.fk_soc= ".$user->socid; } $sql.= " ORDER BY t.tms DESC, t.rowid DESC "; diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index cf4b7f305f7..4c66c647477 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -96,9 +96,9 @@ class box_last_ticket extends ModeleBoxes $sql .= " WHERE t.entity = " . $conf->entity; // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) { - $sql .= " AND t.fk_soc= " . $user->societe_id; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= " . $user->socid; } //$sql.= " AND t.fk_statut > 9"; diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 1e4588f05cf..29f37751ce9 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -63,7 +63,7 @@ class box_members extends ModeleBoxes // disable module for such cases $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users + if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users $this->hidden = ! ($user->rights->adherent->lire); } diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php new file mode 100644 index 00000000000..32ae864fc2f --- /dev/null +++ b/htdocs/core/boxes/box_mos.php @@ -0,0 +1,182 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_mos.php + * \ingroup mrp + * \brief Widget for latest modified MOs + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last orders + */ +class box_mos extends ModeleBoxes +{ + public $boxcode="lastmos"; + public $boximg="object_mrp"; + public $boxlabel="BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->bom->read); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql.= ", c.rowid"; + $sql.= ", c.date_creation"; + $sql.= ", c.tms"; + $sql.= ", c.ref"; + $sql.= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql.= " WHERE c.fk_product = p.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " ORDER BY c.tms DESC, c.ref DESC"; + $sql.= " ".$this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + if (! empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'asis' => 1, + ); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 23c4cc368cf..5cccd24ad6a 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -63,7 +63,7 @@ class box_produits extends ModeleBoxes $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 22509a6c9a2..3c674cd32c0 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -65,7 +65,7 @@ class box_produits_alerte_stock extends ModeleBoxes $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode=isVisibleToUserType(($user->societe_id > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 9053e5f2ab3..48a6d260e2c 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -89,7 +89,7 @@ class box_project extends ModeleBoxes $projectstatic = new Project($this->db); $socid=0; - //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. // Get list of project id allowed to user (in a string list separated by coma) $projectsListId=''; diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 0ba1b1565f8..1fe8c2a0ed8 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -88,11 +88,11 @@ class box_propales extends ModeleBoxes $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index b489247e0b1..9d6a10b6225 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -94,11 +94,11 @@ class box_prospect extends ModeleBoxes $sql.= ", s.logo"; $sql.= ", s.fk_stcomm, s.datec, s.tms, s.status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (2, 3)"; $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " ORDER BY s.tms DESC"; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index f080403aba3..dbb26408b6f 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -96,10 +96,10 @@ class box_services_contracts extends ModeleBoxes $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= ")"; $sql.= " WHERE c.entity = ".$conf->entity; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= $this->db->order("c.tms", "DESC"); $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index b56674adaa0..9ddfa229e55 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -87,12 +87,12 @@ class box_services_expired extends ModeleBoxes $sql.= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; $sql.= " ORDER BY date_line ASC"; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 42c1b7464b9..a95c008688b 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -93,11 +93,11 @@ class box_supplier_orders extends ModeleBoxes $sql.= " c.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index e285cc34289..1039ea74385 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -119,25 +119,25 @@ class box_task extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { $boxcontent.= '
'."\n"; - $boxcontent.= '
'."\n"; + $boxcontent.= '
'."\n"; $boxcontent.= '
boxcode.'">'."\n"; $boxcontent.= ''."\n"; $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); $boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent.= ''; + $boxcontent.= ''; $boxcontent.= '
'."\n"; $boxcontent.= '
'."\n"; $boxcontent.= ''; // set cookie by js $boxcontent.=''; $this->info_box_contents[0][] = array( - 'tr'=>'class="nohover"', + 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', 'textnoformat' => $boxcontent, ); @@ -188,7 +188,7 @@ class box_task extends ModeleBoxes $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent = getTaskProgressView($taskstatic, $label, true, false, true); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); $this->info_box_contents[$i][] = array( 'td' => '', diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 8cc8de94295..f5399cd9eea 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -216,7 +216,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box $cachetime = 900; // 900 : 15mn $cachedir = DOL_DATA_ROOT.'/boxes/temp'; - $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'.cache'; + $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; $filename = '/box-'.$fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $out = ''; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 37e8270d449..cfdb09c527e 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -54,12 +54,12 @@ class Canvas public $control; // Initialized by getCanvas with controller instance - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') + */ public function __construct($db, $actiontype = 'view') { $this->db = $db; diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index edbceec50fd..0934d85b3e7 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -171,16 +171,16 @@ class Ccountry // extends CommonObject public function fetch($id, $code = '', $code_iso = '') { global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.code,"; $sql.= " t.code_iso,"; $sql.= " t.label,"; $sql.= " t.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql.= " WHERE t.rowid = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 3f4b486f547..18c20b0b07c 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -62,6 +62,11 @@ class Comment extends CommonObject */ public $fk_user_author; + /** + * @var int ID + */ + public $fk_user_modif; + /** * @var int Entity */ @@ -94,17 +99,18 @@ class Comment extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf, $langs; + global $user; $error=0; // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql.= "description"; $sql.= ", datec"; $sql.= ", fk_element"; $sql.= ", element_type"; $sql.= ", fk_user_author"; + $sql.= ", fk_user_modif"; $sql.= ", entity"; $sql.= ", import_key"; $sql.= ") VALUES ("; @@ -113,6 +119,7 @@ class Comment extends CommonObject $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; $sql.= ", '".$this->db->escape($this->element_type)."'"; $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; + $sql.= ", ".$user->id.""; $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= ")"; @@ -128,7 +135,7 @@ class Comment extends CommonObject if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); if (! $notrigger) { @@ -177,9 +184,10 @@ class Comment extends CommonObject $sql.= " c.fk_element,"; $sql.= " c.element_type,"; $sql.= " c.fk_user_author,"; + $sql.= " c.fk_user_modif,"; $sql.= " c.entity,"; $sql.= " c.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c"; $sql.= " WHERE c.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -196,8 +204,9 @@ class Comment extends CommonObject $this->description = $obj->description; $this->element_type = $obj->element_type; $this->datec = $this->db->jdate($obj->datec); - $this->tms = $obj->tms; + $this->tms = $this->db->jdate($obj->tms); $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; $this->fk_element = $obj->fk_element; $this->entity = $obj->entity; $this->import_key = $obj->import_key; @@ -225,22 +234,21 @@ class Comment extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $conf, $langs; + global $user; $error=0; // Clean parameters if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); if (isset($this->description)) $this->description=trim($this->description); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; $sql.= " element_type='".$this->db->escape($this->element_type)."',"; - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; + $sql.= " fk_user_modif=".$user->id.","; $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= " WHERE rowid=".$this->id; @@ -297,7 +305,7 @@ class Comment extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql.= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); @@ -345,7 +353,7 @@ class Comment extends CommonObject if(!empty($element_type) && !empty($fk_element)) { $sql = "SELECT"; $sql.= " c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c"; $sql.= " WHERE c.fk_element = ".$fk_element; $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; $sql.= " AND c.entity = ".$conf->entity; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ee5b97c502a..9b3304560d9 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -224,15 +224,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); } @@ -298,15 +298,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key => $label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) { - if ($extrafields->attribute_type[$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; } $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); } @@ -585,7 +585,7 @@ abstract class CommonDocGenerator { $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); - } + } // Retrieve extrafields $extrafieldkey=$line->element; @@ -595,7 +595,30 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($extrafieldkey, true); $line->fetch_optionals(); - $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); + $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); + + // Check if the current line belongs to a supplier order + if (get_class($line) == 'CommandeFournisseurLigne') + { + // Add the product supplier extrafields to the substitutions + $extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $columns = ""; + foreach ($extralabels as $key => $value) + $columns .= "$key, "; + + if ($columns != "") + { + $columns = substr($columns, 0, strlen($columns) - 2); + $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '" . $line->ref_supplier . "'"); + if ($this->db->num_rows($resql) > 0) { + $resql = $this->db->fetch_object($resql); + + foreach ($extralabels as $key => $value) + $resarray['line_product_supplier_'.$key] = $resql->{$key}; + } + } + } // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" if (isset($line->fk_product) && $line->fk_product > 0) @@ -643,11 +666,11 @@ abstract class CommonDocGenerator $array_key.'_tracking_number'=>$object->tracking_number, $array_key.'_tracking_url'=>$object->tracking_url, $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], - $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), - $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), - $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), - $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), - $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), + $array_key.'_weight'=>$object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), + $array_key.'_width'=>$object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), + $array_key.'_height'=>$object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), + $array_key.'_depth'=>$object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), + $array_key.'_size'=>$calculatedVolume.' '.measuringUnitString(0, 'volume'), ); // Add vat by rates @@ -701,10 +724,10 @@ abstract class CommonDocGenerator 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), + 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields @@ -765,30 +788,30 @@ abstract class CommonDocGenerator { // phpcs:enable global $conf; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attribute_type[$key] == 'select') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - elseif($extrafields->attribute_type[$key] == 'checkbox') { + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray=explode(',', $object->array_options['options_'.$key]); $output=array(); - foreach($extrafields->attribute_param[$key]['options'] as $keyopt=>$valopt) { + foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { if (in_array($keyopt, $valArray)) { $output[]=$valopt; } } $object->array_options['options_'.$key] = implode(', ', $output); } - elseif($extrafields->attribute_type[$key] == 'date') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { if (strlen($object->array_options['options_'.$key])>0) { @@ -806,7 +829,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'datetime') + elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language @@ -815,7 +838,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'link') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { $id = $object->array_options['options_'.$key]; if ($id != "") diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index d834fcfe943..b6381ccc7ca 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -154,7 +154,7 @@ abstract class CommonInvoice extends CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // TODO - return 0; + return 0; } require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -496,27 +496,27 @@ abstract class CommonInvoice extends CommonObject $prefix='Short'; if (! $paye){ if ($status == 0) { - $labelstatut = $langs->trans('BillStatusDraft'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusDraft'); + $labelStatus = $langs->trans('BillStatusDraft'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusDraft'); } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { - $labelstatut = $langs->trans('BillStatusClosedUnpaid'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); + $labelStatus = $langs->trans('BillStatusClosedUnpaid'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); $statusType='status5'; } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { - $labelstatut = $langs->trans('BillStatusClosedPaidPartially'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + $labelStatus = $langs->trans('BillStatusClosedPaidPartially'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); $statusType='status9'; } elseif ($alreadypaid <= 0) { - $labelstatut = $langs->trans('BillStatusNotPaid'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusNotPaid'); + $labelStatus = $langs->trans('BillStatusNotPaid'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusNotPaid'); $statusType='status1'; } else { - $labelstatut = $langs->trans('BillStatusStarted'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusStarted'); + $labelStatus = $langs->trans('BillStatusStarted'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusStarted'); $statusType='status3'; } } @@ -525,21 +525,20 @@ abstract class CommonInvoice extends CommonObject $statusType='status6'; if ($type == self::TYPE_CREDIT_NOTE){ - $labelstatut = $langs->trans('BillStatusPaidBackOrConverted'); // credit note - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note + $labelStatus = $langs->trans('BillStatusPaidBackOrConverted'); // credit note + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note } elseif ($type == self::TYPE_DEPOSIT){ - $labelstatut = $langs->trans('BillStatusConverted'); // deposit invoice - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice + $labelStatus = $langs->trans('BillStatusConverted'); // deposit invoice + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice } else{ - $labelstatut = $langs->trans('BillStatusPaid'); - $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaid'); + $labelStatus = $langs->trans('BillStatusPaid'); + $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusPaid'); } } - - return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index abd8e38ce97..0f70652242c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2019 Nicolas ZABOURI * Copyright (C) 2017 Rui Strecht - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -421,7 +421,12 @@ abstract class CommonObject public $civility_id; // Dates - public $date_creation; // Date creation + /** + * @var integer|string date_creation + */ + public $date_creation; + + public $date_validation; // Date validation public $date_modification; // Date last change (tms field) @@ -1057,13 +1062,13 @@ abstract class CommonObject /** * Get array of all contacts for an object * - * @param int $statut Status of links to get (-1=all) + * @param int $status Status of links to get (-1=all) * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array|int Array of contacts, -1 if error */ - public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') + public function liste_contact($status = -1, $source = 'external', $list = 0, $code = '') { // phpcs:enable global $langs; @@ -1086,7 +1091,7 @@ abstract class CommonObject if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; $sql.= " AND tc.active=1"; - if ($statut >= 0) $sql.= " AND ec.statut = '".$statut."'"; + if ($status >= 0) $sql.= " AND ec.statut = ".$status; $sql.=" ORDER BY t.lastname ASC"; dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); @@ -1741,7 +1746,7 @@ abstract class CommonObject // Security on socid $socid = 0; - if ($user->societe_id > 0) $socid = $user->societe_id; + if ($user->socid > 0) $socid = $user->socid; // this->ismultientitymanaged contains // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -1882,13 +1887,19 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if ($this->table_element == 'actioncomm') + if (! empty($this->fields['fk_project'])) // Common case + { + if ($projectid) $sql.= ' SET fk_project = '.$projectid; + else $sql.= ' SET fk_project = NULL'; + $sql.= ' WHERE rowid = '.$this->id; + } + elseif ($this->table_element == 'actioncomm') // Special case for actioncomm { if ($projectid) $sql.= ' SET fk_project = '.$projectid; else $sql.= ' SET fk_project = NULL'; $sql.= ' WHERE id = '.$this->id; } - else + else // Special case for old architecture objects { if ($projectid) $sql.= ' SET fk_projet = '.$projectid; else $sql.= ' SET fk_projet = NULL'; @@ -3817,17 +3828,18 @@ abstract class CommonObject $totalWeight += $weight * $qty * $trueWeightUnit; } else { - if ($weight_units == 99) { - // conversion 1 Pound = 0.45359237 KG - $trueWeightUnit = 0.45359237; - $totalWeight += $weight * $qty * $trueWeightUnit; - } elseif ($weight_units == 98) { - // conversion 1 Ounce = 0.0283495 KG - $trueWeightUnit = 0.0283495; - $totalWeight += $weight * $qty * $trueWeightUnit; - } - else + if ($weight_units == 99) { + // conversion 1 Pound = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 Ounce = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else { $totalWeight += $weight * $qty; // This may be wrong if we mix different units + } } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { @@ -4598,259 +4610,258 @@ abstract class CommonObject */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams = null) { - global $conf, $langs, $user, $hookmanager; + global $conf, $langs, $user, $hookmanager, $action; $srctemplatepath=''; $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if(empty($reshook)) + if (empty($reshook)) { - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); - // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp=explode(':', $modele, 2); - if (! empty($tmp[1])) - { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } + // If selected model is a filename template (then $modele="modelname" or "modelname:filename") + $tmp=explode(':', $modele, 2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('doc','pdf') as $prefix) - { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php - else $file = $prefix."_".$modele.".modules.php"; + // Search template files + $file=''; + $classname=''; + $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('doc','pdf') as $prefix) + { + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + else $file = $prefix."_".$modele.".modules.php"; - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir.$modelspath.$file, 0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir.$modelspath.$file, 0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } - // If generator was found - if ($filefound) - { - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. + // If generator was found + if ($filefound) + { + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. - require_once $file; + require_once $file; - $obj = new $classname($this->db); + $obj = new $classname($this->db); - // If generator is ODT, we must have srctemplatepath defined, if not we set it. - if ($obj->type == 'odt' && empty($srctemplatepath)) - { - $varfortemplatedir=$obj->scandir; - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) - { - $dirtoscan=$conf->global->$varfortemplatedir; + // If generator is ODT, we must have srctemplatepath defined, if not we set it. + if ($obj->type == 'odt' && empty($srctemplatepath)) + { + $varfortemplatedir=$obj->scandir; + if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) + { + $dirtoscan=$conf->global->$varfortemplatedir; - $listoffiles=array(); + $listoffiles=array(); - // Now we add first model found in directories scanned - $listofdir=explode(',', $dirtoscan); - foreach($listofdir as $key => $tmpdir) - { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (is_dir($tmpdir)) - { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); - } - } + // Now we add first model found in directories scanned + $listofdir=explode(',', $dirtoscan); + foreach($listofdir as $key => $tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { unset($listofdir[$key]); continue; } + if (is_dir($tmpdir)) + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } - if (count($listoffiles)) - { - foreach($listoffiles as $record) - { - $srctemplatepath=$record['fullname']; - break; - } - } - } + if (count($listoffiles)) + { + foreach($listoffiles as $record) + { + $srctemplatepath=$record['fullname']; + break; + } + } + } - if (empty($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; - return -1; - } - } + if (empty($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + return -1; + } + } - if ($obj->type == 'odt' && ! empty($srctemplatepath)) - { - if (! dol_is_file($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; - return -1; - } - } + if ($obj->type == 'odt' && ! empty($srctemplatepath)) + { + if (! dol_is_file($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + return -1; + } + } - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) - { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); - } - else - { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); - } - // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. + if (in_array(get_class($this), array('Adherent'))) + { + $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); + } + else + { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + } + // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. - if ($resultwritefile > 0) - { - $outputlangs->charset_output=$sav_charset_output; + if ($resultwritefile > 0) + { + $outputlangs->charset_output=$sav_charset_output; - // We delete old preview - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($this); + // We delete old preview + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($this); - // Index file in database - if (! empty($obj->result['fullpath'])) - { - $destfull = $obj->result['fullpath']; - $upload_dir = dirname($destfull); - $destfile = basename($destfull); - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); + // Index file in database + if (! empty($obj->result['fullpath'])) + { + $destfull = $obj->result['fullpath']; + $upload_dir = dirname($destfull); + $destfile = basename($destfull); + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir - { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($destfile); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); - // Set the public "share" key - $setsharekey = false; - if ($this->element == 'propal') - { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey=true; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } + // Set the public "share" key + $setsharekey = false; + if ($this->element == 'propal') + { + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey=true; + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + } + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } - if ($setsharekey) - { - if (empty($ecmfile->share)) // Because object not found or share not set yet - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $ecmfile->share = getRandomPassword(true); - } - } + if ($setsharekey) { + if (empty($ecmfile->share)) // Because object not found or share not set yet + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + } - if ($result > 0) - { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->update($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } - else - { - $ecmfile->entity = $conf->entity; - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $ecmfile->src_object_type = $this->table_element; - $ecmfile->src_object_id = $this->id; + if ($result > 0) + { + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->update($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + else + { + $ecmfile->entity = $conf->entity; + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_id = $this->id; - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } + $result = $ecmfile->create($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } - /*$this->result['fullname']=$destfull; - $this->result['filepath']=$ecmfile->filepath; - $this->result['filename']=$ecmfile->filename;*/ - //var_dump($obj->update_main_doc_field);exit; + /*$this->result['fullname']=$destfull; + $this->result['filepath']=$ecmfile->filepath; + $this->result['filename']=$ecmfile->filename;*/ + //var_dump($obj->update_main_doc_field);exit; - // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field=0; - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; - if ($update_main_doc_field && ! empty($this->table_element)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql.= ' WHERE rowid = '.$this->id; + // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) + $update_main_doc_field=0; + if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; + if ($update_main_doc_field && ! empty($this->table_element)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; + $sql.= ' WHERE rowid = '.$this->id; - $resql = $this->db->query($sql); - if (! $resql) dol_print_error($this->db); - else - { - $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; - } - } - } - } - else - { - dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); - } + $resql = $this->db->query($sql); + if (! $resql) { + dol_print_error($this->db); + } else { + $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; + } + } + } + } + else + { + dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); + } - // Success in building document. We build meta file. - dol_meta_create($this); + // Success in building document. We build meta file. + dol_meta_create($this); - return 1; - } - else - { - $outputlangs->charset_output=$sav_charset_output; - dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); - return -1; - } - } - else - { - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); - dol_print_error('', $this->error); - return -1; - } + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); + return -1; + } + } + else + { + $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); + dol_print_error('', $this->error); + return -1; + } } else return $reshook; } @@ -5618,7 +5629,7 @@ abstract class CommonObject { $morecss = 'minwidth100imp'; } - elseif ($type == 'datetime') + elseif ($type == 'datetime' || $type == 'link') { $morecss = 'minwidth200imp'; } @@ -6056,18 +6067,19 @@ abstract class CommonObject $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); } } - if (empty($labeltoshow)) + if (empty($labeltoshow)) { $labeltoshow = '(not defined)'; + } - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $data[$obj->rowid]=$labeltoshow; - } - - if (! empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; - } - + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { $data[$obj->rowid]=$labeltoshow; + } + + if (! empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName . ':' . $obj->{$parentField}; + } + + $data[$obj->rowid]=$labeltoshow; } $i ++; @@ -6086,7 +6098,7 @@ abstract class CommonObject $param_list_array = explode(':', $param_list[0]); $showempty=(($required && $default != '')?0:1); - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', '', '', 0, empty($val['disabled'])?0:1); + $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1); if (! empty($param_list_array[2])) // If we set to add a create button { @@ -7469,6 +7481,7 @@ abstract class CommonObject { $sql="UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id; $resqlupdate = $this->db->query($sql); + if ($resqlupdate===false) { $error++; diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 6c6b14ee4e4..83450ee6462 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -182,16 +182,16 @@ abstract class CommonStickerGenerator for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($x2-1)) { - $pdf->Line($j, $y1, $j+1, $y1); // on trace le pointill? du haut, point par point - $pdf->Line($j, $y2, $j+1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y1, $j+1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y2, $j+1, $y2); // on trace le pointill? du bas, point par point } } } for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($y2-1)) { - $pdf->Line($x1, $j, $x1, $j+1); // on trace le pointill? du haut, point par point - $pdf->Line($x2, $j, $x2, $j+1); // on trace le pointill? du bas, point par point + $pdf->Line($x1, $j, $x1, $j+1); // on trace le pointill? du haut, point par point + $pdf->Line($x2, $j, $x2, $j+1); // on trace le pointill? du bas, point par point } } } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 72aa4bc4265..9ba90d00e62 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -353,6 +353,12 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; + // For backward compatibility + $this->banque->multidir_output = array($this->entity => $rootfordata."/bank"); + $this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); + $this->banque->dir_output=$rootfordata."/bank"; + $this->banque->dir_temp=$rootfordata."/bank/temp"; + // For medias storage $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 19588333fcb..cc87a791c0d 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -392,10 +392,10 @@ class CoreObject extends CommonObject */ public function setDate($field, $date) { - if (empty($date)) - { - $this->{$field} = 0; - } + if (empty($date)) + { + $this->{$field} = 0; + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 5048e74b711..c790d89e407 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -252,7 +252,7 @@ class Ctyperesource $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' ' . $this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 07cd778d3a0..e37849ff99a 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -247,8 +247,8 @@ class CUnits // extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid' || $key=='t.active') { - $sqlwhere[] = $key . '='. $value; + if ($key=='t.rowid' || $key=='t.active' || $key=='t.scale') { + $sqlwhere[] = $key . '='. (int) $value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index cc6172e441a..a0879160727 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -157,7 +157,7 @@ class DolEditor $fullpage=false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all } $found=0; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 07554671497..461867041eb 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -944,9 +944,9 @@ class DolGraph if (! empty($this->title)) $this->stringtoshow.='
'.$this->title.'
'; if (! empty($this->shownographyet)) { - $this->stringtoshow.='
'; - $this->stringtoshow.='
'.$langs->trans("NotEnoughDataYet").'
'; - return; + $this->stringtoshow.='
'; + $this->stringtoshow.='
'.$langs->trans("NotEnoughDataYet").'
'; + return; } $this->stringtoshow.='
'."\n"; diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 155050c6997..c4af5773885 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -105,7 +105,13 @@ class EmailSenderProfile extends CommonObject public $label; public $email; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $tms; //public $fk_user_creat; //public $fk_user_modif; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f59aaab7bfa..67693b83c6b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1029,7 +1029,7 @@ class ExtraFields { $morecss = 'minwidth100imp'; } - elseif ($type == 'datetime') + elseif ($type == 'datetime' || $type == 'link') { $morecss = 'minwidth200imp'; } @@ -1573,9 +1573,9 @@ class ExtraFields if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; */ - if (! empty($help)) { + if (! empty($help) && $keyprefix != 'search_options_') { $out .= $form->textwithpicto('', $help, 1, 'help', '', 0, 3); - } + } return $out; } @@ -2088,6 +2088,7 @@ class ExtraFields else { $value_key=GETPOST("options_".$key); + if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; } $object->array_options["options_".$key]=$value_key; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 94dea68ed67..0eed1a56580 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -248,12 +248,12 @@ class Fiscalyear extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); @@ -290,42 +290,42 @@ class Fiscalyear extends CommonObject /** * Give a label from a status * - * @param int $statut Id status + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8').' '.$langs->trans($this->statuts_short[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8'); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8'); } elseif ($mode == 4) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b4c52117ea9..0aca6a94213 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -227,14 +227,14 @@ class Form } elseif (preg_match('/^select;/', $typeofdata)) { - $arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata)); - foreach($arraydata as $val) - { - $tmp=explode(':', $val); - $tmpkey=str_replace('|', ':', $tmp[0]); - $arraylist[$tmpkey]=$tmp[1]; - } - $ret.=$this->selectarray($htmlname, $arraylist, $value); + $arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata)); + foreach($arraydata as $val) + { + $tmp=explode(':', $val); + $tmpkey=str_replace('|', ':', $tmp[0]); + $arraylist[$tmpkey]=$tmp[1]; + } + $ret.=$this->selectarray($htmlname, $arraylist, $value); } elseif (preg_match('/^ckeditor/', $typeofdata)) { @@ -1651,7 +1651,7 @@ class Form $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; } } - if (! empty($user->societe_id)) $sql.= " AND u.fk_soc = ".$user->societe_id; + if (! empty($user->socid)) $sql.= " AND u.fk_soc = ".$user->socid; if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN (".$excludeUsers.")"; if ($includeUsers) $sql.= " AND u.rowid IN (".$includeUsers.")"; if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql.= " AND u.statut <> 0"; @@ -2416,16 +2416,18 @@ class Form // Units $outvalUnits = ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { if (!empty($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; } if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { - $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); + $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) { @@ -2436,17 +2438,17 @@ class Form $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); } } @@ -2458,8 +2460,10 @@ class Form } if (! empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if ($objp->stock > 0) $opt.= ' class="product_line_stock_ok"'; - elseif ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; + if (! empty($user->rights->stock->lire)) { + if ($objp->stock > 0) $opt.= ' class="product_line_stock_ok"'; + elseif ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; + } } $opt.= '>'; $opt.= $objp->ref; @@ -2602,37 +2606,39 @@ class Form if (! empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - $opt.= ' - '.$langs->trans("Stock").':'.$objp->stock; + if (! empty($user->rights->stock->lire)) { + $opt.= ' - '.$langs->trans("Stock").':'.$objp->stock; - if ($objp->stock > 0) { - $outval.= ' - '; - }elseif ($objp->stock <= 0) { - $outval.= ' - '; - } - $outval.= $langs->transnoentities("Stock").':'.$objp->stock; - $outval.= ''; - if (! empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation - { - $langs->load("stocks"); + if ($objp->stock > 0) { + $outval.= ' - '; + }elseif ($objp->stock <= 0) { + $outval.= ' - '; + } + $outval.= $langs->transnoentities("Stock").':'.$objp->stock; + $outval.= ''; + if (! empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation + { + $langs->load("stocks"); - $tmpproduct=new Product($this->db); - $tmpproduct->fetch($objp->rowid); - $tmpproduct->load_virtual_stock(); - $virtualstock = $tmpproduct->stock_theorique; + $tmpproduct=new Product($this->db); + $tmpproduct->fetch($objp->rowid); + $tmpproduct->load_virtual_stock(); + $virtualstock = $tmpproduct->stock_theorique; - $opt.= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; + $opt.= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; - $outval.=' - '.$langs->transnoentities("VirtualStock").':'; - if ($virtualstock > 0) { - $outval.= ' - '; - }elseif ($virtualstock <= 0) { - $outval.= ' - '; - } - $outval.=$virtualstock; - $outval.=''; + $outval.=' - '.$langs->transnoentities("VirtualStock").':'; + if ($virtualstock > 0) { + $outval.= ' - '; + }elseif ($virtualstock <= 0) { + $outval.= ' - '; + } + $outval.=$virtualstock; + $outval.=''; - unset($tmpproduct); - } + unset($tmpproduct); + } + } } $opt.= "\n"; @@ -2802,7 +2808,7 @@ class Form $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 . ' ' . measuring_units_string($objp->length_units, 'size'); + $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) { @@ -2827,15 +2833,6 @@ class Form } } - $opt = '\n"; @@ -3755,7 +3765,7 @@ class Form * * @param string $selected Id account pre-selected * @param string $htmlname Name of select zone - * @param int $statut Status of searched accounts (0=open, 1=closed, 2=both) + * @param int $status Status of searched accounts (0=open, 1=closed, 2=both) * @param string $filtre To filter list * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param string $moreattrib To add more attribute on select @@ -3763,7 +3773,7 @@ class Form * @param string $morecss More CSS * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - public function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') + public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') { // phpcs:enable global $langs, $conf; @@ -3774,7 +3784,7 @@ class Form $sql = "SELECT rowid, label, bank, clos as status, currency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE entity IN (".getEntity('bank_account').")"; - if ($statut != 2) $sql.= " AND clos = '".$statut."'"; + if ($status != 2) $sql.= " AND clos = ".(int) $status; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY label"; @@ -3805,7 +3815,7 @@ class Form } print trim($obj->label); if ($showcurrency) print ' ('.$obj->currency_code.')'; - if ($statut == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; + if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')'; print ''; $i++; } @@ -3813,7 +3823,7 @@ class Form } else { - if ($statut == 0) print ''.$langs->trans("NoActiveBankAccountDefined").''; + if ($status == 0) print ''.$langs->trans("NoActiveBankAccountDefined").''; else print ''.$langs->trans("NoBankAccountFound").''; } } @@ -3829,13 +3839,13 @@ class Form * * @param string $selected Id establishment pre-selected * @param string $htmlname Name of select zone - * @param int $statut Status of searched establishment (0=open, 1=closed, 2=both) + * @param int $status Status of searched establishment (0=open, 1=closed, 2=both) * @param string $filtre To filter list * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param string $moreattrib To add more attribute on select * @return int <0 if error, Num of establishment found if OK (0, 1, 2, ...) */ - public function selectEstablishments($selected = '', $htmlname = 'entity', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '') + public function selectEstablishments($selected = '', $htmlname = 'entity', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '') { // phpcs:enable global $langs, $conf; @@ -3846,7 +3856,7 @@ class Form $sql = "SELECT rowid, name, fk_country, status, entity"; $sql.= " FROM ".MAIN_DB_PREFIX."establishment"; $sql.= " WHERE 1=1"; - if ($statut != 2) $sql.= " AND status = '".$statut."'"; + if ($status != 2) $sql.= " AND status = ".(int) $status; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY name"; @@ -3876,7 +3886,7 @@ class Form print ''; $i++; } @@ -3884,7 +3894,7 @@ class Form } else { - if ($statut == 0) print ''.$langs->trans("NoActiveEstablishmentDefined").''; + if ($status == 0) print ''.$langs->trans("NoActiveEstablishmentDefined").''; else print ''.$langs->trans("NoEstablishmentFound").''; } } @@ -4060,13 +4070,13 @@ class Form * @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , )) * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ... * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' - * @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx - * @param int $height Force height of box + * @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx + * @param int $height Force height of box (0 = auto) * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a
section. * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0) + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) { global $langs,$conf; global $useglobalvars; @@ -4080,6 +4090,14 @@ class Form $newselectedchoice=empty($selectedchoice)?"no":$selectedchoice; if ($conf->browser->layout == 'phone') $width='95%'; + // Set height automatically if not defined + if (empty($height)) { + $height = 210; + if (is_array($formquestion) && count($formquestion) > 2) { + $height += ((count($formquestion) - 2) * 24); + } + } + if (is_array($formquestion) && ! empty($formquestion)) { // First add hidden fields and value @@ -4095,7 +4113,7 @@ class Form } // Now add questions - $more.=''."\n"; + $more.='
'."\n"; if (! empty($formquestion['text'])) $more.='
'."\n"; foreach ($formquestion as $key => $input) { @@ -4107,52 +4125,52 @@ class Form if ($input['type'] == 'text') { - $more.=''.$input['label'].''."\n"; + $more.='
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'password') { - $more.=''.$input['label'].''."\n"; + $more.='
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'select') { - $more.=''; - if (! empty($input['label'])) $more.=$input['label'].''."\n"; + $more.=''."\n"; } elseif ($input['type'] == 'checkbox') { - $more.=''; - $more.=''.$input['label'].' '; - if ($i==0) $more.=''.$input['label'].''; - else $more.=' '; - $more.=''; - $more.=''."\n"; + $more.=''."\n"; $formquestion[] = array('name'=>$input['name'].'day'); $formquestion[] = array('name'=>$input['name'].'month'); $formquestion[] = array('name'=>$input['name'].'year'); @@ -4161,21 +4179,21 @@ class Form } elseif ($input['type'] == 'other') { - $more.=''; - if (! empty($input['label'])) $more.=$input['label'].''."\n"; + $more.=''."\n"; } elseif ($input['type'] == 'onecolumn') { - $more.=''."\n"; + $more.=''."\n"; } } } - $more.='
'.$formquestion['text'].'
'; + $more.='
'; + if (! empty($input['label'])) $more.=$input['label'].'
'; $more.=$this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); - $more.='
'; + $more.='
'; + $more.='
'.$input['label'].'
'; $more.=' $selval) { - $more.='
'.$input['label'].''; + else $more.='
 
'; + $more.='
'.$input['label'].'
'; + $more.='
'.$input['label'].'
'; + $more.='
'; $more.=$this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0); - $more.='
'; + $more.='
'; + if (! empty($input['label'])) $more.=$input['label'].'
'; $more.=$input['value']; - $more.='
'; + $more.='
'; $more.=$input['value']; - $more.='
'."\n"; + $more.='
'."\n"; } // JQUI method dialog is broken with jmobile, we use standard HTML. @@ -5326,13 +5344,14 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. - * @param datetime $adddateof Add a link "Date of invoice" using the following date. - * @param string $openinghours Specify hour strat and hour end for the select ex 8,20 + * @param datetime $adddateof Add a link "Date of invoice" using the following date. See also $labeladddateof for the label used. + * @param string $openinghours Specify hour start and hour end for the select ex 8,20 * @param int $stepminutes Specify step for minutes between 1 and 30 + * @param string $labeladddateof Label to use for the $adddateof parameter. * @return string Html for selectDate * @see form_date(), select_month(), select_year(), select_dayofweek() */ - public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1) + public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '') { global $conf,$langs; @@ -5448,9 +5467,9 @@ class Form dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', autoclose: true, todayHighlight: true,"; - if (! empty($conf->dol_use_jmobile)) - { - $retstring.=" + if (! empty($conf->dol_use_jmobile)) + { + $retstring.=" beforeShow: function (input, datePicker) { input.disabled = true; }, @@ -5458,16 +5477,16 @@ class Form this.disabled = false; }, "; - } - // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php - if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) - { + } + // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php + if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) + { $retstring.=" showOn: 'button', buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png', buttonImageOnly: true"; - } - $retstring.=" + } + $retstring.=" }) });"; $retstring.=""; } @@ -5719,7 +5738,8 @@ class Form if ($conf->use_javascript_ajax && $adddateof) { $tmparray=dol_getdate($adddateof); - $retstring.=' -

'; - print ' + print ''; + print ''; + print '
'.$langs->trans("NewSizeAfterCropping").': diff --git a/htdocs/core/tools.php b/htdocs/core/tools.php index 4f517603d63..f598bd31d83 100644 --- a/htdocs/core/tools.php +++ b/htdocs/core/tools.php @@ -29,7 +29,7 @@ $langs->loadLangs(array("companies","other")); // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +if ($user->socid > 0) $socid=$user->socid; diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index b59ca8c2b22..d1b1dfe1093 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -47,499 +47,492 @@ print ''; - print load_fiche_titre($langs->trans("AdvTgtTitle")); +print load_fiche_titre($langs->trans("AdvTgtTitle")); - print '
' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; +print '
' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '
' . "\n"; - print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - // Customer name - print '' . "\n"; +// Customer name +print '' . "\n"; - // Code Client - print '' . "\n"; +// Code Client +print '' . "\n"; - // Address Client - print '' . "\n"; +// Address Client +print '' . "\n"; - // Zip Client - print '' . "\n"; +// Zip Client +print '' . "\n"; - // City Client - print '' . "\n"; +// City Client +print '' . "\n"; - // Customer Country - print '' . "\n"; +// Customer Country +print '' . "\n"; - // State Customer - print '' . "\n"; +// State Customer +print '' . "\n"; - // Mother Company - print '' . "\n"; +// Mother Company +print '' . "\n"; - // Prospect/Customer - $selected = $array_query['cust_typecust']; - print '' . "\n"; +// Prospect/Customer +$selected = $array_query['cust_typecust']; +print '' . "\n"; - // Prospection status - print '' . "\n"; +// Prospection status +print '' . "\n"; - // Prospection comm status - print '' . "\n"; +// Prospection comm status +print '' . "\n"; - // Customer Type - print '' . "\n"; +// Customer Type +print '' . "\n"; - // Staff number - print '' . "\n"; +// Staff number +print '' . "\n"; - // Sales manager - print '' . "\n"; +// Sales manager +print '' . "\n"; - // Customer Default Langauge - if (! empty($conf->global->MAIN_MULTILANGS)) { - print '' . "\n"; +} + +if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; +} + +// Standard Extrafield feature +if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementtype = Societe::$table_element; + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype); + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { + if ($key != 'ts_nameextra' && $key != 'ts_payeur') { + print '' . "\n"; - } + print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementtype = Societe::$table_element; - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype); - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { - if ($key != 'ts_nameextra' && $key != 'ts_payeur') { - print '' . "\n"; - } - } - } else { - $std_soc = new Societe($db); - $action_search = 'query'; - - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - $hookmanager->initHooks(array ('thirdpartycard')); - - $parameters=array(); - if (! empty($advTarget->id)) { - $parameters = array('array_query' => $advTarget->filtervalue); - } - // Other attributes - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); - print $hookmanager->resPrint; - } - - // State Contact - print '' . "\n"; - - // Civility - print ''; - - // contact name - print '' . "\n"; - print '' . "\n"; - - // Contact Country - print '' . "\n"; - - // Never send mass mailing - print '' . "\n"; - - // Contact Date Create - print '' . "\n"; - - // Contact update Create - print '' . "\n"; - - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementype=Contact::$table_element; - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementype); - foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) { - if($value == 'radio')$value = 'select'; - } - - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) - { - print '' . "\n"; } + } +} else { + $std_soc = new Societe($db); + $action_search = 'query'; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '
' . "\n"; +print '
' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '
' . $langs->trans('AdvTgtNameTemplate') . ''; - if (! empty($template_id)) { - $default_template = $template_id; - } else { - $default_template = $advTarget->id; - } - print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element); - print ''; - print ''; - print ''; - print $langs->trans('AdvTgtOrCreateNewFilter'); - print ''; - print ''; - print '' . "\n"; - print '
' . $langs->trans('AdvTgtNameTemplate') . ''; +if (! empty($template_id)) { + $default_template = $template_id; +} else { + $default_template = $advTarget->id; +} +print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element); +print ''; +print ''; +print ''; +print $langs->trans('AdvTgtOrCreateNewFilter'); +print ''; +print ''; +print '' . "\n"; +print '
' . $langs->trans('AdvTgtTypeOfIncude') . ''; - print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); - print '
' . $langs->trans('AdvTgtTypeOfIncude') . ''; +print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); +print '
' . $langs->trans('ThirdPartyName'); - if (! empty($array_query['cust_name'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('ThirdPartyName'); +if (! empty($array_query['cust_name'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans('CustomerCode'); - if (! empty($array_query['cust_code'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('CustomerCode'); +if (! empty($array_query['cust_code'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans('Address'); - if (! empty($array_query['cust_adress'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Address'); +if (! empty($array_query['cust_adress'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans('Zip'); - if (! empty($array_query['cust_zip'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Zip'); +if (! empty($array_query['cust_zip'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans('Town'); - if (! empty($array_query['cust_city'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Town'); +if (! empty($array_query['cust_city'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans("Country"); - if (count($array_query['cust_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); - print '' . "\n"; - print '
' . $langs->trans("Country"); +if (count($array_query['cust_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); +print '' . "\n"; +print '
' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray( - 'cust_status', array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), - $array_query['cust_status'] - ); - print '' . "\n"; - print '
' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); +if (count($array_query['cust_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray( + 'cust_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), + $array_query['cust_status'] +); +print '' . "\n"; +print '
' . $langs->trans("Maison mère"); - if (! empty($array_query['cust_mothercompany'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans("Maison mère"); +if (! empty($array_query['cust_mothercompany'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_typecust']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - $options_array = array ( - 2 => $langs->trans('Prospect'), - 3 => $langs->trans('ProspectCustomer'), - 1 => $langs->trans('Customer'), - 0 => $langs->trans('NorProspectNorCustomer') - ); - print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); - print '' . "\n"; - print '
' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); +if (count($array_query['cust_typecust']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +$options_array = array ( + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer'), + 1 => $langs->trans('Customer'), + 0 => $langs->trans('NorProspectNorCustomer') +); +print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); +print '' . "\n"; +print '
' . $langs->trans('ProspectLevel'); - if (count($array_query['cust_prospect_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); - print '' . "\n"; - print '
' . $langs->trans('ProspectLevel'); +if (count($array_query['cust_prospect_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); +print '' . "\n"; +print '
' . $langs->trans('StatusProsp'); - if (count($array_query['cust_comm_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); - print '' . "\n"; - print '
' . $langs->trans('StatusProsp'); +if (count($array_query['cust_comm_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); +print '' . "\n"; +print '
' . $langs->trans("ThirdPartyType"); - if (count($array_query['cust_typeent']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); - print '' . "\n"; - print '
' . $langs->trans("ThirdPartyType"); +if (count($array_query['cust_typeent']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); +print '' . "\n"; +print '
' . $langs->trans("Staff"); - if (count($array_query['cust_effectif_id']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); - print '' . "\n"; - print '
' . $langs->trans("Staff"); +if (count($array_query['cust_effectif_id']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); +print '' . "\n"; +print '
' . $langs->trans("SalesRepresentatives"); - if (count($array_query['cust_saleman']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); - print '' . "\n"; - print '
' . $langs->trans("SalesRepresentatives"); +if (count($array_query['cust_saleman']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); +print '' . "\n"; +print '
' . $langs->trans("DefaultLang"); - if (count($array_query['cust_language']) > 0) { +// Customer Default Langauge +if (! empty($conf->global->MAIN_MULTILANGS)) { + print '
' . $langs->trans("DefaultLang"); + if (count($array_query['cust_language']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); + print '' . "\n"; + print '
' . $langs->trans("CustomersCategoryShort"); + if (count($array_query['cust_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); + print '' . "\n"; + print '
' . $extrafields->attributes[$elementtype]['label'][$key]; + if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); - print '' . "\n"; - print '
'; + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->selectDate('', 'options_' . $key . '_st_dt'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->selectDate('', 'options_' . $key . '_end_dt'); + print '
'; - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '
' . $langs->trans("CustomersCategoryShort"); - if (count($array_query['cust_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); - print '' . "\n"; - print '
' . $extrafields->attributes[$elementtype]['label'][$key]; - if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate('', 'options_' . $key . '_st_dt'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate('', 'options_' . $key . '_end_dt'); - print '
'; - - print '
' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { - print $form->selectarray( - 'options_' . $key, - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['options_' . $key] - ); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } else { - print ''; - print '
'; - if (is_array($array_query['options_' . $key])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key]); - } - print '
'; - - print '
' . "\n"; - } - print '
' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); - if (count($array_query['contact_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray( - 'contact_status', - array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), - $array_query['contact_status'] - ); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); - print '
' . $langs->trans("UserTitle"); - if (count($array_query['contact_civility']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); - if (! empty($array_query['contact_lastname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); - if (! empty($array_query['contact_firstname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); - if (count($array_query['contact_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); - print '' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); - if (! empty($array_query['contact_no_email'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->selectarray( - 'contact_no_email', - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['contact_no_email'] - ); - print '' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); - if (! empty($array_query['contact_create_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
'; - print '
' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); - if (! empty($array_query['contact_update_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
'; - print '
' . "\n"; - print '
' . $langs->trans("ContactCategoriesShort"); - if (count($array_query['contact_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); - print '' . "\n"; - print '
' . $extrafields->attributes[$elementtype]['label'][$key]; - if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct'); - print '
'; - - print '
' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { - print $form->selectarray( - 'options_' . $key . '_cnct', - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['options_' . $key . '_cnct'] - ); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { + print $form->selectarray( + 'options_' . $key, + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['options_' . $key] + ); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } else { + print ''; + print '' . "\n"; + print '
'; + if (is_array($array_query['options_' . $key])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); } else { - print ''; - print '
'; - if (is_array($array_query['options_' . $key . '_cnct'])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); - } - print '
'; - - print '
' . "\n"; + print $extrafields->showInputField($key, $array_query['options_' . $key]); } - print '
'; + + print '
' . "\n"; } + print '
' . "\n"; + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + $hookmanager->initHooks(array ('thirdpartycard')); - print '' . "\n"; + $parameters=array(); + if (! empty($advTarget->id)) { + $parameters = array('array_query' => $advTarget->filtervalue); + } + // Other attributes + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); + print $hookmanager->resPrint; +} - print '
' . "\n"; - print '' . "\n"; - print '
' . "\n"; +// State Contact +print '' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); +if (count($array_query['contact_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray( + 'contact_status', + array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), + $array_query['contact_status'] +); +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); +print '' . "\n"; - print '
'; - print ''; - print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere")); - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'; - print '
'; +// Civility +print '' . $langs->trans("UserTitle"); +if (count($array_query['contact_civility']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); +print ''; + +// contact name +print '' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); +if (! empty($array_query['contact_lastname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '' . "\n"; +print '' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); +if (! empty($array_query['contact_firstname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '' . "\n"; + +// Contact Country +print '' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); +if (count($array_query['contact_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); +print '' . "\n"; +print '' . "\n"; + +// Never send mass mailing +print '' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); +if (! empty($array_query['contact_no_email'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->selectarray( + 'contact_no_email', + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['contact_no_email'] +); +print '' . "\n"; +print '' . "\n"; + +// Contact Date Create +print '' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); +if (! empty($array_query['contact_create_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '
' . $langs->trans("AdvTgtStartDt") . ''; +print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); +print '' . $langs->trans("AdvTgtEndDt") . ''; +print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); +print '
'; +print '' . "\n"; +print '' . "\n"; + +// Contact update Create +print '' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); +if (! empty($array_query['contact_update_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '
' . $langs->trans("AdvTgtStartDt") . ''; +print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); +print '' . $langs->trans("AdvTgtEndDt") . ''; +print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); +print '
'; +print '' . "\n"; +print '' . "\n"; + +if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . $langs->trans("ContactCategoriesShort"); + if (count($array_query['contact_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); + print '' . "\n"; + print '' . "\n"; +} + +// Standard Extrafield feature +if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementype=Contact::$table_element; + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementype); + foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) { + if($value == 'radio')$value = 'select'; + } + + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { + print '' . $extrafields->attributes[$elementtype]['label'][$key]; + if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct'); + print '
'; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { + print $form->selectarray( + 'options_' . $key . '_cnct', + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['options_' . $key . '_cnct'] + ); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } else { + print ''; + print '
'; + if (is_array($array_query['options_' . $key . '_cnct'])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); + } + print '
'; + print '' . "\n"; + } + print '' . "\n"; + } +} +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '
' . "\n"; +print '
'; +print ''; +print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere")); +print ''; +print ''; +print ''; +print ''; +print '
'; +print '
'; +print '
'; diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php index fba0810e7cd..d7b5e5d7532 100644 --- a/htdocs/core/tpl/bloc_comment.tpl.php +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -36,21 +36,25 @@ print ''; print ''; print "\n"; -print ''; +if ($action !== 'editcomment') +{ + print ''; -// Description -print ''; + // Description + print ''; -$desc = GETPOST('comment_description'); + $desc = GETPOST('comment_description'); -$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); -print $doleditor->Create(1); + $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); + print $doleditor->Create(1); -print ''; + print ''; + + print ''; + print ''; + print ''; +} -print ''; -print ''; -print ''; print ''; // List of comments @@ -91,15 +95,52 @@ if (!empty($object->comments)) print '
'; print '
'; - print '
'; - print $comment->description; + + if ($action === 'editcomment' && $comment->id == $idcomment) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print '
'; + if ($action === 'editcomment' && $comment->id == $idcomment) + { + $doleditor = new DolEditor('comment_description', $comment->description, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); + print $doleditor->Create(1); + } + else + { + print $comment->description; + } print '
'; // End comment-description - if(($first && $fk_user == $user->id) || $user->admin == 1) { - print ''; - print img_picto('', 'delete.png'); - print ''; - } - print '
'; // End comment-table + + if ($action === 'editcomment' && $comment->id == $idcomment) + { + print ''; + print ''; + + print ''; + } + else + { + if ($fk_user == $user->id || $user->admin == 1) + { + print ''; + print img_picto('', 'edit.png'); + print ''; + } + if(($first && $fk_user == $user->id) || $user->admin == 1) { + print ''; + print img_picto('', 'delete.png'); + print ''; + } + } + + print '
'; // End comment-table print '
'; // End comment-right print '
'; // End comment diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index ca2cd9e1fd7..821881314d3 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -67,7 +67,7 @@ $userstatic=new User($db); + ?>
trans("NatureOfContact"); ?>
trans("ThirdParty"); ?>
@@ -81,13 +81,13 @@ if ($permission) { if (empty($hideaddcontactforuser)) { - ?> + ?> " /> - '; ?> + '; ?>
trans("Users"); ?>
global->MAIN_INFO_SOCIETE_NOM; ?>
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
@@ -101,19 +101,19 @@ if ($permission) {
">
- + ?>
" /> - '; ?> + '; ?>
trans("ThirdPartyContacts"); ?>
socid; ?> @@ -141,7 +141,7 @@ if ($permission) {
- @@ -155,21 +155,21 @@ if ($permission) {
 
- element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; +$arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts +foreach($arrayofsource as $source) { + $tmpobject=$object; + if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; - $tab = $tmpobject->liste_contact(-1, $source); - $num=count($tab); + $tab = $tmpobject->liste_contact(-1, $source); + $num=count($tab); - $i = 0; - while ($i < $num) { - $var = ! $var; - ?> + $i = 0; + while ($i < $num) { + $var = ! $var; + ?>
@@ -177,75 +177,68 @@ if ($permission) { trans("ThirdPartyContact"); ?>
- 0) - { - $companystatic->fetch($tab[$i]['socid']); - echo $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - echo $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - echo ' '; - } - ?> + 0) + { + $companystatic->fetch($tab[$i]['socid']); + echo $companystatic->getNomUrl(1); + } + if ($tab[$i]['socid'] < 0) + { + echo $conf->global->MAIN_INFO_SOCIETE_NOM; + } + if (! $tab[$i]['socid']) + { + echo ' '; + } + ?>
- fetch($tab[$i]['id']); - echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->fetch($tab[$i]['id']); - echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); - } - ?> + if ($tab[$i]['source']=='internal') + { + $userstatic->fetch($tab[$i]['id']); + echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); + } + if ($tab[$i]['source']=='external') + { + $contactstatic->fetch($tab[$i]['id']); + echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); + } + ?>
- - +} -
-
- -initHooks(array('contacttpl')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); - } -?> - +print "
\n"; +print "
\n"; +print "\n"; +if (is_object($hookmanager)) { + $hookmanager->initHooks(array('contacttpl')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); +} +print "\n"; diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index e8b1e396f1a..c6d3776cfe4 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -23,8 +23,15 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $align=$extrafields->getAlignFlag($key); $sortonfield = $extrafieldsobjectprefix.$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; - if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print ''; - else print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; + if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') { + print ''; + } + else + { + $tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key]; + + print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', 0, $tooltip)."\n"; + } } } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 6f52cbcab7a..f19cfff136e 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -85,6 +85,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] else { $value = $object->array_options["options_" . $key]; + //var_dump($key.' - '.$value); } if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { @@ -178,7 +179,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } else { - //print $key.'-'.$value.'-'.$object->table_element; + //var_dump($key.'-'.$value.'-'.$object->table_element); print $extrafields->showOutputField($key, $value, '', $object->table_element); } diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 2a0fe46dfdd..ba0c550debc 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -63,19 +63,17 @@ if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_ $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' -?> - +print "\n"; -global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { // For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random' -?> + ?> - + ?> global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> - @@ -179,7 +177,7 @@ if ($captcha) { if (preg_match('/\?/', $php_self)) $php_self.='&time='.dol_print_date(dol_now(), 'dayhourlog'); else $php_self.='?time='.dol_print_date(dol_now(), 'dayhourlog'); // TODO: provide accessible captcha variants -?> + ?>
@@ -279,11 +277,11 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil // Show error message if defined if (! empty($_SESSION['dol_loginmesg'])) { -?> + ?> -global->MAIN_EASTER_EGG_COMMITSTRIP)) { + ?>
- @@ -362,7 +360,7 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLI { if (empty($conf->dol_use_jmobile)) { -?> + ?>

-
-
+
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 14c65c9cbf1..c2be08aa5da 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -86,7 +86,7 @@ if ($module != 'product') { print '
'."\n"; print '
'."\n"; } -if (empty($user->societe_id)) { +if (empty($user->socid)) { print '
'."\n"; print '
'."\n"; print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b0d4596a711..73d86fa56a5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -90,13 +90,11 @@ if (!empty($extrafields)) } } -?> - -\n"; $nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { -?> + ?> global->MAIN_VIEW_LINE_NUMBER)) { ?> @@ -107,9 +105,9 @@ if ($nolinesbefore) { element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { - ?> + ?> trans('SupplierRef'); ?> - trans('VAT'); ?> @@ -138,129 +136,127 @@ if ($nolinesbefore) { print ''; } if (! empty($usemargins)) - { - if (!empty($user->rights->margins->creer)) { - ?> - - rights->margins->creer)) { + $colspan++; + } + else { + print ''; + if ($conf->global->MARGIN_TYPE == "1") + echo $langs->trans('BuyingPrice'); + else + echo $langs->trans('CostPrice'); + echo ''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; } - else $colspan++; - - if ($conf->global->MARGIN_TYPE == "1") - echo $langs->trans('BuyingPrice'); - else - echo $langs->trans('CostPrice'); - echo ''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; } ?>   - global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay++; - echo ''; - } +$coldisplay=0; +// Adds a line numbering column +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; - ?> + echo ''; +} + +$coldisplay++; +?> - global->MAIN_DISABLE_FREE_LINES)) +$freelines = false; +if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) +{ + $freelines = true; + $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) + if ($object->element == 'contrat') { - $freelines = true; - $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) - if ($object->element == 'contrat') - { - if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set - elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; - } - - // Free line - echo ''; - // Show radio free line - if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - echo ''; - echo ' '; - } - else - { - echo ''; - // Show type selector - if ($forceall >= 0) - { - if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); - else echo $langs->trans("FreeLineOfType"); - echo ' '; - } - } - - echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall); - - echo ''; + if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set + elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; } - // Predefined product/service - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + // Free line + echo ''; + // Show radio free line + if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) { - if ($forceall >= 0 && $freelines) echo '
'; - echo ''; - echo ''; +} + +// Predefined product/service +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +{ + if ($forceall >= 0 && $freelines) echo '
'; + echo ''; + echo ''; + echo ' '; + + $filtertype=''; + if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + + if (empty($senderissupplier)) + { + $statustoshow = 1; + if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + { + // hide products in closed warehouse, but show products for internal transfer + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); } else { - if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase'); - elseif (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase'); - else echo $langs->trans('PredefinedProductsAndServicesToPurchase'); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } - echo ''; - echo ' '; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; - - if (empty($senderissupplier)) + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { - $statustoshow = 1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) - { - // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); - } - else - { - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); - } - - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) - { - ?> + ?> - array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key - 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done - 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) - ); - $alsoproductwithnosupplierprice=0; - } - else - { - $ajaxoptions = array( - 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key - ); - $alsoproductwithnosupplierprice=1; - } + array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key + 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done + 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) + ); + $alsoproductwithnosupplierprice=0; + } + else + { + $ajaxoptions = array( + 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key + ); + $alsoproductwithnosupplierprice=1; + } - $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); + $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) - { - ?> + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> - '; - echo ''; + '; + echo '
'; +} + +if (is_object($hookmanager) && empty($senderissupplier)) +{ + $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); + $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } +} +if (is_object($hookmanager) && ! empty($senderissupplier)) +{ + $parameters=array('htmlname'=>'addproduct'); + $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } +} + + +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + if (!empty($conf->variants->enabled)) { + echo '
'; } - if (is_object($hookmanager) && empty($senderissupplier)) - { - $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } - } - if (is_object($hookmanager) && ! empty($senderissupplier)) - { - $parameters=array('htmlname'=>'addproduct'); - $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } - } + echo '
'; +} +// Editor wysiwyg +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +$nbrows=ROWS_2; +$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); +if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; +$toolbarname='dolibarr_details'; +if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; +$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); +$doleditor->Create(); - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - if (!empty($conf->variants->enabled)) { - echo '
'; - } +// Show autofill date for recurring invoices +if (! empty($conf->service->enabled) && $object->element == 'facturerec') +{ + echo '

'; + echo $langs->trans('AutoFillDateFrom').' '; + echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); + echo ' - '; + echo $langs->trans('AutoFillDateTo').' '; + echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); + echo '
'; +} +echo ''; - echo '
'; - } - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $toolbarname='dolibarr_details'; - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; - $doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); - $doleditor->Create(); - - // Show autofill date for recurring invoices - if (! empty($conf->service->enabled) && $object->element == 'facturerec') - { - echo '

'; - echo $langs->trans('AutoFillDateFrom').' '; - echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); - echo ' - '; - echo $langs->trans('AutoFillDateTo').' '; - echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); - echo '
'; - } - echo ''; - - if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines - { - $coldisplay++; - ?> - "> - - - element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines +{ $coldisplay++; - if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); - ?> + ?> + "> +'; +$coldisplay++; +if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); +else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); +?> "> - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { - $coldisplay++; +multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + $coldisplay++; ?> "> - + "> - +$coldisplay++; +?> "> - global->PRODUCT_USE_UNITS) - { - $coldisplay++; - print ''; - print $form->selectUnits($line->fk_unit, "units"); - print ''; - } - $remise_percent = $buyer->remise_percent; - if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') - { - $remise_percent = $seller->remise_supplier_percent; - } +global->PRODUCT_USE_UNITS) +{ + $coldisplay++; + print ''; + print $form->selectUnits($line->fk_unit, "units"); + print ''; +} +$remise_percent = $buyer->remise_percent; +if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') +{ + $remise_percent = $seller->remise_supplier_percent; +} - $coldisplay++; - ?> +$coldisplay++; +?> ">% - situation_cycle_ref) { - $coldisplay++; - print '%'; - $coldisplay++; - print ''; - } +if ($this->situation_cycle_ref) { + $coldisplay++; + print '%'; + $coldisplay++; + print ''; +} - if (! empty($usemargins)) - { - if (!empty($user->rights->margins->creer)) { - $coldisplay++; +if (! empty($usemargins)) +{ + if (!empty($user->rights->margins->creer)) { + $coldisplay++; ?> - - - product->enabled) || ! empty($conf->service->enabled)) { ?> - - - - "> - + + + product->enabled) || ! empty($conf->service->enabled)) { ?> + + + + "> + rights->margins->creer) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - { - echo '%'; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) - { - echo '%'; - $coldisplay++; - } + echo '%'; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo '%'; + $coldisplay++; } } +} - $coldisplay+=$colspan; - ?> +$coldisplay+=$colspan; +?> @@ -518,37 +510,33 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; } } - print '' - ?> - - -'; + print ''; + print "\n"; } -?> -'; - print '
'; - print ''; - // Load shipments already done for same order $object->loadExpeditions(); @@ -1371,7 +1366,7 @@ if ($action == 'create') print ''; print ''; } } @@ -1553,7 +1548,7 @@ if ($action == 'create') { $warehouseObject=new Entrepot($db); $warehouseObject->fetch($warehouse_selected_id); - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->label); } else { @@ -1575,11 +1570,9 @@ if ($action == 'create') { //var_dump($line); $colspan=5; - $extrafields->fetch_name_optionals_label($expe->table_element_line); $expLine = new ExpeditionLigne($db); $srcLine = new OrderLine($db); - $extrafields->fetch_name_optionals_label($srcLine->table_element); $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline //$line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); @@ -1707,7 +1700,6 @@ elseif ($id || $ref) // Print form confirm print $formconfirm; - // Calculate totalWeight and totalVolume for all products // by adding weight and volume of each product line. $tmparray=$object->getTotalWeightVolume(); @@ -1850,16 +1842,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string(0, "weight", $object->weight_units):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0, "weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print ''; @@ -1867,7 +1857,7 @@ elseif ($id || $ref) // Width print ''; // Height @@ -1887,7 +1877,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string(0, "size", $object->height_units):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print ''; @@ -1895,7 +1885,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1915,15 +1905,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0, "volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -2199,6 +2187,20 @@ elseif ($id || $ref) $product_static->id=$lines[$i]->fk_product; $product_static->ref=$lines[$i]->ref; $product_static->status_batch=$lines[$i]->product_tobatch; + + $product_static->weight=$lines[$i]->weight; + $product_static->weight_units=$lines[$i]->weight_units; + $product_static->length=$lines[$i]->length; + $product_static->length_units=$lines[$i]->length_units; + $product_static->width=$lines[$i]->width; + $product_static->width_units=$lines[$i]->width_units; + $product_static->height=$lines[$i]->height; + $product_static->height_units=$lines[$i]->height_units; + $product_static->surface=$lines[$i]->surface; + $product_static->surface_units=$lines[$i]->surface_units; + $product_static->volume=$lines[$i]->volume; + $product_static->volume_units=$lines[$i]->volume_units; + $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); @@ -2252,7 +2254,7 @@ elseif ($id || $ref) if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); + $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } print ' '.$form->textwithpicto('', $htmltext, 1); } @@ -2409,18 +2411,18 @@ elseif ($id || $ref) // Weight print ''; // Volume print ''; // Size - //print ''; + //print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { @@ -2433,10 +2435,10 @@ elseif ($id || $ref) { // edit-delete buttons print ''; print ''; // Display lines extrafields @@ -2458,8 +2460,6 @@ elseif ($id || $ref) $lines[$i]->fetch_optionals($lines[$i]->id); - $extrafields->fetch_name_optionals_label($lines[$i]->table_element); - print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { @@ -2492,7 +2492,7 @@ elseif ($id || $ref) * Boutons actions */ - if (($user->societe_id == 0) && ($action!='presend')) + if (($user->socid == 0) && ($action!='presend')) { print '
'; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 16b08a8c183..2e61ad47733 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -143,7 +143,12 @@ class Expedition extends CommonObject */ public $date_shipping; + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_valid; public $meths; @@ -324,8 +329,8 @@ class Expedition extends CommonObject $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".($this->weight_units>0?$this->weight_units:'NULL'); - $sql.= ", ".($this->size_units>0?$this->size_units:'NULL'); + $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); + $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); @@ -1668,44 +1673,44 @@ class Expedition extends CommonObject /** * Return label of a status * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable global $langs; if ($mode==0) { - if ($statut==0) return $langs->trans($this->statuts[$statut]); - elseif ($statut==1) return $langs->trans($this->statuts[$statut]); - elseif ($statut==2) return $langs->trans($this->statuts[$statut]); + if ($status==0) return $langs->trans($this->statuts[$status]); + elseif ($status==1) return $langs->trans($this->statuts[$status]); + elseif ($status==2) return $langs->trans($this->statuts[$status]); } elseif ($mode==1) { - if ($statut==0) return $langs->trans($this->statutshorts[$statut]); - elseif ($statut==1) return $langs->trans($this->statutshorts[$statut]); - elseif ($statut==2) return $langs->trans($this->statutshorts[$statut]); + if ($status==0) return $langs->trans($this->statutshorts[$status]); + elseif ($status==1) return $langs->trans($this->statutshorts[$status]); + elseif ($status==2) return $langs->trans($this->statutshorts[$status]); } elseif ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut6'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($statut==0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + if ($status==0) return $langs->trans($this->statutshorts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return $langs->trans($this->statutshorts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return $langs->trans($this->statutshorts[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut6'); } } @@ -1777,7 +1782,8 @@ class Expedition extends CommonObject { $line=new ExpeditionLigne($this->db); $line->desc=$langs->trans("Description")." ".$xnbp; - $line->libelle=$langs->trans("Description")." ".$xnbp; + $line->libelle=$langs->trans("Description")." ".$xnbp; // deprecated + $line->label=$langs->trans("Description")." ".$xnbp; $line->qty=10; $line->qty_asked=5; $line->qty_shipped=4; @@ -1836,7 +1842,7 @@ class Expedition extends CommonObject global $langs; $this->meths = array(); - $sql = "SELECT em.rowid, em.code, em.libelle"; + $sql = "SELECT em.rowid, em.code, em.libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; $sql.= " WHERE em.active = 1"; $sql.= " ORDER BY em.libelle ASC"; @@ -1847,7 +1853,7 @@ class Expedition extends CommonObject while ($obj = $this->db->fetch_object($resql)) { $label=$langs->trans('SendingMethod'.$obj->code); - $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle); + $this->meths[$obj->rowid] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); } } } @@ -1867,7 +1873,7 @@ class Expedition extends CommonObject $this->listmeths = array(); $i=0; - $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; + $sql = "SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; if ($id!='') $sql.= " WHERE em.rowid=".$id; @@ -1879,7 +1885,7 @@ class Expedition extends CommonObject $this->listmeths[$i]['rowid'] = $obj->rowid; $this->listmeths[$i]['code'] = $obj->code; $label=$langs->trans('SendingMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle); + $this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->label); $this->listmeths[$i]['description'] = $obj->description; $this->listmeths[$i]['tracking'] = $obj->tracking; $this->listmeths[$i]['active'] = $obj->active; diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index b8e6af1db85..1cd050cb89e 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -42,7 +42,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expedition', $id, ''); $object = new Expedition($db); diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index 9faaaf1f88e..0018ba3cd06 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -46,9 +46,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref'); // Security check -if ($user->societe_id) +if ($user->socid) { - $socid = $user->societe_id; + $socid = $user->socid; } $result=restrictedArea($user, 'expedition', $id, ''); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 217497a962e..918266eab90 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -57,11 +57,12 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print '
'; - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->label); print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string(0, "size", $object->width_units):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string(0, "size", $object->depth_units):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "weight", $lines[$i]->weight_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "volume", $lines[$i]->volume_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); else print ' '; print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume").''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; - print 'id . '">' . img_edit() . ''; + print 'id . '">' . img_edit() . ''; print ''; - print 'id . '">' . img_delete() . ''; + print 'id . '">' . img_delete() . ''; print '
'; print ''; print ''; - print "
'.$langs->trans("Search").'
'; print $langs->trans("Shipment").':

\n"; + print "

\n"; } /* @@ -92,6 +93,7 @@ if ($resql) $num = $db->num_rows($resql); if ($num) { + print '
'; print ''; print ''; print ''; @@ -115,7 +117,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("SendingsToValidate").'

"; + print "

"; } } @@ -143,6 +145,7 @@ if ($resql) $langs->load("orders"); $i = 0; + print '
'; print ''; print ''; print ''; @@ -172,7 +175,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("OrdersToProcess").'

"; + print "

"; } } @@ -203,6 +206,7 @@ if ( $resql ) if ($num) { $i = 0; + print '
'; print ''; print ''; print ''; @@ -231,7 +235,7 @@ if ( $resql ) print ''; $i++; } - print "
'.$langs->trans("OrdersInProcess").'

"; + print "

"; } } else dol_print_error($db); @@ -262,6 +266,7 @@ if ($resql) if ($num) { $i = 0; + print '
'; print ''; print ''; print ''; @@ -288,7 +293,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("LastSendings", $num).'

"; + print "

"; } $db->free($resql); } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 1840569fd0e..888f7037efb 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -46,7 +46,7 @@ $toselect = GETPOST('toselect', 'array'); // Security check $expeditionid = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expedition', $expeditionid, ''); $search_ref_exp = GETPOST("search_ref_exp", 'alpha'); diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 25ccf938963..1ae26471eb8 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -41,7 +41,7 @@ $action=GETPOST('action', 'alpha'); // Security check $socid=''; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, $origin, $origin_id); $object = new Expedition($db); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 34a89233f1e..2bc1e9a23ef 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -42,7 +42,7 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propa if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); +$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm','other')); $id = GETPOST('id', 'int'); // id of order $ref = GETPOST('ref', 'alpha'); @@ -53,7 +53,7 @@ $hookmanager->initHooks(array('ordershipmentcard')); // Security check $socid=0; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'commande', $id); $object = new Commande($db); @@ -288,19 +288,20 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -618,7 +619,9 @@ if ($id > 0 || ! empty($ref)) $sql.= ' cd.date_start,'; $sql.= ' cd.date_end,'; $sql.= ' cd.special_code,'; - $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; + $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc,'; + $sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,'; + $sql.= ' p.surface, p.surface_units, p.volume, p.volume_units'; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " WHERE cd.fk_commande = ".$object->id; @@ -705,6 +708,20 @@ if ($id > 0 || ! empty($ref)) $product_static->id=$objp->fk_product; $product_static->ref=$objp->ref; $product_static->entity = $objp->entity; + + $product_static->weight=$objp->weight; + $product_static->weight_units=$objp->weight_units; + $product_static->length=$objp->length; + $product_static->length_units=$objp->length_units; + $product_static->width=$objp->width; + $product_static->width_units=$objp->width_units; + $product_static->height=$objp->height; + $product_static->height_units=$objp->height_units; + $product_static->surface=$objp->surface; + $product_static->surface_units=$objp->surface_units; + $product_static->volume=$objp->volume; + $product_static->volume_units=$objp->volume_units; + $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; @@ -839,7 +856,7 @@ if ($id > 0 || ! empty($ref)) * Boutons Actions */ - if (empty($user->societe_id)) + if (empty($user->socid)) { print '
'; diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index b6c3f7355a9..b2aea807b5f 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -34,10 +34,10 @@ $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -71,7 +71,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png'; } @@ -111,7 +111,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png'; } @@ -149,7 +149,7 @@ if (! $mesg) /* $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png'; } diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index a632584a510..8e27db03b45 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -23,11 +23,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("sendings"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Shipment"); ?> getNomUrl(1); ?> date_delivery, 'day'); ?> rights->expedition->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->expedition->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> $objectlink) } ?> - 1) { ?> @@ -81,6 +80,5 @@ if (count($linkedObjectBlock) > 1) { - +print "\n"; diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php index e3872577473..77b6968a38a 100644 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ b/htdocs/expensereport/ajax/ajaxprojet.php @@ -69,8 +69,8 @@ if (GETPOST('fk_projet') != '') { $label=$row['ref'].' - '.$row['title']; $row_array['label'] = $label; - $row_array['value'] = $label; - $row_array['key'] = $row['rowid']; + $row_array['value'] = $label; + $row_array['key'] = $row['rowid']; array_push($return_arr, $row_array); } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 95b9e0cd1f5..ecf1803cb50 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -57,7 +57,7 @@ $confirm = GETPOST('confirm', 'alpha'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); -$fk_projet=GETPOST('fk_projet', 'int'); +$fk_project=GETPOST('fk_project', 'int'); $vatrate=GETPOST('vatrate', 'alpha'); $ref=GETPOST("ref", 'alpha'); $comments=GETPOST('comments', 'none'); @@ -68,7 +68,7 @@ $childids = $user->getAllChildIds(1); // Security check $id=GETPOST("id", 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); @@ -145,7 +145,7 @@ if (empty($reshook)) } $action=''; - $fk_projet=''; + $fk_project=''; $date_start=''; $date_end=''; $date=''; @@ -1232,7 +1232,7 @@ if (empty($reshook)) $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees // Insert line - $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_projet, $fk_c_exp_tax_cat, $type, $fk_ecm_files); + $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -1257,7 +1257,7 @@ if (empty($reshook)) unset($vatrate); unset($comments); unset($fk_c_type_fees); - unset($fk_projet); + unset($fk_project); unset($date); } else { @@ -1334,7 +1334,7 @@ if (empty($reshook)) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); - $projet_id = $fk_projet; + $projet_id = $fk_project; $comments = GETPOST('comments', 'none'); $qty = GETPOST('qty', 'int'); $vatrate = GETPOST('vatrate', 'alpha'); @@ -1506,7 +1506,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("ModePaiement").''; print ''; - $form->select_types_paiements(2, 'fk_c_paiement'); + $form->select_types_paiements('', 'fk_c_paiement'); print ''; print ''; } @@ -1521,7 +1521,7 @@ if ($action == 'create') print ''; // Private note - if (empty($user->societe_id)) { + if (empty($user->socid)) { print ''; print '' . $langs->trans('NotePrivate') . ''; print ''; @@ -1832,7 +1832,7 @@ else { print ''; print ''.$langs->trans("ModePaiement").''; - print ''.$object->libelle_paiement.''; + print ''.$object->fk_c_paiement.''; print ''; } @@ -2372,7 +2372,7 @@ else if (! empty($conf->projet->enabled)) { print ''; - $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } @@ -2527,7 +2527,7 @@ else if (! empty($conf->projet->enabled)) { print ''; - $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f6f8f2246b9..42011fafaf9 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -46,6 +46,10 @@ class ExpenseReport extends CommonObject public $table_element_line = 'expensereport_det'; public $fk_element = 'fk_expensereport'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'trip'; public $lines=array(); @@ -101,9 +105,6 @@ class ExpenseReport extends CommonObject // Paiement public $user_paid_infos; - /* - END ACTIONS - */ /** * Draft status @@ -136,6 +137,51 @@ class ExpenseReport extends CommonObject const STATUS_CLOSED = 6; + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20), + 'ref_number_int' =>array('type'=>'integer', 'label'=>'Ref number int', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'ref_ext' =>array('type'=>'integer', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'Total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'date_debut' =>array('type'=>'date', 'label'=>'Date debut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>60), + 'date_fin' =>array('type'=>'date', 'label'=>'Date fin', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>65), + 'date_valid' =>array('type'=>'datetime', 'label'=>'Date valid', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'date_approve' =>array('type'=>'datetime', 'label'=>'Date approve', 'enabled'=>1, 'visible'=>-1, 'position'=>80), + 'date_refuse' =>array('type'=>'datetime', 'label'=>'Date refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'date_cancel' =>array('type'=>'datetime', 'label'=>'Date cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>100), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'Fk user modif', 'enabled'=>1, 'visible'=>-1, 'position'=>105), + 'fk_user_valid' =>array('type'=>'integer', 'label'=>'Fk user valid', 'enabled'=>1, 'visible'=>-1, 'position'=>110), + 'fk_user_validator' =>array('type'=>'integer', 'label'=>'Fk user validator', 'enabled'=>1, 'visible'=>-1, 'position'=>115), + 'fk_user_approve' =>array('type'=>'integer', 'label'=>'Fk user approve', 'enabled'=>1, 'visible'=>-1, 'position'=>120), + 'fk_user_refuse' =>array('type'=>'integer', 'label'=>'Fk user refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>125), + 'fk_user_cancel' =>array('type'=>'integer', 'label'=>'Fk user cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>130), + 'fk_c_paiement' =>array('type'=>'integer', 'label'=>'Fk c paiement', 'enabled'=>1, 'visible'=>-1, 'position'=>140), + 'paid' =>array('type'=>'integer', 'label'=>'Paid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>145), + 'note_public' =>array('type'=>'text', 'label'=>'Note public', 'enabled'=>1, 'visible'=>0, 'position'=>150), + 'note_private' =>array('type'=>'text', 'label'=>'Note private', 'enabled'=>1, 'visible'=>0, 'position'=>155), + 'detail_refuse' =>array('type'=>'varchar(255)', 'label'=>'Detail refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>160), + 'detail_cancel' =>array('type'=>'varchar(255)', 'label'=>'Detail cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'integration_compta' =>array('type'=>'integer', 'label'=>'Integration compta', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_bank_account' =>array('type'=>'integer', 'label'=>'Fk bank account', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'model_pdf' =>array('type'=>'varchar(50)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>180), + 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>190), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>195), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>205), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>210), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportKey', 'enabled'=>1, 'visible'=>-1, 'position'=>215), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>220), + 'date_create' =>array('type'=>'datetime', 'label'=>'Date create', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>300), + 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>305), + 'fk_statut' =>array('type'=>'integer', 'label'=>'Fk statut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + ); /** * Constructor @@ -153,7 +199,7 @@ class ExpenseReport extends CommonObject // List of language codes for status $this->statuts_short = array(0 => 'Draft', 2 => 'Validated', 4 => 'Canceled', 5 => 'Approved', 6 => 'Paid', 99 => 'Refused'); $this->statuts = array(0 => 'Draft', 2 => 'ValidatedWaitingApproval', 4 => 'Canceled', 5 => 'Approved', 6 => 'Paid', 99 => 'Refused'); - $this->statuts_logo = array(0 => 'statut0', 2 => 'statut1', 4 => 'statut5', 5 => 'statut3', 6 => 'statut6', 99 => 'statut5'); + $this->statuts_logo = array(0 => 'status0', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); } /** @@ -469,7 +515,7 @@ class ExpenseReport extends CommonObject $sql.= " d.fk_user_author, d.fk_user_modif, d.fk_user_validator,"; $sql.= " d.fk_user_valid, d.fk_user_approve,"; $sql.= " d.fk_statut as status, d.fk_c_paiement, d.paid,"; - $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement + $sql.= " dp.libelle as label_payment, dp.code as code_paiement"; // INNER JOIN paiement $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id"; if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'"; @@ -525,15 +571,13 @@ class ExpenseReport extends CommonObject $this->fk_c_paiement = $obj->fk_c_paiement; $this->paid = $obj->paid; - if ($this->fk_statut==5 || $this->fk_statut==6) + if ($this->fk_statut == self::STATUS_APPROVED || $this->fk_statut == self::STATUS_CLOSED) { $user_valid = new User($this->db); if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid); $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname); } - $this->libelle_statut = $obj->libelle_statut; - $this->libelle_paiement = $obj->libelle_paiement; $this->code_statut = $obj->code_statut; $this->code_paiement = $obj->code_paiement; @@ -638,29 +682,15 @@ class ExpenseReport extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable - global $langs; + // phpcs:enable + global $langs; - if ($mode == 0) - return $langs->transnoentities($this->statuts[$status]); + $labelStatus = $langs->trans($this->statuts[$status]); + $labelStatusShort = $langs->trans($this->statuts_short[$status]); - elseif ($mode == 1) - return $langs->transnoentities($this->statuts_short[$status]); + $statusType = $this->statuts_logo[$status]; - elseif ($mode == 2) - return img_picto($langs->transnoentities($this->statuts_short[$status]), $this->statuts_logo[$status]).' '.$langs->transnoentities($this->statuts_short[$status]); - - elseif ($mode == 3) - return img_picto($langs->transnoentities($this->statuts_short[$status]), $this->statuts_logo[$status]); - - elseif ($mode == 4) - return img_picto($langs->transnoentities($this->statuts_short[$status]), $this->statuts_logo[$status]).' '.$langs->transnoentities($this->statuts[$status]); - - elseif ($mode == 5) - return ''.$langs->transnoentities($this->statuts_short[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]), $this->statuts_logo[$status]); - - elseif ($mode == 6) - return $langs->transnoentities($this->statuts[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]), $this->statuts_logo[$status]); + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } @@ -927,10 +957,10 @@ class ExpenseReport extends CommonObject $num = $this->db->num_rows($result); $i = 0; while ($i < $num): - $objp = $this->db->fetch_object($result); - $total_ht+=$objp->total_ht; - $total_tva+=$objp->total_tva; - $i++; + $objp = $this->db->fetch_object($result); + $total_ht+=$objp->total_ht; + $total_tva+=$objp->total_tva; + $i++; endwhile; $total_ttc = $total_ht + $total_tva; @@ -940,13 +970,13 @@ class ExpenseReport extends CommonObject $sql.= " , total_tva = ".$total_tva; $sql.= " WHERE rowid = ".$id; $result = $this->db->query($sql); - if($result): - $this->db->free($result); - return 1; + if ($result): + $this->db->free($result); + return 1; else: - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR); - return -3; + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR); + return -3; endif; } else @@ -1231,10 +1261,10 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->fk_statut != 2) + if ($this->fk_statut != self::STATUS_VALIDATED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = 2"; + $sql.= " SET fk_statut = ".self::STATUS_VALIDATED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG); @@ -1269,11 +1299,12 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $now; - if ($this->fk_statut != 5) { - $this->db->begin(); + if ($this->fk_statut != self::STATUS_APPROVED) + { + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; $sql.= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) @@ -1330,10 +1361,10 @@ class ExpenseReport extends CommonObject $error = 0; // date de refus - if ($this->fk_statut != 99) + if ($this->fk_statut != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 99, fk_user_refuse = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; $sql.= " date_refuse='".$this->db->idate($now)."',"; $sql.= " detail_refuse='".$this->db->escape($details)."',"; $sql.= " fk_user_approve = NULL"; @@ -1399,7 +1430,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET paid = 0"; + $sql.= " SET paid = 0, fk_statut = ".self::STATUS_APPROVED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); @@ -1456,12 +1487,12 @@ class ExpenseReport extends CommonObject // phpcs:enable $error = 0; $this->date_cancel = $this->db->idate(gmmktime()); - if ($this->fk_statut != ExpenseReport::STATUS_CANCELED) + if ($this->fk_statut != self::STATUS_CANCELED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = ".ExpenseReport::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; + $sql.= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; $sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1650,10 +1681,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -1680,10 +1711,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -2305,7 +2336,7 @@ class ExpenseReport extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $now=dol_now(); @@ -2327,10 +2358,10 @@ class ExpenseReport extends CommonObject $response = new WorkboardResponse(); if ($option == 'toapprove') { - $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24; - $response->label=$langs->trans("ExpenseReportsToApprove"); - $response->labelShort=$langs->trans("ToApprove"); - $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=2'; + $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24; + $response->label=$langs->trans("ExpenseReportsToApprove"); + $response->labelShort=$langs->trans("ToApprove"); + $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=2'; } else { diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 5c72dd18528..156bd329d49 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -25,8 +25,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -/** \class PaymentExpenseReport - * \brief Class to manage payments of expense report +/** + * Class to manage payments of expense report */ class PaymentExpenseReport extends CommonObject { @@ -83,9 +83,9 @@ class PaymentExpenseReport extends CommonObject */ public $fk_user_modif; - //Unknow field - public $chid; - public $total; + public $type_code; + public $type_label; + /** * Constructor @@ -124,10 +124,10 @@ class PaymentExpenseReport extends CommonObject if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); - if (! empty($this->fk_expensereport)) $this->chid = $this->fk_expensereport; $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -148,10 +148,10 @@ class PaymentExpenseReport extends CommonObject { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql.= " VALUES ($this->fk_expensereport, '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaid)."',"; $sql.= " ".$totalamount.","; - $sql.= " ".$this->fk_typepayment.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql.= " ".$this->fk_typepayment.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".$user->id.","; $sql.= " 0)"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -188,7 +188,6 @@ class PaymentExpenseReport extends CommonObject */ public function fetch($id) { - global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.fk_expensereport,"; @@ -198,11 +197,11 @@ class PaymentExpenseReport extends CommonObject $sql.= " t.amount,"; $sql.= " t.fk_typepayment,"; $sql.= " t.num_payment,"; - $sql.= " t.note,"; + $sql.= " t.note as note_public,"; $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= " pt.code as type_code, pt.libelle as type_label,"; $sql.= ' b.fk_account'; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; @@ -227,13 +226,13 @@ class PaymentExpenseReport extends CommonObject $this->amount = $obj->amount; $this->fk_typepayment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; - $this->note = $obj->note; + $this->note_public = $obj->note_public; $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->type_code = $obj->type_code; - $this->type_libelle = $obj->type_libelle; + $this->type_label = $obj->type_label; $this->bank_account = $obj->fk_account; $this->bank_line = $obj->fk_bank; @@ -476,11 +475,11 @@ class PaymentExpenseReport extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -540,8 +539,7 @@ class PaymentExpenseReport extends CommonObject $acc->fetch($accountid); //Fix me field - $this->total = $this->amount; - $total = $this->total; + $total = $this->amount; if ($mode == 'payment_expensereport') $amount=$total; @@ -665,7 +663,7 @@ class PaymentExpenseReport extends CommonObject $result=''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref=$this->label; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 6a8bd90f95f..1bf2c0db8da 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index cecbae9757a..e893fdf43f4 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -3,8 +3,9 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric FRANCE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,7 +42,7 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', '', ''); $sortfield = GETPOST("sortfield", 'alpha'); @@ -133,6 +134,8 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); + $dolgraph->setHeight(350); + $dolgraph->combine = empty($conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT)?0.05:$conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT; $dolgraph->setShowLegend(1); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); @@ -162,7 +165,7 @@ $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user_author"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) @@ -173,7 +176,7 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense $sql.= " AND d.fk_user_author IN (".join(',', $childids).")\n"; } $sql.= ' AND d.entity IN ('.getEntity('expensereport').')'; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_user_author = ".$socid; $sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($max, 0); @@ -218,7 +221,6 @@ if ($result) print ''.price($obj->total_ttc).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''; print ''; - //print $obj->libelle; print $expensereportstatic->LibStatut($obj->fk_status, 3); print ''; print ''; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index b9605a92eec..715530e9199 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -33,7 +33,7 @@ $langs->load("trips"); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index ecf32df6740..6f837fb866c 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -53,7 +53,7 @@ $childids = $user->getAllChildIds(1); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOST('id', 'int'); // If we are on the view of a specific user @@ -537,8 +537,9 @@ if ($resql) if (! empty($arrayfields['d.date_debut']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($year_start, 'year_start', 1, $min_year, $max_year); @@ -548,9 +549,10 @@ if ($resql) if (! empty($arrayfields['d.date_fin']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) - print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } + print ''; $formother->select_year($year_end, 'year_end', 1, $min_year, $max_year); print ''; } @@ -577,12 +579,12 @@ if ($resql) } if (! empty($arrayfields['d.total_vat']['checked'])) { - print ''; + print ''; } // Amount with all taxes if (! empty($arrayfields['d.total_ttc']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index b29e24d4374..a5038b32b0e 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -39,7 +39,7 @@ $action=GETPOST('action', 'alpha'); // Security check $socid=0; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'expensereport', $id, 'expensereport'); diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index e168c1aa5b8..72b7296ac6b 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -36,7 +36,7 @@ $action=GETPOST('action', 'aZ09'); $confirm=GETPOST('confirm'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); @@ -162,8 +162,8 @@ print ''.$langs->trans('Numero').''.$object->num_pa // Amount print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; -// Note -print ''.$langs->trans('Note').''.nl2br($object->note).''; +// Note public +print ''.$langs->trans('Note').''.nl2br($object->note_public).''; $disable_delete = 0; // Bank account @@ -258,7 +258,7 @@ if ($resql) print ''.price($objp->amount).''; // Remain to pay - print ''.price($remaintopay).''; + print ''.price($objp->total_ttc - $objp->amount).''; // Status print ''.$expensereport->getLibStatut(4, $objp->amount).''; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 8d1c568332d..7fb79573ab2 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -39,9 +39,9 @@ $accountid=GETPOST('accountid', 'int'); // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } @@ -113,13 +113,13 @@ if ($action == 'add_payment') // Create a line of payments $payment = new PaymentExpenseReport($db); - $payment->chid = $expensereport->id; + $payment->fk_expensereport = $expensereport->id; $payment->datepaid = $datepaid; $payment->amounts = $amounts; // Tableau de montant $payment->total = $total; - $payment->fk_typepayment = $_POST["fk_typepayment"]; - $payment->num_payment = $_POST["num_payment"]; - $payment->note = $_POST["note"]; + $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); + $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); + $payment->note_public = GETPOST("note_public", 'none'); if (! $error) { @@ -239,9 +239,11 @@ if ($action == 'create' || empty($action)) print ''; - print '
'; + print '
'; - print '
'; + dol_fiche_end(); + + dol_fiche_head(); print ''."\n"; @@ -274,14 +276,14 @@ if ($action == 'create' || empty($action)) print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("Comments").'
'; - print '
'; + dol_fiche_end(); - dol_fiche_end(); + print '
'; // List of expenses ereport not already paid completely $num = 1; @@ -289,6 +291,7 @@ if ($action == 'create' || empty($action)) print ''; print ''; + print ''; print ''; print ''; print ''; @@ -304,6 +307,7 @@ if ($action == 'create' || empty($action)) print ''; + print '"; print '"; print '"; print '"; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index 670142836cd..5d6301353db 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -42,12 +42,12 @@ $socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; $id = GETPOST('id', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'expensereport', $id, ''); $nowyear=strftime("%Y", dol_now()); @@ -146,7 +146,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index ee543d40cc5..009b1b9ea75 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -24,37 +24,34 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) { -?> + ?> > + if ($user->rights->expensereport->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> - - +print "\n"; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 5b8e7e60a3b..ed6966eb083 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -73,7 +73,9 @@ $entitytoicon = array( 'expensereport_line'=> 'trip', 'holiday' => 'holiday', 'contract_line' => 'contract', - 'translation' => 'generic' + 'translation' => 'generic', + 'bomm' => 'bom', + 'bomline' => 'bom' ); // Translation code @@ -120,7 +122,9 @@ $entitytolang = array( 'holiday' => 'TitreRequestCP', 'contract' => 'Contract', 'contract_line'=> 'ContractLine', - 'translation' => 'Translation' + 'translation' => 'Translation', + 'bom' => 'BOM', + 'bomline' => 'BOMLine' ); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); @@ -1198,7 +1202,7 @@ if ($step == 5 && $datatoexport) } } } - print ''; + print ''; print ''; } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index fcdf155955d..aaf2aec0490 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -52,7 +52,7 @@ $langs->loadLangs(array("interventions","admin","compta","bills")); // Security check $id=(GETPOST('fichinterid', 'int')?GETPOST('fichinterid', 'int'):GETPOST('id', 'int')); $action=GETPOST('action', 'alpha'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $objecttype = 'fichinter_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'ficheinter', $id, $objecttype); @@ -158,12 +158,10 @@ if ($action == 'add') { // on récupère les enregistrements $object->fetch($id); - // on transfert les données de l'un vers l'autre if ($object->socid > 0) { $newinter->socid=$object->socid; - $newinter->fk_projet=$object->fk_projet; - $newinter->fk_project=$object->fk_projet; + $newinter->fk_project=$object->fk_project; $newinter->fk_contrat=$object->fk_contrat; } else { $newinter->socid=GETPOST("socid"); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index f260ec07491..8bb064ca803 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -74,7 +74,7 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empt $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -978,7 +978,7 @@ if ($action == 'create') print ''; // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print ''; @@ -1196,19 +1196,20 @@ elseif ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->ficheinter->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -1271,12 +1272,12 @@ elseif ($id > 0 || ! empty($ref)) print ''; print '
'.$langs->trans("ExpenseReport").''.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").'
'.$expensereport->getNomUrl(1)."'.price($objp->total_ttc)."'.price($sumpaid)."'.price($objp->total_ttc - $sumpaid)."
trans("ExpenseReport"); ?> getNomUrl(1); ?> date_debut, 'day'); ?> rights->expensereport->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'.(! empty($list)?$list:$langs->trans("None")).''.(! empty($list)?$list:''.$langs->trans("None").'').'
'.$langs->trans('NotePrivate').'
'; - print ''; if ($num == 0) { - print ''; + print ''; } else { - while ($obj = $db->fetch_object($resql)) - { - $user = new User($db); - $user->fetch($obj->fk_user); + while ($obj = $db->fetch_object($resql)) + { + $user = new User($db); + $user->fetch($obj->fk_user); - $date_start = $db->jdate($obj->date_debut, true); - $date_end = $db->jdate($obj->date_fin, true); + $date_start = $db->jdate($obj->date_debut, true); + $date_end = $db->jdate($obj->date_fin, true); - $tmpstart = dol_getdate($date_start); - $tmpend = dol_getdate($date_end); + $tmpstart = dol_getdate($date_start); + $tmpend = dol_getdate($date_end); - $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; - $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; + $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; + $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; - $halfdayinmonth = $obj->halfday; - $starthalfdayinmonth = $starthalfday; - $endhalfdayinmonth = $endhalfday; + $halfdayinmonth = $obj->halfday; + $starthalfdayinmonth = $starthalfday; + $endhalfdayinmonth = $endhalfday; - //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - // Set date_start_gmt and date_end_gmt that are date to show for the selected month - $date_start_inmonth = $db->jdate($obj->date_debut, true); - $date_end_inmonth = $db->jdate($obj->date_fin, true); - if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) - { - $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); - $starthalfdayinmonth = 'morning'; - if ($halfdayinmonth == 2) $halfdayinmonth=1; - if ($halfdayinmonth == -1) $halfdayinmonth=0; - } - if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) - { - $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); - $endhalfdayinmonth = 'afternoon'; - if ($halfdayinmonth == 2) $halfdayinmonth=-1; - if ($halfdayinmonth == 1) $halfdayinmonth=0; - } + // Set date_start_gmt and date_end_gmt that are date to show for the selected month + $date_start_inmonth = $db->jdate($obj->date_debut, true); + $date_end_inmonth = $db->jdate($obj->date_fin, true); + if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) + { + $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); + $starthalfdayinmonth = 'morning'; + if ($halfdayinmonth == 2) $halfdayinmonth=1; + if ($halfdayinmonth == -1) $halfdayinmonth=0; + } + if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) + { + $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); + $endhalfdayinmonth = 'afternoon'; + if ($halfdayinmonth == 2) $halfdayinmonth=-1; + if ($halfdayinmonth == 1) $halfdayinmonth=0; + } - // Leave request - $holidaystatic->id=$obj->rowid; - $holidaystatic->ref=$obj->rowid; + // Leave request + $holidaystatic->id=$obj->rowid; + $holidaystatic->ref=$obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } print '
'; + print ''; if ($action != 'contrat') { - print ''; } @@ -1607,7 +1608,7 @@ elseif ($id > 0 || ! empty($ref)) // modified by hook if (empty($reshook)) { - if ($user->societe_id == 0) + if ($user->socid == 0) { if ($action != 'editdescription' && ($action != 'presend')) { // Validate diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 24a42a034a9..380204c2b0d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -160,7 +160,7 @@ class Fichinter extends CommonObject $sql = "SELECT count(fi.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as fi"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -701,51 +701,36 @@ class Fichinter extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the label of a statut + * Returns the label of a status * - * @param int $statut id statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable // Init/load array of translation of status - if (empty($this->statuts) || empty($this->statuts_short)) + if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) { global $langs; $langs->load("fichinter"); - $this->statuts[0]=$langs->trans('Draft'); - $this->statuts[1]=$langs->trans('Validated'); - $this->statuts[2]=$langs->trans('StatusInterInvoiced'); - $this->statuts[3]=$langs->trans('Done'); - $this->statuts_short[0]=$langs->trans('Draft'); - $this->statuts_short[1]=$langs->trans('Validated'); - $this->statuts_short[2]=$langs->trans('StatusInterInvoiced'); - $this->statuts_short[3]=$langs->trans('Done'); - $this->statuts_logo[0]='statut0'; - $this->statuts_logo[1]='statut1'; - $this->statuts_logo[2]='statut6'; - $this->statuts_logo[3]='statut6'; + $this->statuts[self::STATUS_DRAFT]=$langs->trans('Draft'); + $this->statuts[self::STATUS_VALIDATED]=$langs->trans('Validated'); + $this->statuts[self::STATUS_BILLED]=$langs->trans('StatusInterInvoiced'); + $this->statuts[self::STATUS_CLOSED]=$langs->trans('Done'); + $this->statuts_short[self::STATUS_DRAFT]=$langs->trans('Draft'); + $this->statuts_short[self::STATUS_VALIDATED]=$langs->trans('Validated'); + $this->statuts_short[self::STATUS_BILLED]=$langs->trans('StatusInterInvoiced'); + $this->statuts_short[self::STATUS_CLOSED]=$langs->trans('Done'); + $this->statuts_logo[self::STATUS_DRAFT]='status0'; + $this->statuts_logo[self::STATUS_VALIDATED]='status1'; + $this->statuts_logo[self::STATUS_BILLED]='status6'; + $this->statuts_logo[self::STATUS_CLOSED]='status6'; } - if ($mode == 0) - return $this->statuts[$statut]; - elseif ($mode == 1) - return $this->statuts_short[$statut]; - elseif ($mode == 2) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts_short[$statut]; - elseif ($mode == 3) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]); - elseif ($mode == 4) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts[$statut]; - elseif ($mode == 5) - return ''.$this->statuts_short[$statut].' '.img_picto($this->statuts[$statut], $this->statuts_logo[$statut]); - elseif ($mode == 6) - return ''.$this->statuts[$statut].' '.img_picto($this->statuts[$statut], $this->statuts_logo[$statut]); - - return ''; + return dolGetStatus($this->statuts[$status], $this->statuts_short[$status], '', $this->statuts_logo[$status], $mode); } /** @@ -1332,7 +1317,7 @@ class Fichinter extends CommonObject // phpcs:enable $this->lines = array(); - $sql = 'SELECT rowid, description, duree, date, rang'; + $sql = 'SELECT rowid, fk_fichinter, description, duree, date, rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet'; $sql.=' WHERE fk_fichinter = '.$this->id .' ORDER BY rang ASC, date ASC' ; @@ -1348,6 +1333,7 @@ class Fichinter extends CommonObject $line = new FichinterLigne($this->db); $line->id = $objp->rowid; + $line->fk_fichinter = $objp->fk_fichinter; $line->desc = $objp->description; $line->duration = $objp->duree; //For invoicing we calculing hours diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index f88653e70eb..f599cccf801 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -42,6 +42,10 @@ class FichinterRec extends Fichinter public $table_element = 'fichinter_rec'; public $table_element_line = 'fichinter_rec'; public $fk_element = 'fk_fichinter'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'intervention'; public $title; @@ -342,12 +346,11 @@ class FichinterRec extends Fichinter $objp = $this->db->fetch_object($result); $line = new FichinterLigne($this->db); - $line->rowid = $objp->rowid; + $line->id = $objp->rowid; $line->label = $objp->custom_label; // Label line $line->desc = $objp->description; // Description line $line->product_type = $objp->product_type; // Type of line $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; // Label product $line->product_desc = $objp->product_desc; // Description product $line->fk_product_type = $objp->fk_product_type; // Type of product diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index d762657caec..98eb218e9ef 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -200,7 +200,7 @@ class FichinterStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 494a1156b4f..562a38f7ea8 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -39,7 +39,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); @@ -141,20 +141,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->ficheinter->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index b6d70669cc7..3b6b2bd6299 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -47,7 +47,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); @@ -120,21 +120,22 @@ if ($object->id) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { if (! empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 178a7597626..bf20d6b5c12 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -42,10 +42,10 @@ $langs->load("interventions"); // Security check $socid=GETPOST('socid', 'int'); -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } @@ -89,7 +89,7 @@ $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.entity IN (".getEntity('intervention').")"; $sql.= " AND f.fk_soc = s.rowid"; -if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND f.fk_soc = '.$user->socid; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY f.fk_statut"; $resql = $db->query($sql); diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 30aec089ee6..3261ce84d89 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -40,7 +40,7 @@ $id = GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7df7eac69b0..9cee1ec691c 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -59,7 +59,7 @@ $socid=GETPOST('socid', 'int'); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id; @@ -116,13 +116,16 @@ $arrayfields=array( 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index d7ba3a3c178..2982a0ea8c8 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -39,7 +39,7 @@ $ref = GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); @@ -86,20 +86,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 326901728da..02bec47ed86 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -35,10 +35,10 @@ if (! $user->rights->ficheinter->lire) accessforbidden(); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -77,7 +77,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; @@ -117,7 +117,7 @@ if (! $mesg) $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; @@ -156,7 +156,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php index ea69d287880..95c67f987f5 100644 --- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php @@ -22,11 +22,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("interventions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$ilink=0; +$ilink = 0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> @@ -54,8 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink) - - +print "\n"; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 23e6802fd0c..47f44aff059 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -52,7 +52,7 @@ $cancelbutton = GETPOST('cancel', 'alpha'); // Security check $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid'); $object = new Fournisseur($db); @@ -162,7 +162,7 @@ if ($object->id > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -266,7 +266,7 @@ if ($object->id > 0) print '
'; print $langs->trans('Contract'); print 'id.'">'; + print 'id.'">'; print img_edit($langs->trans('SetContract'), 1); print '
trans("Intervention"); ?> getNomUrl(1); ?>getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; print ''; print ''; @@ -790,48 +791,40 @@ if ($object->id > 0) if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); - if ($object->status == 1) - { - print ''.$langs->trans("AddSupplierProposal").''; - } - else - { - print ''.$langs->trans("AddSupplierProposal").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddSupplierProposal").''; + } else { + print ''.$langs->trans("AddSupplierProposal").''; + } } if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); - if ($object->status == 1) - { - print ''.$langs->trans("AddOrder").''; - } - else - { - print ''.$langs->trans("AddOrder").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddOrder").''; + } else { + print ''.$langs->trans("AddOrder").''; + } } if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); - if ($object->status == 1) - { - print ''.$langs->trans("AddBill").''; - } - else - { - print ''.$langs->trans("AddBill").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddBill").''; + } else { + print ''.$langs->trans("AddBill").''; + } } if ($user->rights->fournisseur->facture->creer) { if (! empty($orders2invoice) && $orders2invoice > 0) { - if ($object->status == 1) // Company is open + if ($object->status == 1) { + // Company is open print ''; } else diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index c09c62a4714..37ac4c55e9d 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -28,180 +28,180 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; */ class SupplierOrders extends DolibarrApi { - /** - * - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid' - ); + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); - /** - * @var CommandeFournisseur $order {@type CommandeFournisseur} - */ - public $order; + /** + * @var CommandeFournisseur $order {@type CommandeFournisseur} + */ + public $order; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->order = new CommandeFournisseur($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->order = new CommandeFournisseur($this->db); + } - /** - * Get properties of a supplier order object - * - * Return an array with supplier order information - * - * @param int $id ID of supplier order - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { - throw new RestException(401); - } + /** + * Get properties of a supplier order object + * + * Return an array with supplier order information + * + * @param int $id ID of supplier order + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } - $result = $this->order->fetch($id); - if ( ! $result ) { - throw new RestException(404, 'Supplier order not found'); - } + $result = $this->order->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Supplier order not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->order->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->order); - } + $this->order->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->order); + } - /** - * List orders - * - * Get a list of supplier orders - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" - * @return array Array of order objects - * - * @throws RestException - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') - { - global $db, $conf; + /** + * List orders + * + * Get a list of supplier orders + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Filter by status - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; - if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)"; - if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)"; - if ($status == 'running') $sql.= " AND t.fk_statut IN (3)"; - if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)"; - if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)"; - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)"; - if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)"; - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + // Filter by status + if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; + if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)"; + if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)"; + if ($status == 'running') $sql.= " AND t.fk_statut IN (3)"; + if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)"; + if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)"; + if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)"; + if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)"; + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); - } + $sql.= $db->plimit($limit + 1, $offset); + } - $result = $db->query($sql); - if ($result) - { - $i = 0; - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $db->fetch_object($result); - $order_static = new CommandeFournisseur($db); - if($order_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($order_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror()); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'No supplier order found'); - } - return $obj_ret; - } + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $order_static = new CommandeFournisseur($db); + if($order_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($order_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No supplier order found'); + } + return $obj_ret; + } - /** - * Create supplier order object - * - * @param array $request_data Request datas - * @return int ID of supplier order - */ - public function post($request_data = null) - { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { - throw new RestException(401, "Insuffisant rights"); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create supplier order object + * + * @param array $request_data Request datas + * @return int ID of supplier order + */ + public function post($request_data = null) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { - $this->order->$field = $value; - } - if(! array_keys($request_data, 'date')) { - $this->order->date = dol_now(); - } - /* We keep lines as an array + foreach($request_data as $field => $value) { + $this->order->$field = $value; + } + if(! array_keys($request_data, 'date')) { + $this->order->date = dol_now(); + } + /* We keep lines as an array if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { @@ -210,163 +210,163 @@ class SupplierOrders extends DolibarrApi $this->order->lines = $lines; }*/ - if ($this->order->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors)); - } - return $this->order->id; - } + if ($this->order->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors)); + } + return $this->order->id; + } - /** - * Update supplier order - * - * @param int $id Id of supplier order to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { - throw new RestException(401); - } + /** + * Update supplier order + * + * @param int $id Id of supplier order to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } - $result = $this->order->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Supplier order not found'); - } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier order not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach($request_data as $field => $value) { - if ($field == 'id') continue; - $this->order->$field = $value; - } + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->order->$field = $value; + } - if($this->order->update($id, DolibarrApiAccess::$user)) - return $this->get($id); + if($this->order->update($id, DolibarrApiAccess::$user)) + return $this->get($id); - return false; - } + return false; + } - /** - * Delete supplier order - * - * @param int $id Supplier order ID - * @return type - */ - public function delete($id) - { - if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) { - throw new RestException(401); - } - $result = $this->order->fetch($id); - if ( ! $result) { - throw new RestException(404, 'Supplier order not found'); - } + /** + * Delete supplier order + * + * @param int $id Supplier order ID + * @return type + */ + public function delete($id) + { + if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if ( ! $result) { + throw new RestException(404, 'Supplier order not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if ( $this->order->delete(DolibarrApiAccess::$user) < 0) { - throw new RestException(500); - } + if ( $this->order->delete(DolibarrApiAccess::$user) < 0) { + throw new RestException(500); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Supplier order deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Supplier order deleted' + ) + ); + } - /** - * Validate an order - * - * @param int $id Order ID - * @param int $idwarehouse Warehouse ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * - * @url POST {id}/validate - * - * @return array - * FIXME An error 403 is returned if the request has an empty body. - * Error message: "Forbidden: Content type `text/plain` is not supported." - * Workaround: send this in the body - * { - * "idwarehouse": 0, - * "notrigger": 0 - * } - */ - public function validate($id, $idwarehouse = 0, $notrigger = 0) - { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { - throw new RestException(401); - } - $result = $this->order->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Order not found'); - } + /** + * Validate an order + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + */ + public function validate($id, $idwarehouse = 0, $notrigger = 0) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Order: '.$this->order->error); - } + $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Order: '.$this->order->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Order validated (Ref='.$this->order->ref.')' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order validated (Ref='.$this->order->ref.')' + ) + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return array Array of cleaned object properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->rowid); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->rowid); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array $data Datas to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $order = array(); - foreach (SupplierOrders::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $order[$field] = $data[$field]; - } - return $order; - } + /** + * Validate fields before create or update object + * + * @param array $data Datas to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $order = array(); + foreach (SupplierOrders::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $order[$field] = $data[$field]; + } + return $order; + } } diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index c0473759a6d..711261a161b 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -118,7 +118,7 @@ class Fournisseur extends Societe $sql = "SELECT count(s.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -191,10 +191,10 @@ class Fournisseur extends Societe $sql = "SELECT s.rowid, s.nom as name"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $resql=$this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fb9539f6e62..96d56d98fdf 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -62,7 +62,10 @@ class CommandeFournisseur extends CommonOrder */ public $fk_element = 'fk_commande'; - public $picto='order'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='order'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -439,7 +442,7 @@ class CommandeFournisseur extends CommonOrder $line->fk_product = $objp->fk_product; - $line->libelle = $objp->product_label; + $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; @@ -1272,7 +1275,8 @@ class CommandeFournisseur extends CommonOrder { $this->special_code = $this->lines[$i]->special_code; // TODO : remove this in 9.0 and add special_code param to addline() - $result = $this->addline( // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set + // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set + $result = $this->addline( $this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, @@ -2348,17 +2352,17 @@ class CommandeFournisseur extends CommonOrder for ($i = 0; $i < $num; $i++) { $prod = new Product($this->db); - $libelle = ''; + $label = ''; $ref = ''; if ($prod->fetch($comclient->lines[$i]->fk_product) > 0) { - $libelle = $prod->libelle; - $ref = $prod->ref; + $label = $prod->label; + $ref = $prod->ref; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; - $sql .= " (fk_commande,label,description,fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)"; - $sql .= " VALUES (".$idc.", '" . $this->db->escape($libelle) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'"; + $sql .= " (fk_commande, label, description, fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)"; + $sql .= " VALUES (".$idc.", '" . $this->db->escape($label) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'"; $sql .= ",".$comclient->lines[$i]->fk_product.",'".price2num($comclient->lines[$i]->price)."'"; $sql .= ", '".$comclient->lines[$i]->qty."', ".$comclient->lines[$i]->tva_tx.", ".$comclient->lines[$i]->localtax1_tx.", ".$comclient->lines[$i]->localtax2_tx.", ".$comclient->lines[$i]->remise_percent; $sql .= ", '".price2num($comclient->lines[$i]->subprice)."','0','".$ref."');"; @@ -2748,7 +2752,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT count(co.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -2791,7 +2795,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; @@ -2804,7 +2808,7 @@ class CommandeFournisseur extends CommonOrder else{ $sql.= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")"; } - if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; + if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -3585,7 +3589,7 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int <0 if KO, >0 if OK */ - public function delete($notrigger) + public function delete($notrigger = 0) { global $user; @@ -3593,7 +3597,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->db->begin(); - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".$this->rowid; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index aed9db75a64..b453653c681 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -539,11 +539,11 @@ class CommandeFournisseurDispatch extends CommonObject /** * Return label of a status * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -551,33 +551,33 @@ class CommandeFournisseurDispatch extends CommonObject if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statutshort[$statut]); + return $langs->trans($this->statutshort[$status]); } elseif ($mode == 2) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut8'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts[$status]), 'statut8').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + if ($status==0) return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut8'); } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 16b4bb1719d..783e8b3737e 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -63,6 +63,9 @@ class FactureFournisseur extends CommonInvoice */ public $fk_element='fk_facture_fourn'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto='bill'; /** @@ -637,6 +640,7 @@ class FactureFournisseur extends CommonInvoice $this->libelle = $obj->label; // deprecated $this->label = $obj->label; $this->paye = $obj->paye; + $this->paid = $obj->paye; $this->amount = $obj->amount; $this->remise = $obj->remise; $this->close_code = $obj->close_code; @@ -2187,12 +2191,12 @@ class FactureFournisseur extends CommonInvoice $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ' WHERE ff.paye=0'; $sql.= ' AND ff.fk_statut > 0'; $sql.= " AND ff.entity = ".$conf->entity; - if ($user->societe_id) $sql.=' AND ff.fk_soc = '.$user->societe_id; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql.=' AND ff.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; $resql=$this->db->query($sql); if ($resql) @@ -2361,10 +2365,10 @@ class FactureFournisseur extends CommonInvoice return $numref; } else - { - $this->error=$obj->error; - //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); - return false; + { + $this->error=$obj->error; + //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + return false; } } @@ -2490,7 +2494,7 @@ class FactureFournisseur extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 14d09c20d6e..b18b054a65b 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -46,6 +46,9 @@ class PaiementFourn extends Paiement */ public $table_element='paiementfourn'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'payment'; public $statut; //Status of payment. 0 = unvalidated; 1 = validated @@ -56,7 +59,7 @@ class PaiementFourn extends Paiement * Label of payment type * @var string */ - public $type_libelle; + public $type_label; /** * Code of Payment type @@ -123,7 +126,7 @@ class PaiementFourn extends Paiement $this->note = $obj->note; $this->note_private = $obj->note; $this->type_code = $obj->paiement_code; - $this->type_libelle = $obj->paiement_type; + $this->type_label = $obj->paiement_type; $this->statut = $obj->statut; $error = 1; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 77d8d1c119a..2475b251f56 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ion Agorria - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,7 +81,7 @@ $datelivraison=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -647,95 +647,96 @@ if (empty($reshook)) // Define info_bits $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; + if (preg_match('/\*/', $vat_rate)) { + $info_bits |= 0x01; + } - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); - $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); + $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht') != '') + if (GETPOST('price_ht') != '') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + } + else + { + $vatratecleaned = $vat_rate; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - } - else - { - $vatratecleaned = $vat_rate; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = trim($reg[1]); - $vatratecode = $reg[2]; - } - - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($vatratecleaned / 100)); - $price_base_type = 'HT'; + $vatratecleaned = trim($reg[1]); + $vatratecode = $reg[2]; } - $pu_ht_devise = GETPOST('multicurrency_subprice'); + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($vatratecleaned / 100)); + $price_base_type = 'HT'; + } - // Extrafields Lines - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); - } + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Extrafields Lines + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); } + } - $result = $object->updateline( - $lineid, - $_POST['product_desc'], - $ht, - $_POST['qty'], - $_POST['remise_percent'], - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $price_base_type, - 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type, - false, - $date_start, - $date_end, - $array_options, - $_POST['units'], - $pu_ht_devise, - GETPOST('fourn_ref', 'alpha') - ); - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprodfournprice']); - unset($_POST['remmise_percent']); - unset($_POST['dp_desc']); - unset($_POST['np_desc']); - unset($_POST['pu']); - unset($_POST['fourn_ref']); - unset($_POST['tva_tx']); - unset($_POST['date_start']); - unset($_POST['date_end']); - unset($_POST['units']); - unset($localtax1_tx); - unset($localtax2_tx); + $result = $object->updateline( + $lineid, + $_POST['product_desc'], + $ht, + $_POST['qty'], + $_POST['remise_percent'], + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $price_base_type, + 0, + isset($_POST["type"])?$_POST["type"]:$line->product_type, + false, + $date_start, + $date_end, + $array_options, + $_POST['units'], + $pu_ht_devise, + GETPOST('fourn_ref', 'alpha') + ); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['fourn_ref']); + unset($_POST['tva_tx']); + unset($_POST['date_start']); + unset($_POST['date_end']); + unset($_POST['units']); + unset($localtax1_tx); + unset($localtax2_tx); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); - if ($result >= 0) - { + if ($result >= 0) + { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -753,12 +754,12 @@ if (empty($reshook)) $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - } - else - { + } + else + { dol_print_error($db, $object->error); exit; - } + } } // Remove a product line @@ -1106,12 +1107,19 @@ if (empty($reshook)) // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { - if ($origin == 'order' || $origin == 'commande') + if ($origin == 'propal' || $origin == 'proposal') { + $classname = 'Propal'; + $element = 'comm/propal'; $subelement = 'propal'; + } + elseif ($origin == 'order' || $origin == 'commande') + { + $classname = 'Commande'; $element = $subelement = 'commande'; } else { + $classname = 'SupplierProposal'; $element = 'supplier_proposal'; $subelement = 'supplier_proposal'; } @@ -1131,7 +1139,6 @@ if (empty($reshook)) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = 'SupplierProposal'; $srcobject = new $classname($db); dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); @@ -1167,7 +1174,6 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used { $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_option = $lines[$i]->array_options; @@ -1442,7 +1448,7 @@ llxHeader('', $langs->trans("Order"), $help_url); $now=dol_now(); if ($action=='create') { - print load_fiche_titre($langs->trans('NewOrder')); + print load_fiche_titre($langs->trans('NewOrderSupplier')); dol_htmloutput_events(); @@ -1459,17 +1465,31 @@ if ($action=='create') { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; + $regs=array(); if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { - $element = $regs [1]; - $subelement = $regs [2]; + $element = $regs[1]; + $subelement = $regs[2]; } - $element = 'supplier_proposal'; - $subelement = 'supplier_proposal'; + if ($origin == 'propal' || $origin == 'proposal') + { + $classname = 'Propal'; + $element = 'comm/propal'; $subelement = 'propal'; + } + elseif ($origin == 'order' || $origin == 'commande') + { + $classname = 'Commande'; + $element = $subelement = 'commande'; + } + else + { + $classname = 'SupplierProposal'; + $element = 'supplier_proposal'; + $subelement = 'supplier_proposal'; + } dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = 'SupplierProposal'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) @@ -2309,7 +2329,7 @@ elseif (! empty($object->id)) * Boutons actions */ - if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') + if ($user->socid == 0 && $action != 'editline' && $action != 'delete') { print '
'; @@ -2481,13 +2501,13 @@ elseif (! empty($object->id)) // Create bill //if (! empty($conf->facture->enabled)) //{ - if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + { + if ($user->rights->fournisseur->facture->creer) { - if ($user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans("CreateBill").''; - } + print ''.$langs->trans("CreateBill").''; } + } //} // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index ca5ad3988fc..63a2935212e 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -41,7 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); @@ -157,20 +157,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 7aa50456e3a..0d9782b3683 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -51,8 +51,8 @@ $id = GETPOST("id", 'int'); $ref = GETPOST('ref'); $lineid = GETPOST('lineid', 'int'); $action = GETPOST('action', 'aZ09'); -if ($user->societe_id) - $socid = $user->societe_id; +if ($user->socid) + $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); if (empty($conf->stock->enabled)) { @@ -407,20 +407,21 @@ if ($id > 0 || ! empty($ref)) { $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -462,8 +463,8 @@ if ($id > 0 || ! empty($ref)) { print '
'; print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print "
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } @@ -280,7 +280,7 @@ if ($object->id > 0) print '
'; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + if ($user->rights->societe->creer && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } @@ -706,7 +706,7 @@ if ($object->id > 0) if ($user->rights->fournisseur->facture->lire) { // TODO move to DAO class - $sql = 'SELECT f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,'; + $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,'; $sql.= ' SUM(pf.amount) as am'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; @@ -741,13 +741,14 @@ if ($object->id > 0) $facturestatic->id=$obj->rowid; $facturestatic->ref=($obj->ref?$obj->ref:$obj->rowid); $facturestatic->ref_supplier = $obj->ref_supplier; - $facturestatic->libelle = $obj->libelle; + $facturestatic->libelle = $obj->label; // deprecated + $facturestatic->label = $obj->label; $facturestatic->total_ht = $obj->total_ht; $facturestatic->total_tva = $obj->total_tva; $facturestatic->total_ttc = $obj->total_ttc; print $facturestatic->getNomUrl(1); print $obj->ref_supplier?' - '.$obj->ref_supplier:''; - print ($obj->libelle?' - ':'').dol_trunc($obj->libelle, 14); + print ($obj->label?' - ':'').dol_trunc($obj->label, 14); print ''.dol_print_date($db->jdate($obj->df), 'day').''.price($obj->amount).'' . $author->getNomUrl(1, '', 0, 0, 0) . '
"; diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index aece9d02014..8fbe54e8580 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -47,7 +47,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Get parameters @@ -126,20 +126,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index ec71820ebbb..5a8e0446cea 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Security check $orderid = GETPOST('orderid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $hookmanager = new HookManager($db); @@ -81,7 +81,7 @@ $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cf.fk_soc = s.rowid"; $sql.= " AND cf.entity = ".$conf->entity; -if ($user->societe_id) $sql.=' AND cf.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND cf.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cf.fk_statut"; @@ -117,14 +117,14 @@ if ($resql) print ''; print ''; print "\n"; - foreach (array(0,1,2,3,4,5,6) as $statut) + foreach (array(0,1,2,3,4,5,6) as $status) { - $dataseries[]=array($commandestatic->LibStatut($statut, 1), (isset($vals[$statut])?(int) $vals[$statut]:0)); + $dataseries[]=array($commandestatic->LibStatut($status, 1), (isset($vals[$status])?(int) $vals[$status]:0)); if (! $conf->use_javascript_ajax) { print ''; - print ''; - print ''; + print ''; + print ''; print "\n"; } } @@ -168,7 +168,7 @@ $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cf.fk_soc = s.rowid"; $sql.= " AND s.entity = ".$conf->entity; -if ($user->societe_id) $sql.=' AND cf.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND cf.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY cf.fk_statut"; diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 45f04b865ea..4f73b373589 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -53,7 +53,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); // Security check $socid=0; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); if (!$user->rights->fournisseur->commande->lire) accessforbidden(); @@ -122,20 +122,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4201321913f..f8325ce8b0f 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -91,7 +91,7 @@ $viewstatut=GETPOST('viewstatut'); // Security check $orderid = GETPOST('orderid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id; diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index d2c262d2e7a..63629af25bb 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -40,7 +40,7 @@ $ref = GETPOST('ref'); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); @@ -103,20 +103,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index cd242faac6a..7005d3029f4 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -139,8 +139,8 @@ if (($action == 'create' || $action == 'add') && ! $error) { $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref') : GETPOST('search_ref'); // Security check - if ($user->societe_id) - $socid = $user->societe_id; + if ($user->socid) + $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $usehm = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; @@ -158,17 +158,18 @@ if (($action == 'create' || $action == 'add') && ! $error) { $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); } if (! $error) { - $object->ref = GETPOST('ref'); - $object->ref_supplier = GETPOST('ref_supplier'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('libelle'); + $object->libelle = (GETPOSTISSET('libelle') ? GETPOST('libelle', 'nohtml') : GETPOST('label', 'nohtml')); + $object->label = (GETPOSTISSET('libelle') ? GETPOST('libelle', 'nohtml') : GETPOST('label', 'nohtml')); $object->date = $datefacture; $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'none'); $object->note_private = GETPOST('note_private', 'none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $projectid = GETPOST('projectid'); + $projectid = GETPOST('projectid', 'int'); if ($projectid > 0) $object->fk_project = $projectid; @@ -397,7 +398,7 @@ if ($action == 'create' && !$error) { print ''; // Private note - if (empty($user->societe_id)) { + if (empty($user->socid)) { print ''; print ''; print ' + if ($user->rights->fournisseur->commande->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> - 1) { @@ -74,6 +73,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index 99a1c85902a..649c24408a1 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -35,10 +35,10 @@ $langs->load("companies"); llxHeader(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $sortfield = GETPOST("sortfield", 'alpha'); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a724cf013eb..310f0fc065f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2002-2005 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2019 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -95,7 +95,7 @@ if ($id > 0 || ! empty($ref)) // Security check $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); @@ -308,18 +308,20 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } @@ -634,10 +636,10 @@ if (empty($reshook)) $result = $object->fetch(GETPOST('fac_replacement'), 'int'); $object->fetch_thirdparty(); - $object->ref = GETPOST('ref'); + $object->ref = GETPOST('ref', 'nohtml'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label'); + $object->libelle = GETPOST('label', 'nohtml'); $object->date = $datefacture; $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'none'); @@ -698,10 +700,11 @@ if (empty($reshook)) $tmpproject = GETPOST('projectid', 'int'); // Creation facture - $object->ref = $_POST['ref']; - $object->ref_supplier = $_POST['ref_supplier']; - $object->socid = $_POST['socid']; - $object->libelle = $_POST['label']; + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); + $object->socid = GETPOST('socid', 'int'); + $object->libelle = GETPOST('label', 'nohtml'); + $object->label = GETPOST('label', 'nohtml'); $object->date = $datefacture; $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'none'); @@ -1017,97 +1020,97 @@ if (empty($reshook)) { $db->begin(); - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - if (GETPOST('price_ht') != '') - { - $up = price2num(GETPOST('price_ht')); - $price_base_type = 'HT'; - } - else - { - $up = price2num(GETPOST('price_ttc')); - $price_base_type = 'TTC'; - } + if (GETPOST('price_ht') != '') + { + $up = price2num(GETPOST('price_ht')); + $price_base_type = 'HT'; + } + else + { + $up = price2num(GETPOST('price_ttc')); + $price_base_type = 'TTC'; + } - if (GETPOST('productid') > 0) + if (GETPOST('productid') > 0) + { + $productsupplier = new ProductFournisseur($db); + if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { - $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) { - if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) - { - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); - } - } - - $prod = new Product($db); - $prod->fetch(GETPOST('productid')); - $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; - - $type = $prod->type; - } - else - { - $label = $_POST['product_desc']; - $type = $_POST["type"]?$_POST["type"]:0; - } - - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $tva_tx)) - $info_bits |= 0x01; - - // Define vat_rate - $tva_tx = str_replace('*', '', $tva_tx); - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - - $remise_percent=GETPOST('remise_percent'); - $pu_ht_devise = GETPOST('multicurrency_subprice'); - - // Extrafields Lines - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); - if ($result >= 0) - { - unset($_POST['label']); - unset($_POST['fourn_ref']); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + $prod = new Product($db); + $prod->fetch(GETPOST('productid')); + $label = $prod->description; + if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; - $db->commit(); - } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + $type = $prod->type; + } + else + { + $label = $_POST['product_desc']; + $type = $_POST["type"]?$_POST["type"]:0; + } + + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $tva_tx)) + $info_bits |= 0x01; + + // Define vat_rate + $tva_tx = str_replace('*', '', $tva_tx); + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + + $remise_percent=GETPOST('remise_percent'); + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Extrafields Lines + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); } + } + + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + if ($result >= 0) + { + unset($_POST['label']); + unset($_POST['fourn_ref']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + + $db->commit(); + } + else + { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) @@ -1654,52 +1657,52 @@ if ($action == 'create') $element = 'projet'; } - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'order_supplier') { - $element = 'fourn'; $subelement = 'fournisseur.commande'; - } + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'order_supplier') { + $element = 'fourn'; $subelement = 'fournisseur.commande'; + } - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $objectsrc = new $classname($db); - $objectsrc->fetch($originid); - $objectsrc->fetch_thirdparty(); + require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $objectsrc = new $classname($db); + $objectsrc->fetch($originid); + $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); - //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $soc = $objectsrc->thirdparty; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; - } + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); + $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); - // Replicate extrafields - $objectsrc->fetch_optionals($originid); - $object->array_options = $objectsrc->array_options; + // Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options = $objectsrc->array_options; } else { @@ -2047,7 +2050,7 @@ if ($action == 'create') $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; - // print ''; + // print ''; print ''; // Private note @@ -2085,12 +2088,21 @@ if ($action == 'create') print ''; print ''; print '"; @@ -2376,19 +2388,20 @@ else $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->facture->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -2773,7 +2786,7 @@ else } print ''; print ''; @@ -1105,32 +1106,31 @@ if ($resql) // Show total line if (isset($totalarray['totalhtfield']) - || isset($totalarray['totalvatfield']) - || isset($totalarray['totallocaltax1field']) - || isset($totalarray['totallocaltax2field']) - || isset($totalarray['totalttcfield']) - || isset($totalarray['totalamfield']) - || isset($totalarray['totalrtpfield']) - ) - { + || isset($totalarray['totalvatfield']) + || isset($totalarray['totallocaltax1field']) + || isset($totalarray['totallocaltax2field']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; while ($i < $totalarray['nbfield']) { - $i++; - if ($i == 1) - { + $i++; + if ($i == 1) + { if ($num < $limit && empty($offset)) print ''; else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''; - elseif ($totalarray['totallocaltax2field'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - elseif ($totalarray['totalamfield'] == $i) print ''; - elseif ($totalarray['totalrtpfield'] == $i) print ''; - else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''; + elseif ($totalarray['totallocaltax2field'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + elseif ($totalarray['totalamfield'] == $i) print ''; + elseif ($totalarray['totalrtpfield'] == $i) print ''; + else print ''; } print ''; } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index ba51b4688a9..a7200495e96 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -40,7 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); @@ -102,20 +102,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { // $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index c68dcd98752..1dc10406a24 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -78,9 +78,9 @@ $multicurrency_amounts=array(); $multicurrency_amountsresttopay=array(); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $object = new PaiementFourn($db); @@ -755,7 +755,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $db->free($resql); } else - { + { dol_print_error($db); } } diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php index 94ef53f2372..59ad242fa05 100644 --- a/htdocs/fourn/facture/rapport.php +++ b/htdocs/fourn/facture/rapport.php @@ -30,16 +30,16 @@ $langs->loadLangs(array('bills')); // Security check $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $action=GETPOST('action', 'aZ09'); $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $dir = $conf->fournisseur->facture->dir_output.'/payments'; diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index ed94fdf23d4..cc3d3084464 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -25,11 +25,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> + if ($user->rights->fournisseur->facture->lire) { + $sign = 1; + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; + if ($objectlink->statut != 3) + { + // If not abandonned + $total = $total + $sign * $objectlink->total_ht; + echo price($objectlink->total_ht); + } + else + { + echo ''.price($objectlink->total_ht).''; + } + } ?> - 1) { @@ -85,6 +84,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index a7107f0a5c8..3615051fa2f 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("suppliers", "orders", "companies")); // Security check $socid = GETPOST("socid", 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, ''); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 8b65d8be7c0..3977c6ad4be 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -197,7 +197,7 @@ if ($result > 0) print ''; // Payment mode - $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_label; print ''; @@ -342,7 +342,7 @@ if ($result > 0) print '
'; if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->societe_id == 0 && $object->statut == 0 && $action == '') + if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) @@ -351,7 +351,7 @@ if ($result > 0) } } } - if ($user->societe_id == 0 && $action == '') + if ($user->socid == 0 && $action == '') { if ($user->rights->fournisseur->facture->supprimer) { diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index b7119e3ae67..860cbde73ba 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -54,7 +54,7 @@ if (! $sortfield) $sortfield="p.ref"; // Set here default search field if (! $sortorder) $sortorder="ASC"; $fourn_id = GETPOST('fourn_id', 'intcomma'); -if ($user->societe_id) $fourn_id=$user->societe_id; +if ($user->socid) $fourn_id=$user->socid; $catid = GETPOST('catid', 'intcomma'); diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index db2a3bdc38a..7f9a7fb11ab 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -32,10 +32,10 @@ $langs->loadLangs(array('bills', 'companies')); // Security check $socid = GETPOST("socid", 'int'); -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } @@ -62,7 +62,7 @@ if ($socid > 0) $head = societe_prepare_head($societe); dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($societe, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($societe, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); dol_fiche_end(); if (! empty($conf->fournisseur->enabled) && $user->rights->facture->lire) @@ -77,7 +77,7 @@ if ($socid > 0) $sql.= " u.login, u.rowid as userid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; - $sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany + $sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany $sql.= " AND f.fk_user_valid = u.rowid"; $sql.= " ORDER BY f.datef DESC"; diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index d69f1751911..354fa5c0921 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; $langs->loadLangs(array('ftp', 'companies', 'other')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'ftp', ''); // Get parameters @@ -359,7 +359,7 @@ llxHeader(); // Add logic to shoow/hide buttons if ($conf->use_javascript_ajax) { -?> + ?> -id); -// Protection if external user -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'holiday', $id, 'holiday'); - // Load translation files required by the page $langs->loadLangs(array("holiday","mails")); @@ -65,14 +61,15 @@ if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; $error = 0; $object = new Holiday($db); + $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if ($id > 0) +if (($id > 0) || $ref) { - $object->fetch($id); + $object->fetch($id, $ref); // Check current user can read this leave request $canread = 0; @@ -92,6 +89,10 @@ $candelete = 0; if (! empty($user->rights->holiday->delete)) $candelete=1; if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete=1; +// Protection if external user +if ($user->socid) $socid=$user->socid; +$result = restrictedArea($user, 'holiday', $object->id, 'holiday'); + /* * Actions diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 0c8c17b23a4..f18cad2a266 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -54,6 +54,9 @@ class Holiday extends CommonObject */ public $fk_element = 'fk_holiday'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'holiday'; /** @@ -1217,68 +1220,40 @@ class Holiday extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the label of a statut + * Returns the label of a status * - * @param int $statut id statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @param integer $startdate Date holiday should start * @return string Label */ - public function LibStatut($statut, $mode = 0, $startdate = '') + public function LibStatut($status, $mode = 0, $startdate = '') { - // phpcs:enable - global $langs; - - if ($mode == 0) + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($statut == 1) return $langs->trans('DraftCP'); - elseif ($statut == 2) return $langs->trans('ToReviewCP'); - elseif ($statut == 3) return $langs->trans('ApprovedCP'); - elseif ($statut == 4) return $langs->trans('CancelCP'); - elseif ($statut == 5) return $langs->trans('RefuseCP'); - } - elseif ($mode == 2) - { - $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; - if ($statut == 1) return img_picto($langs->trans('DraftCP'), 'statut0').' '.$langs->trans('DraftCP'); // Draft - elseif ($statut == 2) return img_picto($langs->trans('ToReviewCP'), 'statut1').' '.$langs->trans('ToReviewCP'); // Waiting approval - elseif ($statut == 3) return img_picto($langs->trans('ApprovedCP'), $pictoapproved).' '.$langs->trans('ApprovedCP'); - elseif ($statut == 4) return img_picto($langs->trans('CancelCP'), 'statut5').' '.$langs->trans('CancelCP'); - elseif ($statut == 5) return img_picto($langs->trans('RefuseCP'), 'statut5').' '.$langs->trans('RefuseCP'); - } - elseif ($mode == 3) - { - $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; - if ($statut == 1) return img_picto($langs->trans('DraftCP'), 'statut0'); - elseif ($statut == 2) return img_picto($langs->trans('ToReviewCP'), 'statut1'); - elseif ($statut == 3) return img_picto($langs->trans('ApprovedCP'), $pictoapproved); - elseif ($statut == 4) return img_picto($langs->trans('CancelCP'), 'statut5'); - elseif ($statut == 5) return img_picto($langs->trans('RefuseCP'), 'statut5'); - } - elseif ($mode == 5) - { - $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; - if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'), 'statut0'); // Draft - elseif ($statut == 2) return $langs->trans('ToReviewCP').' '.img_picto($langs->trans('ToReviewCP'), 'statut1'); // Waiting approval - elseif ($statut == 3) return $langs->trans('ApprovedCP').' '.img_picto($langs->trans('ApprovedCP'), $pictoapproved); - elseif ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'), 'statut5'); - elseif ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'), 'statut5'); - } - elseif ($mode == 6) - { - $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; - if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'), 'statut0'); // Draft - elseif ($statut == 2) return $langs->trans('ToReviewCP').' '.img_picto($langs->trans('ToReviewCP'), 'statut1'); // Waiting approval - elseif ($statut == 3) return $langs->trans('ApprovedCP').' '.img_picto($langs->trans('ApprovedCP'), $pictoapproved); - elseif ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'), 'statut5'); - elseif ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'), 'statut5'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('DraftCP'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('ToReviewCP'); + $this->labelStatus[self::STATUS_APPROVED] = $langs->trans('ApprovedCP'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('CancelCP'); + $this->labelStatus[self::STATUS_REFUSED] = $langs->trans('RefuseCP'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('DraftCP'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('ToReviewCP'); + $this->labelStatusShort[self::STATUS_APPROVED] = $langs->trans('ApprovedCP'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('CancelCP'); + $this->labelStatusShort[self::STATUS_REFUSED] = $langs->trans('RefuseCP'); } - else return $statut; + $statusType = 'status6'; + if (! empty($startdate) && $startdate > dol_now()) $statusType = 'status4'; + if ($status == self::STATUS_DRAFT) $statusType = 'status0'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) $statusType = 'status5'; + if ($status == self::STATUS_REFUSED) $statusType = 'status5'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -1744,7 +1719,8 @@ class Holiday extends CommonObject } } else - { // Si faux donc return array + { + // Si faux donc return array // List for Dolibarr users if ($type) { @@ -1757,49 +1733,47 @@ class Holiday extends CommonObject $sql.= " WHERE (ug.fk_user = u.rowid"; $sql.= " AND ug.entity = ".$conf->entity.")"; $sql.= " OR u.admin = 1"; - } - else + } else { $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + } - $sql.= " AND u.statut > 0"; - if ($filters) $sql.=$filters; + $sql.= " AND u.statut > 0"; + if ($filters) $sql.=$filters; - $resql=$this->db->query($sql); + $resql=$this->db->query($sql); - // Si pas d'erreur SQL - if ($resql) - { - $i = 0; - $tab_result = $this->holiday; - $num = $this->db->num_rows($resql); + // Si pas d'erreur SQL + if ($resql) + { + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); - // Boucles du listage des utilisateurs - while($i < $num) { - $obj = $this->db->fetch_object($resql); + // Boucles du listage des utilisateurs + while($i < $num) { + $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user - $tab_result[$i]['name'] = $obj->lastname; // deprecated - $tab_result[$i]['lastname'] = $obj->lastname; - $tab_result[$i]['firstname'] = $obj->firstname; - $tab_result[$i]['gender'] = $obj->gender; - $tab_result[$i]['status'] = $obj->statut; - $tab_result[$i]['employee'] = $obj->employee; - $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager - //$tab_result[$i]['type'] = $obj->type; - //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user + $tab_result[$i]['name'] = $obj->lastname; // deprecated + $tab_result[$i]['lastname'] = $obj->lastname; + $tab_result[$i]['firstname'] = $obj->firstname; + $tab_result[$i]['gender'] = $obj->gender; + $tab_result[$i]['status'] = $obj->statut; + $tab_result[$i]['employee'] = $obj->employee; + $tab_result[$i]['photo'] = $obj->photo; + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager + //$tab_result[$i]['type'] = $obj->type; + //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; - $i++; - } - // Retoune le tableau des utilisateurs - return $tab_result; - } - else - { - // Erreur SQL - $this->errors[]="Error ".$this->db->lasterror(); - return -1; + $i++; } + // Retoune le tableau des utilisateurs + return $tab_result; + } else { + // Erreur SQL + $this->errors[]="Error ".$this->db->lasterror(); + return -1; + } } else { @@ -2198,7 +2172,7 @@ class Holiday extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $now=dol_now(); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 9add71da395..3419d663e30 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -53,7 +53,7 @@ if (! $sortorder) $sortorder="ASC"; // Protection if external user -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // If the user does not have perm to read the page if (!$user->rights->holiday->read) accessforbidden(); @@ -173,6 +173,10 @@ llxHeader('', $langs->trans('CPTitreMenu')); $typeleaves=$holiday->getTypes(1, 1); +$result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user. +if ($result < 0) { + setEventMessages($holiday->error, $holiday->errors, 'errors'); +} print '
'; @@ -189,21 +193,14 @@ print load_fiche_titre($langs->trans('MenuConfCP'), '', 'title_hrm.png'); print '
'.$langs->trans('LastUpdateCP').': '."\n"; $lastUpdate = $holiday->getConfCP('lastUpdate'); -if ($lastUpdate) -{ - $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; - $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; - print ''.dol_print_date($db->jdate($holiday->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; - print '
'.$langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.''."\n"; +if ($lastUpdate) { + print ''.dol_print_date($db->jdate($lastUpdate), 'dayhour').''; + print '
'.$langs->trans("MonthOfLastMonthlyUpdate").': '.$langs->trans('Month'.substr($lastUpdate, 4, 2)).' '.substr($lastUpdate, 0, 4).''."\n"; +} else { + print $langs->trans('None'); } -else print $langs->trans('None'); print "

\n"; -$result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user. -if ($result < 0) -{ - setEventMessages($holiday->error, $holiday->errors, 'errors'); -} $filters = ''; diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 05ddf164105..bbf6cac4c87 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -45,7 +45,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'holiday', $id, 'holiday'); // Get parameters @@ -213,7 +213,7 @@ if ($object->id) print '
'; print '
'.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'
'.$commandestatic->LibStatut($statut, 0).''.(isset($vals[$statut])?$vals[$statut]:0).''.$commandestatic->LibStatut($status, 0).''.(isset($vals[$status])?$vals[$status]:0).'
' . $langs->trans('NotePrivate') . ''; @@ -436,7 +437,7 @@ if (($action != 'create' && $action != 'add') && !$error) { }); }); - - +print "\n"; -load("orders"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?>
trans("SupplierOrder"); ?> trans("ShowOrder"), "order").' '.$objectlink->ref; ?> ref_supplier; ?> date, 'day'); ?> rights->fournisseur->commande->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, '', 'invoice_supplier'); - $cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']); - if ($cntinvoice>=1) + + $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; + + // count function need a array as argument (Note: the array must implement Countable too) + if(is_array($invoice_supplier)) { - setEventMessages('WarningBillExist', null, 'warnings'); - echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['invoice_supplier'])->getNomUrl(1).')'; + $cntinvoice = count($invoice_supplier); + + if ($cntinvoice >= 1) + { + setEventMessages('WarningBillExist', null, 'warnings'); + echo ' ('.$langs->trans('LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).')'; + } } + echo '
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
' . price($sign * $objp->amount) . ''; - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print 'rowid.'">'; print img_delete(); @@ -3076,13 +3089,13 @@ else } // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print ''; // must use facid because id is for payment id not invoice } // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print ''; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 2d2f9006632..18f64d15734 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -41,7 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index d8cf1ecda27..087325e3de0 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -46,7 +46,7 @@ $confirm=GETPOST('confirm', 'alpha'); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Get parameters diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 78abccdc250..0a10d58764a 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -39,10 +39,10 @@ $socid=GETPOST('socid', 'int'); $option = GETPOST('option'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $sortfield = GETPOST("sortfield", 'alpha'); diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 6b4af5dd290..8f10fd94dc4 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -40,7 +40,7 @@ $id = GETPOST("facid", 'int')?GETPOST("facid", 'int'):GETPOST("id", 'int'); $ref = GETPOST("ref", 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 367f360da37..b13e283ea65 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2015-2016 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,11 +60,11 @@ $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplier $socid = GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action=''; $_GET["action"] = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $mode=GETPOST("mode"); @@ -375,10 +375,11 @@ if (! $search_all) $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; $sql.= " p.rowid, p.ref, p.title"; - - foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by - { - $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + //prevent error with sql_mode=only_full_group_by + $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + } } } else @@ -614,12 +615,12 @@ if ($resql) FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); -/* + /* if (! empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } -*/ + */ //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).'
trans("SupplierInvoice"); ?> trans("ShowBill"), "bill").' '.$objectlink->ref; ?> ref_supplier; ?> date, 'day'); ?> rights->fournisseur->facture->lire) { - $sign = 1; - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) // If not abandonned - { - $total = $total + $sign * $objectlink->total_ht; - echo price($objectlink->total_ht); - } - else - { - echo ''.price($objectlink->total_ht).''; - } - } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'.$langs->trans('PaymentMode').''.$labeltype; print $object->num_paiement?' - '.$object->num_paiement:''; print '
'."\n"; -/* + /* print ''; print '
'; print '
'; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index b86dd2864b5..8b30c03a1a9 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; $langs->loadLangs(array('users', 'holiday', 'hrm')); // Protection if external user -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); $action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -59,9 +59,9 @@ $childids = $user->getAllChildIds(1); // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', '', ''); @@ -121,6 +121,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, // List of fields to search into when doing a "search in all" $fieldstosearchall = array( + 'cp.ref'=>'Ref', 'cp.description'=>'Description', 'uu.lastname'=>'EmployeeLastname', 'uu.firstname'=>'EmployeeFirstname', @@ -289,10 +290,7 @@ $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pou // Search all if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Ref -if(!empty($search_ref)) -{ - $sql.= " AND cp.rowid = ".(int) $db->escape($search_ref); -} +if (!empty($search_ref)) $sql.= natural_search("cp.ref", $search_ref); // Start date $sql.= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start); // End date diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index a7efd8616f0..c09771e47a3 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -35,9 +35,9 @@ $langs->loadLangs(array("holiday")); // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'holiday', $id, ''); @@ -119,75 +119,75 @@ print '
'.$langs->trans('None').'
'.$langs->trans('None').'
'; - print $holidaystatic->getNomUrl(1, 1); - print '' . $user->getFullName($langs) . '' . $obj->label . '' . dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print '' . dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . '' . dol_print_date($date_start_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; - print '' . dol_print_date($date_end_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; - print '' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '
'; + print $holidaystatic->getNomUrl(1, 1); + print '' . $user->getFullName($langs) . '' . $obj->label . '' . dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print '' . dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . '' . dol_print_date($date_start_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; + print '' . dol_print_date($date_end_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; + print '' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '
'; print ''; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 13d4cb7d23a..9e5f0ad0cba 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; // Protection if external user -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page if(!$user->rights->holiday->read_all) accessforbidden(); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 0ea9b5ffba2..20c80d07981 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -55,7 +55,10 @@ class Establishment extends CommonObject */ public $ismultientitymanaged = 1; - public $picto='building'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='building'; /** * @var int ID @@ -265,12 +268,12 @@ class Establishment extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 80a9366186c..5f390ab1d45 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -46,7 +46,7 @@ $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes')); $socid=GETPOST("socid", "int"); // Protection if external user -if ($user->societe_id > 0) accessforbidden(); +if ($user->socid > 0) accessforbidden(); if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; @@ -114,6 +114,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -126,6 +127,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print ''; print '
'; } @@ -178,7 +180,7 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) $sql.= " WHERE u.rowid = x.fk_user"; $sql.= " AND x.entity = ".$conf->entity; if (empty($user->rights->holiday->read_all)) $sql.=' AND x.fk_user IN ('.join(',', $childids).')'; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql.= $db->order("x.tms", "DESC"); $sql.= $db->plimit($max, 0); @@ -246,93 +248,22 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) } print '
'; print '
'; + print '
'; } else dol_print_error($db); } -// Last expense report (old module) -if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) -{ - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE u.rowid = d.fk_user"; - $sql.= " AND d.entity = ".$conf->entity; - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if (!empty($socid)) $sql.= " AND d.fk_soc = ".$socid; - $sql.= $db->order("d.tms", "DESC"); - $sql.= $db->plimit($max, 0); - - $result = $db->query($sql); - if ($result) - { - $var=false; - $num = $db->num_rows($result); - - $i = 0; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - $total_ttc = $totalam = $total = 0; - - $deplacementstatic=new Deplacement($db); - $userstatic=new User($db); - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - - $deplacementstatic->ref=$obj->rowid; - $deplacementstatic->id=$obj->rowid; - - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; - $userstatic->login=$obj->login; - $userstatic->email=$obj->email; - $userstatic->statut=$obj->statut; - $userstatic->photo=$obj->photo; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $i++; - } - } - else - { - print ''; - } - print '
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(-1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("None").'
'; - print '
'; - } - else dol_print_error($db); -} - -// Last expense report (new module) +// Latest expense report if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = x.fk_user_author"; $sql.= " AND x.entity = ".$conf->entity; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',', $childids).')'; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql.= $db->order("x.tms", "DESC"); $sql.= $db->plimit($max, 0); @@ -340,7 +271,6 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire $result = $db->query($sql); if ($result) { - $var=false; $num = $db->num_rows($result); $i = 0; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 9edc7f018a7..6a00679fd84 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1962,15 +1962,16 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') $height='24px'; - if ($key == 'none') {//stop multiple duplicate ids with no number + if ($key == 'none') { + //stop multiple duplicate ids with no number print "\n\n\n"; print '
' . "\n"; print '' . "\n"; } else { - print "\n\n\n"; + print "\n\n\n"; print '
' . "\n"; - print '
'."\n"; + print '
'."\n"; } if ($pos && $pos > count($fieldssource)) // No fields diff --git a/htdocs/imports/index.php b/htdocs/imports/index.php index f674daddddc..2ce0139f517 100644 --- a/htdocs/imports/index.php +++ b/htdocs/imports/index.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php'; // Load translation files required by the page $langs->load("exports"); -if (! $user->societe_id == 0) +if (! $user->socid == 0) accessforbidden(); $import=new Import($db); diff --git a/htdocs/index.php b/htdocs/index.php index b0b04075da4..37ea818817a 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -115,7 +115,7 @@ $boxstatFromHook = ''; // Load translation files required by page $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts')); -if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) +if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $object=new stdClass(); $parameters=array(); @@ -283,26 +283,27 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT DOL_URL_ROOT.'/don/list.php?leftmenu=donations' ); // Translation lang files - $langfile=array("users", - "companies", - "prospects", - "suppliers", - "companies", - "members", - "products", - "products", - "propal", - "orders", - "bills", - "contracts", - "interventions", - "bills", - "bills", - "supplier_proposal", - "projects", - "trips", - "holiday", - "donations" + $langfile=array( + "users", + "companies", + "prospects", + "suppliers", + "companies", + "members", + "products", + "products", + "propal", + "orders", + "bills", + "contracts", + "interventions", + "bills", + "bills", + "supplier_proposal", + "projects", + "trips", + "holiday", + "donations", ); @@ -353,34 +354,34 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $showweather = (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0; -//Array that contains all WorkboardResponse classes to process them + //Array that contains all WorkboardResponse classes to process them $dashboardlines = array(); -// Do not include sections without management permission + // Do not include sections without management permission require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php'; -// Number of actions to do (late) + // Number of actions to do (late) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $board = new ActionComm($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of project opened + // Number of project opened if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $board = new Project($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of tasks to do (late) + // Number of tasks to do (late) if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; $board = new Task($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of commercial proposals opened (expired) + // Number of commercial proposals opened (expired) if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $board = new Propal($db); @@ -389,7 +390,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); } -// Number of commercial proposals opened (expired) + // Number of commercial proposals opened (expired) if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; $board = new SupplierProposal($db); @@ -398,14 +399,14 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); } -// Number of customer orders a deal + // Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $board = new Commande($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of suppliers orders a deal + // Number of suppliers orders a deal if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $board = new CommandeFournisseur($db); @@ -413,7 +414,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_awaiting'] = $board->load_board($user, 'awaiting'); } -// Number of services enabled (delayed) + // Number of services enabled (delayed) if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $board = new Contrat($db); @@ -421,22 +422,22 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // Number of active services (expired) $dashboardlines[$board->element . '_active'] = $board->load_board($user, "active"); } -// Number of invoices customers (has paid) + // Number of invoices customers (has paid) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $board = new Facture($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of supplier invoices (has paid) + // Number of supplier invoices (has paid) if (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->fournisseur->facture->lire)) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $board = new FactureFournisseur($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of transactions to conciliate - if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id) { + // Number of transactions to conciliate + if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid) { include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $board = new Account($db); $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate @@ -445,35 +446,35 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } } -// Number of cheque to send - if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { + // Number of cheque to send + if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php'; $board = new RemiseCheque($db); $dashboardlines['RemiseCheque'] = $board->load_board($user); } -// Number of foundation members - if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->societe_id) { + // Number of foundation members + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->socid) { include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $board = new Adherent($db); $dashboardlines['Adherent'] = $board->load_board($user); } -// Number of expense reports to approve + // Number of expense reports to approve if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'toapprove'); } -// Number of expense reports to pay + // Number of expense reports to pay if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay'); } -// Number of holidays to approve + // Number of holidays to approve if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) { include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; $board = new Holiday($db); @@ -591,11 +592,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } -// Calculate total nb of late + // Calculate total nb of late $totallate = $totaltodo = 0; -//Remove any invalid response -//load_board can return an integer if failed or WorkboardResponse if OK + //Remove any invalid response + //load_board can return an integer if failed or WorkboardResponse if OK $valid_dashboardlines = array(); foreach ($dashboardlines as $infoKey => $tmp) { if ($tmp instanceof WorkboardResponse) { @@ -603,7 +604,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } } -// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop + // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop foreach ($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { $totaltodo += $board->nbtodo; @@ -645,7 +646,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $boxwork .= ''; $boxwork .= '' . "\n"; -// Show dashboard + // Show dashboard $nbworkboardempty = 0; $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array(); if (!empty($valid_dashboardlines)) { @@ -886,7 +887,7 @@ $boxlist.=$resultboxes['boxlista']; $boxlist.= ''; -if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) +if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { // Remove allready present info in new dash board if(!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0){ @@ -1001,7 +1002,7 @@ function showWeather($totallate, $text, $options, $morecss = '') { global $conf; - $weather = getWeatherStatus($totallate); + $weather = getWeatherStatus($totallate); return img_weather($text, $weather->picto, $options, 0, $morecss); } diff --git a/htdocs/install/doctemplates/boms/template_bom.odt b/htdocs/install/doctemplates/boms/template_bom.odt new file mode 100644 index 00000000000..9eea32e4197 Binary files /dev/null and b/htdocs/install/doctemplates/boms/template_bom.odt differ diff --git a/htdocs/install/doctemplates/mrps/template_mo.odt b/htdocs/install/doctemplates/mrps/template_mo.odt new file mode 100644 index 00000000000..7545fe73a34 Binary files /dev/null and b/htdocs/install/doctemplates/mrps/template_mo.odt differ diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index c953790f8c0..b800f5f6ad4 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -118,19 +118,21 @@ if (! empty($force_install_message)) +if (empty($dolibarr_main_url_root)) { + $dolibarr_main_document_root = detect_dolibarr_main_document_root(); +} +?> - @@ -245,9 +244,7 @@ if (! empty($force_install_message)) id="db_name" name="db_name" value="" - + > @@ -324,9 +321,7 @@ if (! empty($force_install_message)) ?> @@ -343,9 +338,7 @@ if (! empty($force_install_message)) id="db_host" name="db_host" value="" - + > @@ -391,12 +380,8 @@ if (! empty($force_install_message)) - + + > @@ -424,17 +407,16 @@ if (! empty($force_install_message)) + value=" + " + > @@ -446,12 +428,8 @@ if (! empty($force_install_message)) - + + > '; - print ''; + print ''; print ''; } @@ -706,7 +706,7 @@ else * Boutons actions */ - if ($user->societe_id == 0) + if ($user->socid == 0) { print '
'; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 428015a96f4..c962d1d352e 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -64,10 +64,16 @@ class Livraison extends CommonObject public $ref_customer; public $date_delivery; // Date really received + + /** + * @var integer|string date_creation + */ public $date_creation; + public $date_valid; public $model_pdf; + /** * Constructor * @@ -823,44 +829,44 @@ class Livraison extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable global $langs; if ($mode==0) { - if ($statut==-1) return $langs->trans('StatusDeliveryCanceled'); - elseif ($statut==0) return $langs->trans('StatusDeliveryDraft'); - elseif ($statut==1) return $langs->trans('StatusDeliveryValidated'); + if ($status==-1) return $langs->trans('StatusDeliveryCanceled'); + elseif ($status==0) return $langs->trans('StatusDeliveryDraft'); + elseif ($status==1) return $langs->trans('StatusDeliveryValidated'); } elseif ($mode==1) { - if ($statut==-1) return $langs->trans($this->statuts[$statut]); - elseif ($statut==0) return $langs->trans($this->statuts[$statut]); - elseif ($statut==1) return $langs->trans($this->statuts[$statut]); + if ($status==-1) return $langs->trans($this->statuts[$status]); + elseif ($status==0) return $langs->trans($this->statuts[$status]); + elseif ($status==1) return $langs->trans($this->statuts[$status]); } elseif ($mode == 3) { - if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5'); - if ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0'); - if ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4'); + if ($status==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5'); + if ($status==0) return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0'); + if ($status==1) return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4'); } elseif ($mode == 4) { - if ($statut==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5').' '.$langs->trans('StatusDeliveryCanceled'); - elseif ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0').' '.$langs->trans('StatusDeliveryDraft'); - elseif ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4').' '.$langs->trans('StatusDeliveryValidated'); + if ($status==-1) return img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5').' '.$langs->trans('StatusDeliveryCanceled'); + elseif ($status==0) return img_picto($langs->trans('StatusDeliveryDraft'), 'statut0').' '.$langs->trans('StatusDeliveryDraft'); + elseif ($status==1) return img_picto($langs->trans('StatusDeliveryValidated'), 'statut4').' '.$langs->trans('StatusDeliveryValidated'); } elseif ($mode == 6) { - if ($statut==-1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5'); - elseif ($statut==0) return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'), 'statut0'); - elseif ($statut==1) return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'), 'statut4'); + if ($status==-1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'), 'statut5'); + elseif ($status==0) return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'), 'statut0'); + elseif ($status==1) return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'), 'statut4'); } } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 066399320d8..7cf592a354c 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -44,7 +44,7 @@ $projectid = GETPOST('projectid', 'int'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index c8e241186d2..66fdfbc25a2 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -41,6 +41,9 @@ class Loan extends CommonObject */ public $table_element='loan'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'bill'; /** @@ -63,7 +66,13 @@ class Loan extends CommonObject public $account_capital; public $account_insurance; public $account_interest; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_modification; public $date_validation; @@ -402,12 +411,12 @@ class Loan extends CommonObject /** * Return label for given status * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=Label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label, 5=Short label + Picto * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - public function LibStatut($statut, $mode = 0, $alreadypaid = -1) + public function LibStatut($status, $mode = 0, $alreadypaid = -1) { // phpcs:enable global $langs; @@ -415,38 +424,38 @@ class Loan extends CommonObject if ($mode == 0 || $mode == 1) { - if ($statut == 0) return $langs->trans("Unpaid"); - elseif ($statut == 1) return $langs->trans("Paid"); + if ($status == 0) return $langs->trans("Unpaid"); + elseif ($status == 1) return $langs->trans("Paid"); } elseif ($mode == 2) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 3) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 4) { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 5) { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 6) { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } else return "Error, mode/status not found"; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index c9a8fd9354e..c5335496313 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -94,6 +94,10 @@ class LoanSchedule extends CommonObject */ public $total; + public $type_code; + public $type_label; + + /** * Constructor * @@ -213,7 +217,7 @@ class LoanSchedule extends CommonObject $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= " pt.code as type_code, pt.libelle as type_label,"; $sql.= ' b.fk_account'; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; @@ -245,7 +249,7 @@ class LoanSchedule extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->type_code = $obj->type_code; - $this->type_libelle = $obj->type_libelle; + $this->type_label = $obj->type_label; $this->bank_account = $obj->fk_account; $this->bank_line = $obj->fk_bank; diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index c938fe92c80..eb0508c3768 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -90,6 +90,10 @@ class PaymentLoan extends CommonObject */ public $fk_user_modif; + public $type_code; + public $type_label; + + /** * Constructor * @@ -208,7 +212,7 @@ class PaymentLoan extends CommonObject $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= " pt.code as type_code, pt.libelle as type_label,"; $sql.= ' b.fk_account'; $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; @@ -242,7 +246,7 @@ class PaymentLoan extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->type_code = $obj->type_code; - $this->type_libelle = $obj->type_libelle; + $this->type_label = $obj->type_label; $this->bank_account = $obj->fk_account; $this->bank_line = $obj->fk_bank; @@ -545,8 +549,6 @@ class PaymentLoan extends CommonObject $result=''; - if (empty($this->ref)) $this->ref=$this->lib; - if (!empty($this->id)) { $link = ''; diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 0cbcec2f209..a4bed07949e 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -40,7 +40,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); // Get parameters diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index b4fb8851ad0..618345518ed 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -38,7 +38,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'loan', $id, '', ''); diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 7af7d55fb43..c77d6b1c855 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("loan","compta","banks","bills")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'loan', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 29b9df4bf70..1f937e6fe77 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -33,7 +33,7 @@ $langs->loadLangs(array("bills","banks","companies","loan")); $id=GETPOST("id", 'int'); $action=GETPOST('action', 'aZ09'); $confirm=GETPOST('confirm'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); @@ -271,7 +271,7 @@ print '
'; /* if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') + if ($user->socid == 0 && $payment->statut == 0 && $_GET['action'] == '') { if ($user->rights->facture->paiement) { diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 6742b0b1c04..742cf5ea5cf 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -38,9 +38,9 @@ $last=GETPOST('last'); // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $loan = new Loan($db); diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 6a1967bccf9..d8b5c7ed36e 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -379,7 +379,7 @@ class MailmanSpip return count($lists); } else - { + { $this->error="ADHERENT_MAILMAN_URL not defined"; return -1; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f522ad29fa8..efbe1a03a5e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1020,7 +1020,7 @@ $heightforframes=50; // Init menu manager if (! defined('NOREQUIREMENU')) { - if (empty($user->societe_id)) // If internal user or not defined + if (empty($user->socid)) // If internal user or not defined { $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED); } @@ -1048,7 +1048,7 @@ if (! defined('NOREQUIREMENU')) include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } - $menumanager = new MenuManager($db, empty($user->societe_id)?0:1); + $menumanager = new MenuManager($db, empty($user->socid)?0:1); $menumanager->loadMenu(); } @@ -1277,7 +1277,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (GETPOSTISSET('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } if (GETPOSTISSET('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } if (GETPOSTISSET('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } - if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) { $themeparam.='&THEME_AGRESSIVITY_RATIO='.GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); } + if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) { $themeparam.='&THEME_AGRESSIVENESS_RATIO='.GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); } if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { @@ -1984,7 +1984,7 @@ function top_menu_bookmark() */ function top_menu_search() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user, $hookmanager; $html = ''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 17caa1bf29e..e04a5e6ecc0 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -68,9 +68,9 @@ if (!empty($enddatemonth)) // Security check if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); + $agentid = GETPOST('agentid', 'int'); } else { - $agentid = $user->id; + $agentid = $user->id; } $result=restrictedArea($user, 'margins'); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 8d1e04cafd2..a25528f58fb 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -36,7 +36,7 @@ $socid = GETPOST('socid', 'int'); $TSelectedProducts = GETPOST('products', 'array'); $TSelectedCats = GETPOST('categories', 'array'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'margins'); @@ -360,7 +360,7 @@ if ($result) print "
\n"; print "\n"; - print "
+ > " - + > " - + > trans("Examples").":
"; ?> @@ -214,19 +217,15 @@ if (! empty($force_install_message)) - + + >
trans("CheckToForceHttps"); ?>
trans("DatabaseName"); ?> trans("ServerAddressDescription"); ?> @@ -360,9 +353,7 @@ if (! empty($force_install_message)) name="db_port" id="db_port" value="" - + > trans("ServerPortDescription"); ?> @@ -377,9 +368,7 @@ if (! empty($force_install_message)) id="db_prefix" name="db_prefix" value="" - + > trans("DatabasePrefixDescription"); ?> trans("CheckToCreateDatabase"); ?> @@ -410,9 +395,7 @@ if (! empty($force_install_message)) id="db_user" name="db_user" value="" - + > trans("AdminLogin"); ?> trans("AdminPassword"); ?> trans("CheckToCreateUser"); ?> @@ -478,9 +456,7 @@ if (! empty($force_install_message)) name="db_user_root" class="needroot" value="" - 0 && ! empty($force_install_databaserootlogin)) { - print ' disabled'; - } ?> + 0 && ! empty($force_install_databaserootlogin)) { print ' disabled'; } ?> > trans("DatabaseRootLoginDescription"); ?> @@ -516,9 +492,7 @@ if (! empty($force_install_message)) } // Do not autofill password for remote access print dol_escape_htmltag($autofill); ?>" - 0 && ! empty($force_install_databaserootpass)) { - print ' disabled'; // May be removed by javascript - } ?> + 0 && ! empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ } ?> > trans("KeepEmptyIfNoPassword"); ?> diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index abc961b49d5..406bfe88dbc 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -119,6 +119,14 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modified','Executed when a intervention is modified','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_VALIDATE','BOM validated','Executed when a BOM is validated','bom',400); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_UNVALIDATE','BOM unvalidated','Executed when a BOM is unvalidated','bom',401); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',402); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',403); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',404); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',410); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',411); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',412); -- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 2b71fbb1321..d5d46aea152 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -46,9 +46,13 @@ UPDATE llx_c_units SET scale = -3, active = 0 WHERE code IN ('L'); UPDATE llx_c_units SET label = 'VolumeUnitm3' WHERE code IN ('M3'); UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2'); +ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle, entity); + -- For v11 +ALTER TABLE llx_don ADD COLUMN fk_user_modif integer; + ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line); ALTER TABLE llx_rights_def ADD COLUMN module_position INTEGER NOT NULL DEFAULT 0; @@ -58,6 +62,9 @@ UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND modu ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; +ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; +ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; + ALTER TABLE llx_bom_bomline DROP COLUMN rank; create table llx_categorie_warehouse @@ -334,3 +341,93 @@ create table llx_fichinterdet_rec ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type; ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start; +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_parcel_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; + +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; + + +CREATE TABLE llx_mrp_mo( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + qty real NOT NULL, + fk_warehouse integer, + fk_soc integer, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + fk_product integer NOT NULL, + date_start_planned datetime, + date_end_planned datetime, + fk_bom integer, + fk_project integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + + +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT fk_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_end_planned (date_end_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_bom (fk_bom); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_project (fk_project); + + +create table llx_mrp_mo_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_fk_object(fk_object); + + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_VALIDATE','BOM validated','Executed when a BOM is validated','bom',400); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_UNVALIDATE','BOM unvalidated','Executed when a BOM is unvalidated','bom',401); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',402); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',403); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',404); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',410); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',411); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',412); + +ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index 330f1bb18d6..3fa1c2be528 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -22,6 +22,8 @@ CREATE TABLE llx_bom_bomline( description text, import_key varchar(14), qty double(24,8) NOT NULL, + qty_frozen smallint DEFAULT 0, + disable_stock_change smallint DEFAULT 0, efficiency double(8,4) NOT NULL DEFAULT 1, position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS diff --git a/htdocs/install/mysql/tables/llx_c_shipment_package_type b/htdocs/install/mysql/tables/llx_c_shipment_package_type new file mode 100644 index 00000000000..e510352eba2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_shipment_package_type @@ -0,0 +1,9 @@ +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_comment.sql b/htdocs/install/mysql/tables/llx_comment.sql index d881c84c0e3..22b2c40b9f1 100644 --- a/htdocs/install/mysql/tables/llx_comment.sql +++ b/htdocs/install/mysql/tables/llx_comment.sql @@ -22,6 +22,7 @@ CREATE TABLE llx_comment ( tms timestamp, description text NOT NULL, fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, fk_element integer DEFAULT NULL, element_type varchar(50) DEFAULT NULL, entity integer DEFAULT 1, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index ee17fdd1e67..f03e82d6143 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -47,6 +47,7 @@ create table llx_don fk_projet integer NULL, -- Donation is given for a project ? datec datetime, -- Create date fk_user_author integer NOT NULL, + fk_user_modif integer, date_valid datetime, -- date de validation fk_user_valid integer NULL, note_private text, diff --git a/htdocs/install/mysql/tables/llx_expedition_package.sql b/htdocs/install/mysql/tables/llx_expedition_package.sql new file mode 100644 index 00000000000..2f8d97a26a9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_expedition_package.sql @@ -0,0 +1,18 @@ +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_package_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; diff --git a/htdocs/mrp/sql/llx_mrp_mo.key.sql b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql similarity index 87% rename from htdocs/mrp/sql/llx_mrp_mo.key.sql rename to htdocs/install/mysql/tables/llx_mrp_mo.key.sql index 071a663dd56..5c218763ff6 100644 --- a/htdocs/mrp/sql/llx_mrp_mo.key.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql @@ -15,12 +15,10 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_rowid (rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); -ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_qty (qty); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); -ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT fk_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); diff --git a/htdocs/mrp/sql/llx_mrp_mo.sql b/htdocs/install/mysql/tables/llx_mrp_mo.sql similarity index 96% rename from htdocs/mrp/sql/llx_mrp_mo.sql rename to htdocs/install/mysql/tables/llx_mrp_mo.sql index dbb8b0faa01..52a046191dc 100644 --- a/htdocs/mrp/sql/llx_mrp_mo.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.sql @@ -20,7 +20,8 @@ CREATE TABLE llx_mrp_mo( ref varchar(128) DEFAULT '(PROV)' NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), - qty real NOT NULL, + qty real NOT NULL, + fk_warehouse integer, fk_soc integer, note_public text, note_private text, diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql b/htdocs/install/mysql/tables/llx_mrp_mo_extrafields.key.sql similarity index 100% rename from htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_mrp_mo_extrafields.key.sql diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql b/htdocs/install/mysql/tables/llx_mrp_mo_extrafields.sql similarity index 100% rename from htdocs/mrp/sql/llx_mrp_mo_extrafields.sql rename to htdocs/install/mysql/tables/llx_mrp_mo_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.key.sql new file mode 100644 index 00000000000..b0d9345b604 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2011 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_product_fournisseur_price_extrafields ADD INDEX idx_product_fournisseur_price_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.sql new file mode 100644 index 00000000000..51d5499e825 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price_extrafields.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Copyright (C) 2011 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +Create Table llx_product_fournisseur_price_extrafields ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 517b5843f30..b46e9713983 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1297,7 +1297,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { $listofmods.=($listofmods?',':'')."'".$val."'"; } - $sql = 'SELECT id, libelle, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000'; + $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000'; $resql = $db->query($sql); if ($resql) { @@ -1310,7 +1310,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) $obj=$db->fetch_object($resql); if ($obj->id > 0) { - print '
Found line with id '.$obj->id.', label "'.$obj->libelle.'" of module "'.$obj->module.'" to delete'; + print '
Found line with id '.$obj->id.', label "'.$obj->label.'" of module "'.$obj->module.'" to delete'; if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') { $sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 39e14283a40..0787c84762b 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -64,7 +64,10 @@ $error = 0; // Ne fonctionne que si on est pas en safe_mode. $err=error_reporting(); error_reporting(0); -@set_time_limit(300); +if (! empty($conf->global->MAIN_OVERRIDE_TIME_LIMIT)) + @set_time_limit((int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT); +else + @set_time_limit(600); error_reporting($err); $setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):'auto'; diff --git a/htdocs/langs/de_DE/products.lang b/htdocs/langs/de_DE/products.lang index 6b163a857c8..13c61b3fa67 100644 --- a/htdocs/langs/de_DE/products.lang +++ b/htdocs/langs/de_DE/products.lang @@ -341,3 +341,4 @@ ErrorDestinationProductNotFound=Zielprodukt nicht gefunden ErrorProductCombinationNotFound=Produktvariante nicht gefunden ActionAvailableOnVariantProductOnly=Action only available on the variant of product ProductsPricePerCustomer=Product prices per customers +ProductSupplierExtraFields=Ergänzende Attribute (Lieferantenpreise) \ No newline at end of file diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 0acd25ec536..f7ed7bcade0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -175,6 +175,7 @@ DraftBills=Draft invoices CustomersDraftInvoices=Customer draft invoices SuppliersDraftInvoices=Vendor draft invoices Unpaid=Unpaid +ErrorNoPaymentDefined=Error No payment defined ConfirmDeleteBill=Are you sure you want to delete this invoice? ConfirmValidateBill=Are you sure you want to validate this invoice with reference %s? ConfirmUnvalidateBill=Are you sure you want to change invoice %s to draft status? diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index eee7d7dcfac..a55a0194632 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -44,6 +44,8 @@ BoxTitleLastActionsToDo=Latest %s actions to do BoxTitleLastContracts=Latest %s modified contracts BoxTitleLastModifiedDonations=Latest %s modified donations BoxTitleLastModifiedExpenses=Latest %s modified expense reports +BoxTitleLatestModifiedBoms=Latest %s modified BOMs +BoxTitleLatestModifiedMos=Latest %s modified Manufacturing Orders BoxGlobalActivity=Global activity (invoices, proposals, orders) BoxGoodCustomers=Good customers BoxTitleGoodCustomers=%s Good customers diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 5edc8d62033..a810c61c8f4 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -17,6 +17,7 @@ DonationStatusPromiseNotValidatedShort=Draft DonationStatusPromiseValidatedShort=Validated DonationStatusPaidShort=Received DonationTitle=Donation receipt +DonationDate=Donation date DonationDatePayment=Payment date ValidPromess=Validate promise DonationReceipt=Donation receipt diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index e7667ef6946..e65b966ea09 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -60,6 +60,7 @@ InterDateCreation=Date creation intervention InterDuration=Duration intervention InterStatus=Status intervention InterNote=Note intervention +InterLine=Line of intervention InterLineId=Line id intervention InterLineDate=Line date intervention InterLineDuration=Line duration intervention diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 656f6fb7a28..6e3ba31d36c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -114,6 +114,7 @@ InformationToHelpDiagnose=This information can be useful for diagnostic purposes MoreInformation=More information TechnicalInformation=Technical information TechnicalID=Technical ID +LineID=Line ID NotePublic=Note (public) NotePrivate=Note (private) PrecisionUnitIsLimitedToXDecimals=Dolibarr was setup to limit precision of unit prices to %s decimals. @@ -183,6 +184,7 @@ Hide=Hide ShowCardHere=Show card Search=Search SearchOf=Search +SearchMenuShortCut=Ctrl + shift + f Valid=Valid Approve=Approve Disapprove=Disapprove @@ -476,7 +478,9 @@ Categories=Tags/categories Category=Tag/category By=By From=From +FromLocation=From to=to +To=to and=and or=or Other=Other diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index a1c35515f9d..d14aa8a3c71 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -6,7 +6,7 @@ ModuleBuilderDesc2=Path where modules are generated/edited (first directory for ModuleBuilderDesc3=Generated/editable modules found: %s ModuleBuilderDesc4=A module is detected as 'editable' when the file %s exists in root of module directory NewModule=New module -NewObject=New object +NewObjectInModulebuilder=New object ModuleKey=Module key ObjectKey=Object key ModuleInitialized=Module initialized @@ -60,12 +60,14 @@ HooksFile=File for hooks code ArrayOfKeyValues=Array of key-val ArrayOfKeyValuesDesc=Array of keys and values if field is a combo list with fixed values WidgetFile=Widget file +CSSFile=CSS file +JSFile=Javascript file ReadmeFile=Readme file ChangeLog=ChangeLog file TestClassFile=File for PHP Unit Test class SqlFile=Sql file -PageForLib=File for PHP library -PageForObjLib=File for PHP library dedicated to object +PageForLib=File for the common PHP library +PageForObjLib=File for the PHP library dedicated to object SqlFileExtraFields=Sql file for complementary attributes SqlFileKey=Sql file for keys SqlFileKeyExtraFields=Sql file for keys of complementary attributes @@ -77,6 +79,7 @@ NoTrigger=No trigger NoWidget=No widget GoToApiExplorer=Go to API explorer ListOfMenusEntries=List of menu entries +ListOfDictionariesEntries=List of dictionaries entries ListOfPermissionsDefined=List of defined permissions SeeExamples=See examples here EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) @@ -86,8 +89,10 @@ SearchAllDesc=Is the field used to make a search from the quick search tool? (Ex SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. LanguageDefDesc=Enter in this files, all the key and the translation for each language file. MenusDefDesc=Define here the menus provided by your module +DictionariesDefDesc=Define here the dictionaries provided by your module PermissionsDefDesc=Define here the new permissions provided by your module MenusDefDescTooltip=The menus provided by your module/application are defined into the array $this->menus into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), menus are also visible into the menu editor available to administrator users on %s. +DictionariesDefDescTooltip=The dictionaries provided by your module/application are defined into the array $this->dictionaries into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), dictionaries are also visible into the setup area to administrator users on %s. PermissionsDefDescTooltip=The permissions provided by your module/application are defined into the array $this->rights into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), permissions are visible into the default permissions setup %s. HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed. @@ -109,6 +114,8 @@ ContentOfREADMECustomized=Note: The content of the README.md file has been repla RealPathOfModule=Real path of module ContentCantBeEmpty=Content of file can't be empty WidgetDesc=You can generate and edit here the widgets that will be embedded with your module. +CSSDesc=You can generate and edit here a file with personalized CSS embedded with your module. +JSDesc=You can generate and edit here a file with personalized Javascript embedded with your module. CLIDesc=You can generate here some command line scripts you want to provide with your module. CLIFile=CLI File NoCLIFile=No CLI files @@ -117,4 +124,14 @@ UseSpecificEditorURL = Use a specific editor URL UseSpecificFamily = Use a specific family UseSpecificAuthor = Use a specific author UseSpecificVersion = Use a specific initial version -ModuleMustBeEnabled=The module/application must be enabled first \ No newline at end of file +ModuleMustBeEnabled=The module/application must be enabled first +IncludeRefGeneration=The reference of object must be generated automatically +IncludeRefGenerationHelp=Check this if you want to include code to manage the generation automatically of the reference +IncludeDocGeneration=I want to generate some documents from the object +IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record. +ShowOnCombobox=Show value into combobox +KeyForTooltip=Key for tooltip +CSSClass=CSS Class +NotEditable=Not editable +ForeignKey=Foreign key +TypeOfFieldsHelp=Type of fields:
varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]] ('1' means we add a + button after the combo to create the record, 'filter' can be 'status=1 AND fk_user = __USER_ID AND entity IN (__SHARED_ENTITIES__)' for example) \ No newline at end of file diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 5d51be56e56..bc71a65f72a 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -2,9 +2,10 @@ Mrp=Manufacturing Orders MO=Manufacturing Order MRPDescription=Module to manage Manufacturing Orders (MO). MRPArea=MRP Area -MrpSetupPage=Setup of module MO +MrpSetupPage=Setup of module MRP MenuBOM=Bills of material LatestBOMModified=Latest %s Bills of materials modified +LatestMOModified=Latest %s Manufacturing Orders modified Bom=Bills of Material BillOfMaterials=Bill of Material BOMsSetup=Setup of module BOM @@ -13,14 +14,21 @@ ListOfManufacturingOrders=List of Manufacturing Orders NewBOM=New bill of material ProductBOMHelp=Product to create with this BOM BOMsNumberingModules=BOM numbering templates -BOMsModelModule=BOMS document templates +BOMsModelModule=BOM document templates +MOsNumberingModules=MO numbering templates +MOsModelModule=MO document templates FreeLegalTextOnBOMs=Free text on document of BOM WatermarkOnDraftBOMs=Watermark on draft BOM -ConfirmCloneBillOfMaterials=Are you sure you want to clone this bill of material ? +FreeLegalTextOnMOs=Free text on document of MO +WatermarkOnDraftMOs=Watermark on draft MO +ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of material %s ? +ConfirmCloneMo=Are you sure you want to clone the Manufacturing Order %s ? ManufacturingEfficiency=Manufacturing efficiency ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production DeleteBillOfMaterials=Delete Bill Of Materials +DeleteMo=Delete Manufacturing Order ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material? +ConfirmDeleteMo=Are you sure you want to delete this Bill Of Material? MenuMRP=Manufacturing Orders NewMO=New Manufacturing Order QtyToProduce=Qty to produce @@ -31,4 +39,13 @@ EstimatedDuration=Estimated duration EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM ConfirmValidateBom=Are you sure you want to validate the BOM with the reference %s (you will be able to use it to build new Manufacturing Orders) ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ? -ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) \ No newline at end of file +ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) +StatusMOProduced=Produced +QtyFrozen=Frozen Qty +QuantityFrozen=Frozen Quantity +QuantityConsumedInvariable=When this flag is set, the quantity consumed is always the value defined and is not relative to the quantity produced. +DisableStockChange=Disable stock change +DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced +BomAndBomLines=Bills Of Material and lines +BOMLine=Line of BOM +WarehouseForProduction=Warehouse for production \ No newline at end of file diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index a010a64b907..3d22b338166 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -11,6 +11,7 @@ OrderDate=Order date OrderDateShort=Order date OrderToProcess=Order to process NewOrder=New order +NewOrderSupplier=New Purchase Order ToOrder=Make order MakeOrder=Make order SupplierOrder=Purchase order @@ -70,6 +71,7 @@ DeleteOrder=Delete order CancelOrder=Cancel order OrderReopened= Order %s Reopened AddOrder=Create order +AddPurchaseOrder=Create purchase order AddToDraftOrders=Add to draft order ShowOrder=Show order OrdersOpened=Orders to process diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 480a2aa91e5..1ca335da637 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -292,6 +292,7 @@ ProductWeight=Weight for 1 product ProductVolume=Volume for 1 product WeightUnits=Weight unit VolumeUnits=Volume unit +SurfaceUnits=Surface unit SizeUnits=Size unit DeleteProductBuyPrice=Delete buying price ConfirmDeleteProductBuyPrice=Are you sure you want to delete this buying price? @@ -346,3 +347,4 @@ ErrorDestinationProductNotFound=Destination product not found ErrorProductCombinationNotFound=Product variant not found ActionAvailableOnVariantProductOnly=Action only available on the variant of product ProductsPricePerCustomer=Product prices per customers +ProductSupplierExtraFields=Additional Attributes (Supplier Prices) \ No newline at end of file diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index be758c04890..62ce5a23531 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -117,4 +117,5 @@ ImportSite=Import site EditInLineOnOff=Mode 'Edit inline' is %s ShowSubContainersOnOff=Mode to execute 'dynamic content' is %s GlobalCSSorJS=Global CSS/JS/Header file of web site -BackToHomePage=Back to home page... \ No newline at end of file +BackToHomePage=Back to home page... +TranslationLinks=Translation links \ No newline at end of file diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index b375a3e16e0..afeed4b318d 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -476,6 +476,7 @@ Category=Tag/catégorie By=Par From=Du to=au +To=à and=et or=ou Other=Autre diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index bf407b8fc90..3f6c6b493b1 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -56,7 +56,7 @@ $backtopage=GETPOST('backtopage', 'alpha'); // Security check $id = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'expedition', $id, 'livraison', 'livraison'); $object = new Livraison($db); @@ -559,7 +559,7 @@ else $entrepot = new Entrepot($db); $entrepot->fetch($object->entrepot_id); print '
'.$langs->trans("Warehouse").''.$entrepot->libelle.''.$entrepot->label.'
".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."
"; + print ""; } else { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f63067d6af8..cbc134c0b66 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -40,7 +40,7 @@ $TSelectedCats=GETPOST('categories', 'array'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $result=restrictedArea($user, 'margins'); @@ -103,13 +103,13 @@ dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print ''; if ($id > 0) { - print ''; - print ''; + print ''; + print ''; - if (! $sortorder) $sortorder="DESC"; - if (! $sortfield) $sortfield="f.datef"; + if (! $sortorder) $sortorder="DESC"; + if (! $sortfield) $sortfield="f.datef"; } else { print ''; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 0ad3f2f645b..d9677ffa4da 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -36,7 +36,7 @@ $confirm=GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); + dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref'); print '
'; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index c5d1f0d1e0b..1edd5349467 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -30,7 +30,7 @@ $langs->loadLangs(array("companies", "bills", "products", "margins")); // Security check $socid = GETPOST('socid', 'int'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'societe', '', ''); @@ -90,7 +90,7 @@ if ($socid > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 970d4841fbf..3879efa2030 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2018-2019 Nicolas ZABOURI * * This program is free software; you can redistribute it and/or modify @@ -153,6 +153,12 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/class/api_'.strtolower($modulename).'.class.php'); dol_delete_dir($destdir.'/class'); + dol_delete_file($destdir.'/css/'.strtolower($modulename).'.css.php'); + dol_delete_dir($destdir.'/css'); + + dol_delete_file($destdir.'/js/'.strtolower($modulename).'.js.php'); + dol_delete_dir($destdir.'/js'); + dol_delete_file($destdir.'/scripts/'.strtolower($modulename).'.php'); dol_delete_dir($destdir.'/scripts'); @@ -163,7 +169,7 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/myobject_agenda.php'); dol_delete_file($destdir.'/myobject_list.php'); dol_delete_file($destdir.'/lib/'.strtolower($modulename).'_myobject.lib.php'); - dol_delete_file($destdir.'/test/phpunit/MyObjectFunctionnalTest.php'); + dol_delete_file($destdir.'/test/phpunit/MyModuleFunctionnalTest.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); dol_delete_file($destdir.'/test/phpunit'); dol_delete_file($destdir.'/test'); @@ -259,6 +265,11 @@ if ($dirins && $action == 'initapi' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initphpunit' && !empty($module)) { @@ -270,9 +281,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) $srcfile = $srcdir.'/test/phpunit/MyObjectTest.php'; $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php'; $result = dol_copy($srcfile, $destfile, 0, 0); - /*$srcfile = $srcdir.'/test/phpunit/MyModuleFunctionnalTest.class.php'; - $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($module).'FunctionnalTest.class.php'; - $result = dol_copy($srcfile, $destfile, 0, 0);*/ + if ($result > 0) { //var_dump($phpfileval['fullname']); @@ -295,6 +304,8 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) } else { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } if ($dirins && $action == 'initsqlextrafields' && !empty($module)) @@ -327,13 +338,21 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), + 'My Object'=>$objectname, + 'MyObject'=>$objectname, + 'my object'=>strtolower($objectname), + 'myobject'=>strtolower($objectname), '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); dolReplaceInFile($destfile1, $arrayreplacement); dolReplaceInFile($destfile2, $arrayreplacement); } - + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', ''), null, 'errors'); + } // TODO Enable in class the property $isextrafieldmanaged = 1 } if ($dirins && $action == 'inithook' && !empty($module)) @@ -364,6 +383,11 @@ if ($dirins && $action == 'inithook' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'inittrigger' && !empty($module)) { @@ -393,6 +417,11 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initwidget' && !empty($module)) { @@ -422,6 +451,89 @@ if ($dirins && $action == 'initwidget' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } +} +if ($dirins && $action == 'initcss' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/css'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/css/mymodule.css.php'; + $destfile = $dirins.'/'.strtolower($module).'/css/'.strtolower($module).'.css.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':''), + ); + + dolReplaceInFile($destfile, $arrayreplacement); + + // Update descriptor file to uncomment file + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/\/\/\s*\''.preg_quote('/'.strtolower($module).'/css/'.strtolower($module).'.css.php', '/').'\'/' => '\'/'.strtolower($module).'/css/'.strtolower($module).'.css.php\''); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); + } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } +} +if ($dirins && $action == 'initjs' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/js'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/js/mymodule.js.php'; + $destfile = $dirins.'/'.strtolower($module).'/js/'.strtolower($module).'.js.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + + // Update descriptor file to uncomment file + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/\/\/\s*\''.preg_quote('/'.strtolower($module).'/js/'.strtolower($module).'.js.php', '/').'\'/' => '\'/'.strtolower($module).'/js/'.strtolower($module).'.js.php\''); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); + } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initcli' && !empty($module)) { @@ -456,6 +568,11 @@ if ($dirins && $action == 'initcli' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initdoc' && !empty($module)) { @@ -502,6 +619,11 @@ if ($dirins && $action == 'initdoc' && !empty($module)) dol_delete_file($outputfiledoc, 0, 0, 0, null, false, 0); dol_delete_file($outputfiledocpdf, 0, 0, 0, null, false, 0); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'addlanguage' && !empty($module)) @@ -523,6 +645,14 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) $result = dol_delete_file($filetodelete); if (dol_is_dir_empty($dirtodelete)) dol_delete_dir($dirtodelete); + + // Update descriptor file to comment file + if (in_array($tab, array('css', 'js'))) + { + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); + } } } @@ -595,12 +725,15 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', // visible $visible = -1; if ($fieldname == 'entity') $visible = -2; - if ($fieldname == 'model_pdf') $visible = 0; + if (in_array($fieldname, array('model_pdf', 'note_public', 'note_private'))) $visible = 0; // enabled $enabled = 1; // default $default = ''; if ($fieldname == 'entity') $default=1; + // position + $position = $i; + if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) $position = 500; $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; if ($default != '') $string.= " 'default'=>".$default.","; @@ -608,7 +741,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $string.= " 'visible'=>".$visible; if ($notnull) $string.= ", 'notnull'=>".$notnull; if ($fieldname == 'ref') $string.= ", 'showoncombobox'=>1"; - $string.= ", 'position'=>".$i."),\n"; + $string.= ", 'position'=>".$position."),\n"; $string.="
"; $i+=5; } @@ -668,14 +801,35 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php', //'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php', 'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql', - 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', 'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql', + 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_mymodule_myobject_extrafields.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.key.sql', //'scripts/mymodule.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', //'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php', ); + if (GETPOST('includerefgeneration', 'aZ09')) + { + dol_mkdir($destdir.'/core/modules/'.strtolower($module)); + + $filetogenerate += array( + 'core/modules/mymodule/mod_myobject_advanced.php'=>'core/modules/'.strtolower($module).'/mod_'.strtolower($objectname).'_advanced.php', + 'core/modules/mymodule/mod_myobject_standard.php'=>'core/modules/'.strtolower($module).'/mod_'.strtolower($objectname).'_standard.php', + 'core/modules/mymodule/modules_myobject.php'=>'core/modules/'.strtolower($module).'/modules_'.strtolower($objectname).'.php', + ); + } + if (GETPOST('includedocgeneration', 'aZ09')) + { + dol_mkdir($destdir.'/core/modules/'.strtolower($module)); + dol_mkdir($destdir.'/core/modules/'.strtolower($module).'/doc'); + + $filetogenerate += array( + 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>'core/modules/'.strtolower($module).'/doc/doc_generic_'.strtolower($objectname).'_odt.modules.php' + ); + } + foreach($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); @@ -694,8 +848,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - //if (! $error) // If there is error copying 1 file, we still have to make the replacement - //{ + // Edit the class 'class/'.strtolower($objectname).'.class.php' + if (GETPOST('includerefgeneration', 'aZ09')) { + // Replace 'visible'=>1, 'noteditable'=>0, 'default'=>'' + $arrayreplacement = array('/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' => "'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"); + //var_dump($arrayreplacement);exit; + //var_dump($destdir.'/class/'.strtolower($objectname).'.class.php');exit; + dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1); + } + + // Edit the setup file and the card page + if (GETPOST('includedocgeneration', 'aZ09')) { + // TODO + // dolReplaceInFile(); + } + // Scan for object class files $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); @@ -768,15 +935,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) // Add module descriptor to list of files to replace "MyObject' string with real name of object. $filetogenerate[]='core/modules/mod'.$module.'.class.php'; - - // TODO } - //} } if (! $error) { - // Edit PHP files + // Edit PHP files to make replacement foreach($filetogenerate as $destfile) { $phpfileval['fullname'] = $destdir.'/'.$destfile; @@ -821,6 +985,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) if (! $error) { setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); + $tabobj = $objectname; } } @@ -989,7 +1154,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) } } -if ($dirins && $action == 'confirm_delete') +if ($dirins && $action == 'confirm_deletemodule') { if (preg_match('/[^a-z0-9_]/i', $module)) { @@ -1016,8 +1181,6 @@ if ($dirins && $action == 'confirm_delete') } } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; $action = ''; $module = 'deletemodule'; } @@ -1039,26 +1202,30 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) $dir = $dirins.'/'.$modulelowercase; // Delete some files - $filetogenerate = array( - 'myobject_card.php'=>strtolower($objectname).'_card.php', - 'myobject_note.php'=>strtolower($objectname).'_note.php', - 'myobject_document.php'=>strtolower($objectname).'_document.php', - 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', - 'myobject_list.php'=>strtolower($objectname).'_list.php', - 'lib/mymodule.lib.php'=>'lib/'.strtolower($module).'.lib.php', - 'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php', - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php', - 'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql', - 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', - 'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', - 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', - 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', - 'class/api_myobject.class.php'=>'class/api_'.strtolower($module).'.class.php' + $filetodelete = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_note.php'=>strtolower($objectname).'_note.php', + 'myobject_document.php'=>strtolower($objectname).'_document.php', + 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php', + 'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql', + 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql', + 'sql/llx_mymodule_myobject_extrafields.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.key.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($module).'.class.php', + 'core/modules/mymodule/mod_myobject_advanced.php'=>'core/modules/'.strtolower($module).'/mod_'.strtolower($objectname).'_advanced.php', + 'core/modules/mymodule/mod_myobject_standard.php'=>'core/modules/'.strtolower($module).'/mod_'.strtolower($objectname).'_standard.php', + 'core/modules/mymodule/modules_myobject.php'=>'core/modules/'.strtolower($module).'/modules_'.strtolower($objectname).'.php', + 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>'core/modules/'.strtolower($module).'/doc/doc_generic_'.strtolower($objectname).'_odt.modules.php' ); $resultko = 0; - foreach($filetogenerate as $filetodelete) + foreach($filetodelete as $filetodelete) { $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); if (! $resulttmp) $resultko++; @@ -1074,8 +1241,6 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) } } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; $action = ''; $tabobj = 'deleteobject'; } @@ -1302,6 +1467,7 @@ if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >=2 || // Search modules to edit print ''."\n"; $listofmodules=array(); +$i=0; foreach($dirsrootforscan as $dirread) { $dirsincustom=dol_dir_list($dirread, 'directories'); @@ -1359,8 +1525,12 @@ foreach($dirsrootforscan as $dirread) if (empty($newdircustom)) $newdircustom=img_warning(); // If dirread was forced to somewhere else, by using URL // htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product - print $langs->trans("DirScanned").' : '.$dirread.'
'; + if (empty($i)) print $langs->trans("DirScanned").' : '; + else print ', '; + print ''.$dirread.''; + $i++; } +print '
'; //var_dump($listofmodules); $message=''; @@ -1392,7 +1562,7 @@ if ($message) } //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; -$infomodulesfound = '
'.$form->textwithpicto($langs->trans("ModuleBuilderDesc3", count($listofmodules)), $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
'; +$infomodulesfound = '
'.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
'; // Load module descriptor @@ -1467,16 +1637,17 @@ if ($module == 'initmodule') print $langs->trans("EnterNameOfModuleDesc").'
'; print '
'; - print ''; + print '
'; - print ''; + print '
'; print ''; } elseif ($module == 'deletemodule') { + print ''."\n"; print '
'; print ''; - print ''; + print ''; print ''; print $langs->trans("EnterNameOfModuleToDeleteDesc").'

'; @@ -1507,23 +1678,23 @@ elseif (! empty($module)) $linktoenabledisable=''; if (! empty($conf->global->$const_name)) // If module is already activated { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on'); + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); $linktoenabledisable.=''; } else { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off'); + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', 1); $linktoenabledisable.="\n"; } - if (! empty($conf->$modulelowercase->enabled)) + if (empty($conf->$modulelowercase->enabled)) { - $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); + $modulestatusinfo=$form->textwithpicto($langs->trans("ModuleIsNotActive", $urltomodulesetup), '', -1, 'help'); } else { - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); + $modulestatusinfo=$form->textwithpicto($langs->trans("ModuleIsLive"), $langs->trans("Warning"), -1, 'warning'); } $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); @@ -1536,6 +1707,11 @@ elseif (! empty($module)) $head2[$h][2] = 'languages'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Dictionaries"); + $head2[$h][2] = 'dictionaries'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; @@ -1566,6 +1742,16 @@ elseif (! empty($module)) $head2[$h][2] = 'widgets'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("CSS"); + $head2[$h][2] = 'css'; + $h++; + + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=js&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("JS"); + $head2[$h][2] = 'js'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cli&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("CLI"); $head2[$h][2] = 'cli'; @@ -1588,13 +1774,8 @@ elseif (! empty($module)) // Link to enable / disable print $modulestatusinfo; - print ' '.$linktoenabledisable; - print '
'; + print ' '.$linktoenabledisable.'
'; - if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) - { - print ''.$langs->trans("RealPathOfModule").' : '.realpath($dirread.'/'.$modulelowercase).'
'; - } print '
'; if ($tab == 'description') @@ -1607,21 +1788,28 @@ elseif (! empty($module)) { dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 - print ''.$langs->trans("ModuleBuilderDesc".$tab).'

'; + print ''.$langs->trans("ModuleBuilderDesc".$tab).''; + $infoonmodulepath = ''; + if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) + { + $infoonmodulepath = ''.$langs->trans("RealPathOfModule").' : '.realpath($dirread.'/'.$modulelowercase).'
'; + print ' '.$infoonmodulepath; + } + print '
'; print '
'.$langs->trans('ChooseProduct/Service').''; - print $form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All'); - print '
'.$langs->trans('ChooseProduct/Service').''; + print $form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All'); + print '
'.$langs->trans('ChooseProduct/Service').'
'; print ''; print ''; print ''; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -1782,8 +1970,8 @@ elseif (! empty($module)) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } print ''; @@ -1819,6 +2007,142 @@ elseif (! empty($module)) } } + if ($tab == 'dictionaries') + { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $dicts = $moduleobj->dictionaries; + + if ($action != 'editfile' || empty($file)) + { + print ''; + $htmlhelp=$langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').''); + print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; + print '
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("LanguageFile").' : '; + if (! is_array($dicts) || empty($dicts)) print ''.$langs->trans("NoDictionaries").''; + else print ''.$dicts['langs'].''; + print '
'; + + print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQLSort", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsView", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsEdit", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsInsert", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Rowid", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; + + if (is_array($dicts)) + { + $i = 0; + $maxi = count($dicts['tabname']); + while ($i < $maxi) + { + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + else + { + print ''; + } + + print '
'; + print ($i + 1); + print ''; + print $dicts['tabname'][$i]; + print ''; + print $dicts['tablib'][$i]; + print ''; + print $dicts['tabsql'][$i]; + print ''; + print $dicts['tabsqlsort'][$i]; + print ''; + print $dicts['tabfield'][$i]; + print ''; + print $dicts['tabfieldvalue'][$i]; + print ''; + print $dicts['tabfieldinsert'][$i]; + print ''; + print $dicts['tabrowid'][$i]; + print ''; + print $dicts['tabcond'][$i]; + print '
'.$langs->trans("None").'
'; + print '
'; + + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'objects') { $head3 = array(); @@ -1828,7 +2152,7 @@ elseif (! empty($module)) $dir = $dirread.'/'.$modulelowercase.'/class'; $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; - $head3[$h][1] = $langs->trans("NewObject"); + $head3[$h][1] = ''.$langs->trans("NewObjectInModulebuilder").''; $head3[$h][2] = 'newobject'; $h++; @@ -1880,7 +2204,9 @@ elseif (! empty($module)) print ''.$langs->trans("EnterNameOfObjectDesc").'

'; - print ''; + print '
'; + print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'
'; + print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'
'; print ''; print '
'; print '
'; @@ -1888,7 +2214,6 @@ elseif (! empty($module)) print $langs->trans("or"); print '
'; print '
'; - print '
'; //print ' '; print $langs->trans("InitStructureFromExistingTable"); print ''; @@ -1973,14 +2298,14 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; if ($realpathtoapi) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; if (empty($conf->global->$const_name)) // If module is not activated { @@ -1994,7 +2319,7 @@ elseif (! empty($module)) else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } // PHPUnit print '
'; @@ -2002,24 +2327,24 @@ elseif (! empty($module)) if ($realpathtophpunit) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } print '
'; print '
'; print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtolib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForObjLib").' : '.($realpathtoobjlib?'':'').$pathtoobjlib.($realpathtoobjlib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("Image").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; //print ' '.img_picto($langs->trans("Edit"), 'edit').''; @@ -2027,34 +2352,34 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("DropTableIfEmpty").''; //print '   '.$langs->trans("RunSql").''; print '
'; + print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + //print '   '.$langs->trans("RunSql").''; + print '
'; print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; if ($realpathtosqlextra) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; - print ''.$langs->trans("DropTableIfEmpty").''; + print ''.$langs->trans("DropTableIfEmpty").''; } else { - print ''; + print ''; } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - //print '   '.$langs->trans("RunSql").''; - print '
'; print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey?'':'').$pathtosqlextrakey.($realpathtosqlextrakey?'':'').''; if ($realpathtosqlextrakey) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } //print '   '.$langs->trans("RunSql").''; print '
'; @@ -2067,33 +2392,33 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("PageForList").' : '.($realpathtolist?'':'').$pathtolist.($realpathtolist?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtoagenda) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtodocument) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtonote) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; @@ -2151,7 +2476,7 @@ elseif (! empty($module)) print load_fiche_titre($langs->trans("ObjectProperties"), '', ''); - + print ''."\n"; print '
'; print ''; print ''; @@ -2161,16 +2486,22 @@ elseif (! empty($module)) print ''; - print ''; print ''; print ''; print ''; print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; print ''; print ''; print ''; @@ -2191,11 +2522,17 @@ elseif (! empty($module)) print ''; print ''; print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; print ''; print ''; @@ -2239,7 +2582,7 @@ elseif (! empty($module)) print ''; - print ''; print ''; + print ''; print ''; @@ -2266,16 +2612,34 @@ elseif (! empty($module)) print $propvisible?$propvisible:''; print ''; print ''; print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ print ''; print ''; print ''; @@ -2402,7 +2766,7 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -2428,9 +2792,9 @@ elseif (! empty($module)) print_liste_field_titre("LanguageFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Position", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Enabled", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("perms", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Permission", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'right '); print "\n"; if (count($menus)) @@ -2483,7 +2847,7 @@ elseif (! empty($module)) print $menu['target']; print ''; - print ''; @@ -2542,7 +2906,7 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -2639,7 +3003,7 @@ elseif (! empty($module)) $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; print ''; - print ''; + print ''; + print ''; } else { @@ -2706,8 +3070,8 @@ elseif (! empty($module)) print ''; - print ''; + print ''; + print ''; print ''; } } @@ -2747,6 +3111,110 @@ elseif (! empty($module)) } } + if ($tab == 'css') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("CSSDesc").'
'; + print '
'; + + print '
'; print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); print ''.$langs->trans("Type").''; + print ''.$form->textwithpicto($langs->trans("Type"), $langs->trans("TypeOfFieldsHelp")).''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''.$form->textwithpicto($langs->trans("NotNull"), $langs->trans("NotNullDesc")).''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("ForeignKey").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$langs->trans("NotEditable").''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$langs->trans("CSSClass").''.$langs->trans("KeyForTooltip").''.$langs->trans("ShowOnCombobox").''.$langs->trans("Disabled").''.$langs->trans("Comment").'
'; print ''; @@ -2222,13 +2559,19 @@ elseif (! empty($module)) $proptype=$propval['type']; $proparrayofkeyval=$propval['arrayofkeyval']; $propnotnull=$propval['notnull']; - $propsearchall=$propval['searchall']; $propdefault=$propval['default']; $propindex=$propval['index']; + $propforeignkey=$propval['foreignkey']; $propposition=$propval['position']; $propenabled=$propval['enabled']; $propvisible=$propval['visible']; + $propnoteditable=$propval['noteditable']; + $propsearchall=$propval['searchall']; $propisameasure=$propval['isameasure']; + $propcss=$propval['css']; + $prophelp=$propval['help']; + $propshowoncombobox=$propval['showoncombobox']; + //$propdisabled=$propval['disabled']; $propcomment=$propval['comment']; print '
'; print $proplabel; print ''; + print ''; print $proptype; print ''; @@ -2256,6 +2599,9 @@ elseif (! empty($module)) print ''; print $propindex?'1':''; print ''; + print $propforeignkey?$propforeignkey:''; + print ''; print $propposition; print ''; - print $propisameasure?$propisameasure:''; + print $propnoteditable?$propnoteditable:''; print ''; print $propsearchall?'1':''; print ''; + print $propisameasure?$propisameasure:''; + print ''; + print $propcss?$propcss:''; + print ''; + print $prophelp?$prophelp:''; + print ''; + print $propshowoncombobox?$propshowoncombobox:''; + print ''; + print $propdisabled?$propdisabled:''; + print ''; print $propcomment; print ''; - print ''.img_delete().''; + if ($propname != 'rowid') + { + print ''.img_delete().''; + } print '
'; + print ''; print $menu['user']; print ''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -2648,8 +3012,8 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + + print ''; + print ''; + } + else + { + print ''.$langs->trans("FileNotYetGenerated").''; + print ''; + } + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ''; + } + } + + if ($tab == 'js') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("JSDesc").'
'; + print '
'; + + print '
'; + $pathtohook = strtolower($module).'/css/'.strtolower($module).'.css.php'; + print ' '.$langs->trans("CSSFile").' : '; + if (dol_is_file($dirins.'/'.$pathtohook)) + { + print ''.$pathtohook.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + + print ''; + print ''; + } + else + { + print ''.$langs->trans("FileNotYetGenerated").''; + print ''; + } + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ''; + } + } + if ($tab == 'widgets') { require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -2766,9 +3234,8 @@ elseif (! empty($module)) $pathtofile = $widget['relpath']; print ''; - print ''; + print ''; print ''; } } @@ -2853,8 +3320,8 @@ elseif (! empty($module)) $pathtofile = $clifile['relpath']; print ''; - print ''; + print ''; + print ''; print ''; } } @@ -2905,7 +3372,7 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -3034,8 +3501,8 @@ elseif (! empty($module)) if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; print ''; - print ''; + print ''; + print ''; print ''; } } diff --git a/htdocs/modulebuilder/template/.gitignore b/htdocs/modulebuilder/template/.gitignore index e950cee245d..942cb8b03ba 100644 --- a/htdocs/modulebuilder/template/.gitignore +++ b/htdocs/modulebuilder/template/.gitignore @@ -13,4 +13,6 @@ /doc/user/build /.settings/ /.buildpath -/.project \ No newline at end of file +/.project +# Other +*.back \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index bc3b6c4050c..d7a810ac2cd 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -271,7 +271,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error); } - return array( + return array( 'success' => array( 'code' => 200, 'message' => 'MyObject deleted' @@ -290,14 +290,56 @@ class MyModuleApi extends DolibarrApi protected function _cleanObjectDatas($object) { // phpcs:enable - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder);*/ + unset($object->rowid); + unset($object->canvas); + + /*unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->statut); + unset($object->state); + unset($object->state_id); + unset($object->state_code); + unset($object->region); + unset($object->region_code); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_account); + unset($object->comments); + unset($object->note); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->shipping_method_id); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + */ + + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i=0; $i < $nboflines; $i++) + { + $this->_cleanObjectDatas($object->lines[$i]); + + unset($object->lines[$i]->lines); + unset($object->lines[$i]->note); + } + } return $object; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1a6fa3915ae..4cefbc159a0 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -68,21 +68,21 @@ class MyObject extends CommonObject * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'enabled' is a condition when the field must be managed. + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) * 'noteditable' says if field is not editable (1 or 0) - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'css' is the CSS style to use on field. For example: 'maxwidth200' * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'comment' is not used. You can store here any text of your choice. It is not used by application. */ // BEGIN MODULEBUILDER PROPERTIES @@ -91,12 +91,13 @@ class MyObject extends CommonObject */ public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'notnull'=> 1, 'default'=>'(PROV)', 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), @@ -282,8 +283,9 @@ class MyObject extends CommonObject // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) @@ -654,43 +656,22 @@ class MyObject extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); - $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index 854e7f37bd5..43970122919 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -26,6 +26,10 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets public $enabled=0; public $require_module=array(); + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto='mymodule@mymodule'; /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index aa21942cf2a..86eb50aff9e 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -125,7 +125,7 @@ class modMyModule extends DolibarrModules $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mymodule@mymodule"); $this->phpmin = array(5,5); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(11,-3); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); @@ -183,25 +183,25 @@ class modMyModule extends DolibarrModules $this->dictionaries=array(); /* Example: $this->dictionaries=array( - 'langs'=>'mylangfile@mymodule', + 'langs'=>'mymodule@mymodule', // List of tables we want to see into dictonnary editor - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"), // Label of tables - 'tablib'=>array("Table1","Table2","Table3"), + 'tablib'=>array("Table1", "Table2", "Table3"), // Request to select fields - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Sort order - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), // List of fields (result of select to show dictionary) - 'tabfield'=>array("code,label","code,label","code,label"), + 'tabfield'=>array("code,label", "code,label", "code,label"), // List of fields (list of fields to edit a record) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), + 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), // List of fields (list of fields for insert) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), + 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), // Name of columns with primary key (try to always name it 'rowid') - 'tabrowid'=>array("rowid","rowid","rowid"), + 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) + 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) ); */ @@ -246,18 +246,18 @@ class modMyModule extends DolibarrModules /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; /* END MODULEBUILDER PERMISSIONS */ @@ -276,14 +276,28 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); /* END MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Top menu entry + 'titre'=>'MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'myobject', + 'url'=>'/mymodule/mymoduleindex.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'List MyObject', 'mainmenu'=>'mymodule', @@ -292,12 +306,12 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'New MyObject', 'mainmenu'=>'mymodule', @@ -306,7 +320,7 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->write', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); @@ -322,11 +336,16 @@ class modMyModule extends DolibarrModules $this->export_icon[$r]='myobject@mymodule'; $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + //$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline'; $keyforalias='tl'; + //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline'; + //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid'; $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; $r++; */ @@ -363,6 +382,8 @@ class modMyModule extends DolibarrModules */ public function init($options = '') { + global $conf, $langs; + $result=$this->_load_tables('/mymodule/sql/'); if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') @@ -375,7 +396,36 @@ class modMyModule extends DolibarrModules //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + // Permissions + $this->remove($options); + $sql = array(); + + // ODT template + /* + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule'; + $dest=$dirodt.'/template_myobjects.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src, $dest, 0, 0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } + } + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'mymodule' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','mymodule',".$conf->entity.")" + ); + */ + return $this->_init($sql, $options); } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php new file mode 100644 index 00000000000..822d6110c4b --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -0,0 +1,518 @@ + + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/commande/doc/doc_generic_myobject_odt.modules.php + * \ingroup mymodule + * \brief File of class to build ODT documents for myobjects + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/myobject/modules_myobject.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_myobject_odt extends ModelePDFMyObject +{ + /** + * Issuer + * @var Societe + */ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * @var string Dolibarr version of the loaded document + */ + public $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Page size for A4 format + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; + + // Load translation files required by the page + $langs->loadLangs(array("errors","companies")); + + $form = new Form($this->db); + + $texte = $this->description.".
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'; + $pathtohook = strtolower($module).'/js/'.strtolower($module).'.js.php'; + print ' '.$langs->trans("JSFile").' : '; + if (dol_is_file($dirins.'/'.$pathtohook)) + { + print ''.$pathtohook.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'.$langs->trans("WidgetFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').'
'.$langs->trans("CLIFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
'; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + + // Scan directories + $nbofiles=count($listoffiles); + if (! empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte.=count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte.=''; + } + + if ($nbofiles) + { + $texte.='
'; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
'; + $texte.= ''; + + return $texte; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build a document on disk using the generic odt module. + * + * @param Commande $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user,$langs,$conf,$mysoc,$hookmanager; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); + + if ($conf->commande->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Commande($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db, $object->error); + return -1; + } + } + + $dir = $conf->commande->multidir_output[$object->entity]; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp=$objectref.'_'.$newfiletmp; + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; + + dol_mkdir($conf->mymodule->dir_temp); + + + // If CUSTOMER contact defined on order, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + $contactobject=null; + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='ORDER_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object, $outputlangs); + $array_user=$this->get_substitutionarray_user($user, $outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + // Replace tags of lines + try + { + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + catch(SegmentException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + + // Call the beforeODTSave hook + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + return -1; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php new file mode 100644 index 00000000000..dfcd1a574e7 --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_advanced.php + * \ingroup bom + * \brief File containing class for advanced numbering model of MyObject + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + + +/** + * Class to manage customer Bom numbering rules advanced + */ +class mod_myobject_advanced extends ModeleNumRefMyObject +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name='advanced'; + + + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; + + $langs->load("bills"); + + $form = new Form($db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $old_code_type=$mysoc->typent_code; + $mysoc->code_client='CCCCCCCCCC'; + $mysoc->typent_code='TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client=$old_code_client; + $mysoc->typent_code=$old_code_type; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $date = ($object->date_bom ? $object->date_bom : $object->date); + + $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date); + + return $numFinal; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php new file mode 100644 index 00000000000..0da53adb55f --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_standard.php + * \ingroup bom + * \brief File of class to manage MyObject numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + +/** + * Class to manage customer order numbering rules standard + */ +class mod_myobject_standard extends ModeleNumRefMyObject +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix='MYOBJECT'; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string name + */ + public $name='standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=9; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_bom_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->date_creation; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max+1); + + dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php new file mode 100644 index 00000000000..4598a010287 --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/modules_bom.php + * \ingroup bom + * \brief File that contains parent class for boms models + * and parent class for boms numbering models + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit + + +/** + * Parent class for boms models + */ +abstract class ModelePDFMyObject extends CommonDocGenerator +{ + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { + // phpcs:enable + global $conf; + + $type = 'bom'; + $list = array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + + return $list; + } +} + + + +/** + * Parent class to manage numbering of BOMs + */ +abstract class ModeleNumRefMyObject +{ + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Returns the default description of the numbering template + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoDescription"); + } + + /** + * Returns an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoExample"); + } + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Returns next assigned value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns version of numbering module + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php new file mode 100644 index 00000000000..c0b2e073ad0 --- /dev/null +++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php @@ -0,0 +1,58 @@ + + * + * 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 . + */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + +print "\n"; + + +global $user; +global $noMoreLinkedObjectBlockAfter; + +$langs = $GLOBALS['langs']; +$linkedObjectBlock = $GLOBALS['linkedObjectBlock']; + +// Load translation files required by the page +$langs->load("mymodule"); + +$total=0; $ilink=0; +foreach($linkedObjectBlock as $key => $objectlink) +{ + $ilink++; + + $trclass='oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + ?> + + trans("MyObject"); ?> + getNomUrl(1); ?> + + date, 'day'); ?> + + getLibStatut(7); ?> + '.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + + \n"; diff --git a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php b/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php deleted file mode 100644 index 8e871e7f416..00000000000 --- a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -/** - * \file core/tpl/mytemplate.tpl.php - * \ingroup mymodule - * \brief Example template. - * - * Put detailed description here. - */ - -// Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; -} - - -/** Your code here. */ -echo "Hello world!"; diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 2b681e817f8..d97af3cc99e 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -50,10 +50,10 @@ $action=GETPOST('action', 'alpha'); // Securite acces client if (! $user->rights->mymodule->read) accessforbidden(); $socid=GETPOST('socid', 'int'); -if (isset($user->societe_id) && $user->societe_id > 0) +if (isset($user->socid) && $user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $max=5; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 8abb3623909..c452d908538 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -61,14 +61,9 @@ if (GETPOST('actioncode', 'array')) } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); - -// Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'mymodule', $id); +$search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -79,10 +74,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC'; +if (! $sortorder) $sortorder='DESC,DESC'; // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array @@ -93,13 +88,17 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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->mymodule->multidir_output[$object->entity] . "/" . $object->id; +// Security check - Protection if external user +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'mymodule', $object->id); /* - * Actions + * Actions */ -$parameters=array('id'=>$socid); +$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'); @@ -126,8 +125,6 @@ if (empty($reshook)) * View */ -$contactstatic = new Contact($db); - $form = new Form($db); if ($object->id > 0) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index e39022814e7..ec70df73583 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -100,8 +100,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); @@ -142,6 +142,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; @@ -310,7 +322,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project if (! empty($conf->projet->enabled)) { @@ -355,6 +367,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Common attributes //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. @@ -498,7 +512,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Documents /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; + $relativepath = $objref . '/' . $objref . '.pdf'; $filedir = $conf->mymodule->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content @@ -522,23 +536,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, 'myobject', (is_object($object->thirdparty)?$object->thirdparty->id:0), 1, '', $MAXEVENT, '', $morehtmlright); print '
'; } //Select mail models is same action as presend /* - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; - // Presend form - $modelmail='inventory'; - $defaulttopic='InformationMessage'; - $diroutput = $conf->product->dir_output.'/inventory'; - $trackid = 'stockinv'.$object->id; + // Presend form + $modelmail='myobject'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->mymodule->dir_output; + $trackid = 'myobject'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - */ + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ } // End of page diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 5e40b12a076..f4b918692ca 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -53,11 +53,6 @@ $confirm=GETPOST('confirm'); $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'mymodule', $id); - // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -84,6 +79,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->id); if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->ref); +// Security check - Protection if external user +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'mymodule', $object->id); + + /* * Actions diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index bf24be61023..08fbcbaa98e 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -112,9 +112,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled'); $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'mymodule', $id, ''); @@ -153,6 +153,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$permtoread = $user->rights->mymodule->myobject->read; +$permtowrite = $user->rights->mymodule->myobject->write; +$permtodelete = $user->rights->mymodule->myobject->delete; /* @@ -190,8 +193,6 @@ if (empty($reshook)) // Mass actions $objectclass='MyObject'; $objectlabel='MyObject'; - $permtoread = $user->rights->mymodule->read; - $permtodelete = $user->rights->mymodule->delete; $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -346,7 +347,7 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if ($permtodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -360,7 +361,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mymodule/myobject_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mymodule->write); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permtowrite); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); @@ -593,8 +594,8 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $urlsource.=str_replace('&', '&', $param); $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->write; + $genallowed=$permtoread; + $delallowed=$permtowrite; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index c8dbc5d3140..7cf5f418ff1 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -59,8 +59,8 @@ $hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that co $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); // Load object diff --git a/htdocs/mrp/ChangeLog.md b/htdocs/mrp/ChangeLog.md deleted file mode 100644 index 416bad1d559..00000000000 --- a/htdocs/mrp/ChangeLog.md +++ /dev/null @@ -1,5 +0,0 @@ -# CHANGELOG MRP FOR DOLIBARR ERP CRM - -## 1.0 -Initial version - diff --git a/htdocs/mrp/admin/setup.php b/htdocs/mrp/admin/setup.php deleted file mode 100644 index 8d7df29b383..00000000000 --- a/htdocs/mrp/admin/setup.php +++ /dev/null @@ -1,151 +0,0 @@ - - * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson - * - * 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 mrp/admin/setup.php - * \ingroup mrp - * \brief Mrp setup page. - */ - -// Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - -global $langs, $user; - -// Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; -require_once '../lib/mrp.lib.php'; -//require_once "../class/myclass.class.php"; - -// Translations -$langs->loadLangs(array("admin", "mrp")); - -// Access control -if (! $user->admin) accessforbidden(); - -// Parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - -$arrayofparameters=array( - 'MRP_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'MRP_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) -); - - - -/* - * Actions - */ - -if ((float) DOL_VERSION >= 6) -{ - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} - - - -/* - * View - */ - -$page_name = "MrpSetup"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mrp'); - -// Configuration header -$head = mrpAdminPrepareHead(); -dol_fiche_head($head, 'settings', '', -1, "mrp"); - -// Setup page goes here -echo ''.$langs->trans("MrpSetupPage").'

'; - - -if ($action == 'edit') -{ - print '
'; - print ''; - print ''; - - print ''; - print ''; - - foreach($arrayofparameters as $key => $val) - { - print ''; - } - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '
'; - - print '
'; - print ''; - print '
'; - - print '
'; - print '
'; -} -else -{ - if (! empty($arrayofparameters)) - { - print ''; - print ''; - - foreach($arrayofparameters as $key => $val) - { - print ''; - } - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '' . $conf->global->$key . '
'; - - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - } - else - { - print '
'.$langs->trans("NothingToSetup"); - } -} - - -// Page end -dol_fiche_end(); - -llxFooter(); -$db->close(); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 384893269ce..2cff993a05f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -61,7 +61,7 @@ class Mo extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; // To produce const STATUS_INPROGRESS = 2; - const STATUS_DONE = 3; + const STATUS_PRODUCED = 3; const STATUS_CANCELED = -1; @@ -92,34 +92,42 @@ class Mo extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), - 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce",), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>52), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), - 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '-1'=>'Canceled')), ); public $rowid; public $ref; public $entity; public $label; public $qty; + public $fk_warehouse; public $fk_soc; public $note_public; public $note_private; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $tms; public $fk_user_creat; public $fk_user_modif; @@ -246,10 +254,10 @@ class Mo extends CommonObject unset($object->fk_user_creat); unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) @@ -544,43 +552,21 @@ class Mo extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) + if (empty($this->labelStatus)) { global $langs; //$langs->load("mrp"); - $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated'); + $this->labelStatus[self::STATUS_INPROGRESS] = $langs->trans('InProgress'); + $this->labelStatus[self::STATUS_PRODUCED] = $langs->trans('StatusMOProduced'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode); } /** diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 2a3249efdd9..36847b71035 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2019 Frédéric France @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; $hookmanager = new HookManager($db); @@ -46,6 +47,7 @@ $result=restrictedArea($user, 'bom|mrp'); */ $staticbom = new BOM($db); +$staticmo = new Mo($db); llxHeader('', $langs->trans("MRP"), ''); @@ -81,7 +83,7 @@ if ($conf->use_javascript_ajax) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { - $dataseries[$obj->status]=$obj->nb; + $dataseries[$obj->status]=array(0=>$staticmo->LibStatut($obj->status), $obj->nb); $totalnb+=$obj->nb; } } @@ -128,6 +130,7 @@ print '
'; /* * Last modified BOM */ + $max=5; $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; @@ -160,7 +163,7 @@ if ($resql) print ''; print ''.$staticbom->getNomUrl(1, 32).''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; - print ''.$staticbom->getLibStatut(5).''; + print ''.$staticbom->getLibStatut(3).''; print ''; $i++; } @@ -177,12 +180,66 @@ else dol_print_error($db); } +/* + * Last modified MOs + */ +$max=5; + +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; +$sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo as a"; +$sql.= " WHERE a.entity IN (".getEntity('mo').")"; +$sql.= $db->order("a.tms", "DESC"); +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print '
'; + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $staticmo->id=$obj->rowid; + $staticmo->ref=$obj->ref; + $staticmo->date_modification=$obj->datem; + $staticmo->status=$obj->status; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } else { + print ''; + print ''; + print ''; + } + print "
'.$langs->trans("LatestMOModified", $max).'
'.$staticmo->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmo->getLibStatut(3).'
' . $langs->trans("None") . '
"; + print "
"; +} +else +{ + dol_print_error($db); +} print '
'; -$parameters = array('type' => $type, 'user' => $user); -$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array( + //'type' => $type, + 'user' => $user, +); +$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters); // End of page llxFooter(); diff --git a/htdocs/mrp/lib/mrp.lib.php b/htdocs/mrp/lib/mrp.lib.php index 7ee1fcd04c7..4fdfa25342e 100644 --- a/htdocs/mrp/lib/mrp.lib.php +++ b/htdocs/mrp/lib/mrp.lib.php @@ -35,7 +35,7 @@ function mrpAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mrp/admin/setup.php", 1); + $head[$h][0] = dol_buildpath("/admin/mrp.php", 1); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index 6189761269e..fe29c774f44 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -36,11 +36,16 @@ function moPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$object->id; + $head[$h][1] = $langs->trans("Production"); + $head[$h][2] = 'production'; + $h++; + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index be68bb26d35..884bc234cbf 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -23,19 +23,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -66,8 +54,8 @@ else $search_agenda_label=GETPOST('search_agenda_label'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mrp', $id); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index b12ee490fe7..07b6be426f3 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -42,22 +42,11 @@ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -99,8 +88,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); @@ -143,6 +132,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MO_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; @@ -155,12 +156,10 @@ if (empty($reshook)) /* * View - * - * Put here all code to build page */ $form=new Form($db); -$formfile=new FormFile($db); +$formproject=new FormProjets($db); llxHeader('', $langs->trans('Mo'), ''); @@ -248,7 +247,7 @@ if ($action == 'create') // Part to edit record if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("Mo"), '', 'cubes'); + print load_fiche_titre($langs->trans("MO"), '', 'cubes'); print '
'; print ''; @@ -282,7 +281,8 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); + $res = $object->fetch_thirdparty(); + $res = $object->fetch_optionals(); $head = moPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("MO"), -1, $object->picto); @@ -306,23 +306,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - // Confirmation of action xxxx - if ($action == 'xxx') - { - $formquestion=array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -341,9 +324,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project if (! empty($conf->projet->enabled)) { @@ -354,15 +337,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=$formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.='
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (! empty($object->fk_project)) { @@ -374,7 +357,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } } - */ $morehtmlref.=''; @@ -387,7 +369,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + $keyforbreak='fk_warehouse'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes @@ -479,26 +463,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } + // Validate + if ($user->rights->mrp->write && $object->status == MO::STATUS_DRAFT) + { + if (is_array($object->lines) && count($object->lines) > 0) + { + print '' . $langs->trans("Validate") . ''; + } + else + { + print '' . $langs->trans("Validate") . ''; + } + } + // Clone if (! empty($user->rights->mrp->write)) { - print '
' . $langs->trans("ToClone") . '
'; + print '
' . $langs->trans("ToClone") . '
'; } - /* - if ($user->rights->mrp->write) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; - } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ - // Delete (need delete permission, or if draft, just need create/modify permission) if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) { @@ -555,17 +538,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } //Select mail models is same action as presend - /* - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; - // Presend form - $modelmail='inventory'; - $defaulttopic='InformationMessage'; - $diroutput = $conf->product->dir_output.'/inventory'; - $trackid = 'stockinv'.$object->id; + // Presend form + $modelmail='mo'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->mrp->dir_output; + $trackid = 'mo'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - */ + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 40b92c2371a..2c4d1b36c99 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -22,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -53,8 +41,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mrp', $id); // Get parameters diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 81cb781ccff..b91affe403f 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -42,6 +42,7 @@ // Load Dolibarr environment require '../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -97,9 +98,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'mrp', $id, ''); diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 8cc5a9d50bd..aeb4630168d 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -22,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -59,8 +47,8 @@ $hookmanager->initHooks(array('monote','globalcard')); // Note that conf->ho $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mrp', $id); // Load object diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php new file mode 100644 index 00000000000..345bfe3f8dd --- /dev/null +++ b/htdocs/mrp/mo_production.php @@ -0,0 +1,421 @@ + + * + * 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 mo_production.php + * \ingroup mrp + * \brief Page to make production on a MO + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +// Security check - Protection if external user +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$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)) +{ + $error=0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Actions to send emails + $trigger_name='MO_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid='mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + */ + +$form=new Form($db); +$formproject=new FormProjets($db); + +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; + + + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = moPrepareHead($object); + dol_fiche_head($head, 'production', $langs->trans("MO"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ + // Thirdparty + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print '
'."\n"; + + // Common attributes + $keyforbreak='qty'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print ''; + print ''; + + print '
'; + + dol_fiche_end(); + + + /* + * Lines + */ + + if (! empty($object->table_element_line)) + { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (! empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print ''; + } + + if (! empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + /* + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if (! empty($user->rights->mrp->write)) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if (! empty($user->rights->mrp->write)) + { + print ''; + } + + // Delete (need delete permission, or if draft, just need create/modify permission) + if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + }*/ + + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + + + print '
'; + + + + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 786ed7220b5..b1cdeac1f36 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -44,6 +44,9 @@ class Opensurveysondage extends CommonObject */ public $table_element='opensurvey_sondage'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'opensurvey'; public $id_sondage; diff --git a/htdocs/product/admin/product_supplier_extrafields.php b/htdocs/product/admin/product_supplier_extrafields.php new file mode 100644 index 00000000000..149178ead36 --- /dev/null +++ b/htdocs/product/admin/product_supplier_extrafields.php @@ -0,0 +1,132 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Marcos García + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2019 Tim Otte + * + * 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/product/admin/product_supplier_extrafields.php + * \ingroup product + * \brief Page to setup extra fields of products + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'admin', 'products')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='product_fournisseur_price'; //Must be the $element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$title = $langs->trans('ProductServiceSetup'); +$textobject = $langs->trans("ProductsAndServices"); +if (empty($conf->product->enabled)) +{ + $title = $langs->trans('ServiceSetup'); + $textobject = $langs->trans('Services'); +} +elseif (empty($conf->service->enabled)) +{ + $title = $langs->trans('ProductSetup'); + $textobject = $langs->trans('Products'); +} + +//$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +$help_url=''; +llxHeader('', $title, $help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($title, $linkback, 'title_setup'); + + +$head = product_admin_prepare_head(); + +dol_fiche_head($head, 'supplierAttributes', $textobject, -1, 'product'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index a264171f529..c6585f5e590 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -50,7 +50,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); // Security check $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result=restrictedArea($user, 'produit|service', $id, 'product&product'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -132,7 +132,7 @@ if ($id > 0 || $ref) $object->next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index a5365545f62..9c02fc35d16 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -181,19 +181,19 @@ class ActionsCardProduct // Weight $this->tpl['weight'] = $this->object->weight; - $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units); + $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units, 0, 2); // Length $this->tpl['length'] = $this->object->length; - $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units); + $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units, 0, 2); // Surface $this->tpl['surface'] = $this->object->surface; - $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units); + $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units, 0, 2); // Volume $this->tpl['volume'] = $this->object->volume; - $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units); + $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2); } if ($action == 'view') @@ -211,25 +211,25 @@ class ActionsCardProduct // Weight if ($this->object->weight != '') { - $this->tpl['weight'] = $this->object->weight." ".measuring_units_string($this->object->weight_units, "weight"); + $this->tpl['weight'] = $this->object->weight." ".measuringUnitString(0, "weight", $this->object->weight_units); } // Length if ($this->object->length != '') { - $this->tpl['length'] = $this->object->length." ".measuring_units_string($this->object->length_units, "size"); + $this->tpl['length'] = $this->object->length." ".measuringUnitString(0, "size", $this->object->length_units); } // Surface if ($this->object->surface != '') { - $this->tpl['surface'] = $this->object->surface." ".measuring_units_string($this->object->surface_units, "surface"); + $this->tpl['surface'] = $this->object->surface." ".measuringUnitString(0, "surface", $this->object->surface_units); } // Volume if ($this->object->volume != '') { - $this->tpl['volume'] = $this->object->volume." ".measuring_units_string($this->object->volume_units, "volume"); + $this->tpl['volume'] = $this->object->volume." ".measuringUnitString(0, "volume", $this->object->volume_units); } $this->tpl['fiche_end']=dol_get_fiche_end(); diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 594fd6c1b9b..dc7fea3fc0e 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -37,7 +37,7 @@ $linkback = 'next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; -if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; +if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); ?> diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f8f64decbfa..79511df9640 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -78,7 +78,7 @@ $confirm=GETPOST('confirm', 'alpha'); $socid=GETPOST('socid', 'int'); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $object = new Product($db); $object->type = $type; // so test later to fill $usercancxxx is correct @@ -1120,7 +1120,7 @@ else // Net Measure print ''.$langs->trans("NetMeasure").''; print ''; - print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), ''); + print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 0); print ''; } } @@ -1503,7 +1503,7 @@ else // Net Measure print ''.$langs->trans("NetMeasure").''; print ' '; - print $formproduct->selectMeasuringUnits($object->net_measure_units, ''); + print $formproduct->selectMeasuringUnits($object->net_measure_units, '', 0, 0, 0); print ''; } } @@ -1650,7 +1650,7 @@ else $object->next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -1836,7 +1836,7 @@ else print ''; } - //Parent product. + // Parent product. if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); @@ -1885,7 +1885,7 @@ else print ''.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string(0, "weight", $object->weight_units); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { @@ -1902,7 +1902,7 @@ else print $object->length; if ($object->width) print " x ".$object->width; if ($object->height) print " x ".$object->height; - print ' '.measuring_units_string(0, "size", $object->length_units); + print ' '.measuringUnitString(0, "size", $object->length_units); } else { @@ -1916,7 +1916,7 @@ else print ''.$langs->trans("Surface").''; if ($object->surface != '') { - print $object->surface." ".measuring_units_string(0, "surface", $object->surface_units); + print $object->surface." ".measuringUnitString(0, "surface", $object->surface_units); } else { @@ -1930,7 +1930,7 @@ else print ''.$langs->trans("Volume").''; if ($object->volume != '') { - print $object->volume." ".measuring_units_string(0, "volume", $object->volume_units); + print $object->volume." ".measuringUnitString(0, "volume", $object->volume_units); } else { @@ -1945,7 +1945,7 @@ else print ''.$langs->trans("NetMeasure").''; if ($object->net_measure != '') { - print $object->net_measure." ".measuring_units_string(0, "weight", $object->net_measure_units); + print $object->net_measure." ".measuringUnitString(0, "weight", $object->net_measure_units); } else { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index d6066b1a03a..947e4292c1a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -450,12 +450,13 @@ class Products extends DolibarrApi * Get prices per customer for a product * * @param int $id ID of product + * @param string $thirdparty_id Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i} * * @return mixed * * @url GET {id}/selling_multiprices/per_customer */ - public function getCustomerPricesPerCustomer($id) + public function getCustomerPricesPerCustomer($id, $thirdparty_id = '') { global $conf; @@ -472,12 +473,20 @@ class Products extends DolibarrApi throw new RestException(404, 'Product not found'); } - if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); + if ($result > 0) { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + $prodcustprice = new Productcustomerprice($this->db); + $filter = array(); + $filter['t.fk_product'] .= $id; + if ($thirdparty_id) $filter['t.fk_soc'] .= $thirdparty_id; + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); } - throw new RestException(501, 'Feature not yet available'); - //return $result; + if ( empty($prodcustprice->lines)) { + throw new RestException(404, 'Prices not found'); + } + + return $prodcustprice->lines; } /** @@ -573,7 +582,7 @@ class Products extends DolibarrApi { global $db, $conf; $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; if ($category > 0) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 8684c23511e..72fd475e6ae 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -258,12 +258,25 @@ class FormProduct if ($empty) $out.=''; foreach($this->cache_warehouses as $id => $arraytypes) { + $label=''; + if ($showfullpath) $label.=$arraytypes['full_label']; + else $label.=$arraytypes['label']; + if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) + { + if ($arraytypes['stock'] <= 0) { + $label.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; + } + else + { + $label.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; + } + } + $out.=''; } $out.=''; @@ -327,7 +340,7 @@ class FormProduct /** * Return a combo box with list of units - * For the moment, units labels are defined in measuring_units_string + * Units labels are defined in llx_c_units * * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume, time @@ -455,12 +468,20 @@ class FormProduct { if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { + $label=$arraytypes['entrepot_label'].' - '; + $label.=$arraytypes['batch']; + if ($arraytypes['qty'] <= 0) { + $label.=' ('.$langs->trans("Stock").' '.$arraytypes['qty'].')'; + } + else { + $label.=' ('.$langs->trans("Stock").' '.$arraytypes['qty'].')'; + } + $out.=''; } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f526c5e3c52..de14a5621a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -91,12 +91,19 @@ class Product extends CommonObject public $label; /** - * Product descripion + * Product description * * @var string */ public $description; + /** + * Product other fields PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION + * + * @var string + */ + public $other; + /** * Check TYPE constants * @@ -256,18 +263,23 @@ class Product extends CommonObject */ public $url; - //! Unites de mesure - public $net_measure; - public $net_measure_units; + //! Metric of products public $weight; public $weight_units; public $length; public $length_units; + public $width; + public $width_units; + public $height; + public $height_units; public $surface; public $surface_units; public $volume; public $volume_units; + public $net_measure; + public $net_measure_units; + public $accountancy_code_sell; public $accountancy_code_sell_intra; public $accountancy_code_sell_export; @@ -313,7 +325,12 @@ class Product extends CommonObject public $imgWidth; public $imgHeight; + /** + * @var integer|string date_creation + */ public $date_creation; + + public $date_modification; //! Id du fournisseur @@ -2075,14 +2092,17 @@ class Product extends CommonObject } $resql = $this->db->query($sql); - if ($resql ) { + if ($resql) { + + unset($this->oldcopy); + if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; - $this->label = $obj->label; + $this->label = $obj->label; $this->description = $obj->description; $this->url = $obj->url; $this->note_private = $obj->note_private; @@ -4197,22 +4217,22 @@ class Product extends CommonObject if ($this->type == Product::TYPE_PRODUCT) { if ($this->weight) { - $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuring_units_string($this->weight_units, "weight"); + $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); } if ($this->length) { - $label.="
".$langs->trans("Length").': '.$this->length.' '.measuring_units_string($this->length_units, 'size'); + $label.="
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); } if ($this->width) { - $label.="
".$langs->trans("Width").': '.$this->width.' '.measuring_units_string($this->width_units, 'size'); + $label.="
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); } if ($this->height) { - $label.="
".$langs->trans("Height").': '.$this->height.' '.measuring_units_string($this->height_units, 'size'); + $label.="
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } if ($this->surface) { - $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuring_units_string($this->surface_units, 'surface'); + $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); } if ($this->volume) { - $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuring_units_string($this->volume_units, 'volume'); + $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } } @@ -4368,17 +4388,17 @@ class Product extends CommonObject /** * Return label of a given status * - * @param int $status Statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - * @return string Label of status + * @param int $status Statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" + * @return string Label of status */ public function LibStatut($status, $mode = 0, $type = 0) { // phpcs:enable global $conf, $langs; - $labelstatut = $labelstatutShort = ''; + $labelStatus = $labelStatusShort = ''; $langs->load('products'); if (! empty($conf->productbatch->enabled)) { $langs->load("productbatch"); @@ -4408,51 +4428,50 @@ class Product extends CommonObject $statuttrans=empty($status)?'status5':'status4'; - if($status == 0){ + if ($status == 0) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if($type==0){ - $labelstatut = $langs->trans('ProductStatusNotOnSellShort'); - $labelstatutShort = $langs->trans('ProductStatusNotOnSell'); + if($type==0) { + $labelStatus = $langs->trans('ProductStatusNotOnSellShort'); + $labelStatusShort = $langs->trans('ProductStatusNotOnSell'); } - elseif($type == 1){ - $labelstatut = $langs->trans('ProductStatusNotOnBuyShort'); - $labelstatutShort = $langs->trans('ProductStatusNotOnBuy'); + elseif($type == 1) { + $labelStatus = $langs->trans('ProductStatusNotOnBuyShort'); + $labelStatusShort = $langs->trans('ProductStatusNotOnBuy'); } - elseif($type == 2){ - $labelstatut = $langs->trans('ProductStatusNotOnBatch'); - $labelstatutShort = $langs->trans('ProductStatusNotOnBatchShort'); + elseif($type == 2) { + $labelStatus = $langs->trans('ProductStatusNotOnBatch'); + $labelStatusShort = $langs->trans('ProductStatusNotOnBatchShort'); } } - elseif($status == 1){ + elseif ($status == 1) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if($type==0){ - $labelstatut = $langs->trans('ProductStatusOnSellShort'); - $labelstatutShort = $langs->trans('ProductStatusOnSell'); + if ($type==0) { + $labelStatus = $langs->trans('ProductStatusOnSellShort'); + $labelStatusShort = $langs->trans('ProductStatusOnSell'); } - elseif($type == 1){ - $labelstatut = $langs->trans('ProductStatusOnBuyShort'); - $labelstatutShort = $langs->trans('ProductStatusOnBuy'); + elseif ($type == 1) { + $labelStatus = $langs->trans('ProductStatusOnBuyShort'); + $labelStatusShort = $langs->trans('ProductStatusOnBuy'); } - elseif($type == 2){ - $labelstatut = $langs->trans('ProductStatusOnBatch'); - $labelstatutShort = $langs->trans('ProductStatusOnBatchShort'); + elseif ($type == 2) { + $labelStatus = $langs->trans('ProductStatusOnBatch'); + $labelStatusShort = $langs->trans('ProductStatusOnBatchShort'); } } - if($mode>6){ + if ($mode > 6) { return dolGetStatus($langs->trans('Unknown'), '', '', 'status0', 0); - } - else{ - return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); + } else { + return dolGetStatus($labelStatus, $labelStatusShort, '', $statuttrans, $mode); } } /** - * Retourne le libelle du finished du produit + * Retour label of nature of product * - * @return string Libelle + * @return string Label */ public function getLibFinished() { diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a3517c593f1..8fb3420df49 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -45,7 +45,7 @@ $key=GETPOST('key'); $parent=GETPOST('parent'); // Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -205,7 +205,7 @@ if ($id > 0 || ! empty($ref)) $linkback = '
'.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 0); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index f62ea66fd48..ef508c9a200 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -48,7 +48,7 @@ $confirm= GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -215,7 +215,7 @@ if ($object->id) $object->next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index ef0d1bc1c85..f0bedbcd7f5 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -8,7 +8,8 @@ * Copyright (C) 2014 Ion Agorria * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Tim Otte * * 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 @@ -33,6 +34,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php'; @@ -53,6 +55,8 @@ $cost_price=GETPOST('cost_price', 'alpha'); $backtopage=GETPOST('backtopage', 'alpha'); $error=0; +$extrafields = new ExtraFields($db); + // If socid provided by ajax company selector if (! empty($_REQUEST['search_fourn_id'])) { @@ -64,7 +68,7 @@ if (! empty($_REQUEST['search_fourn_id'])) // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (empty($user->rights->fournisseur->lire)) accessforbidden(); @@ -138,6 +142,7 @@ if (empty($reshook)) $action = ''; $result=$object->remove_product_fournisseur_price($rowid); if($result > 0){ + $db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = $rowid"); setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); }else{ $error++; @@ -146,7 +151,7 @@ if (empty($reshook)) } } - if ($action == 'updateprice') + if ($action == 'save_price') { $id_fourn=GETPOST("id_fourn"); if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); @@ -257,6 +262,36 @@ if (empty($reshook)) if (isset($_POST['ref_fourn_price_id'])) $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price"); + + $sql = ""; + $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $object->product_fourn_price_id); + // Insert a new extrafields row, if none exists + if ($db->num_rows($resql) != 1) { + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields (fk_object, "; + foreach ($extrafield_values as $key => $value) { + $sql .= str_replace('options_', '', $key) . ', '; + } + $sql = substr($sql, 0, strlen($sql)-2) . ") VALUES (" . $object->product_fourn_price_id . ", "; + foreach ($extrafield_values as $key => $value) { + $sql .= '"' . $value . '", '; + } + $sql = substr($sql, 0, strlen($sql)-2) . ')'; + } + // else update the existing one + else { + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields SET "; + foreach ($extrafield_values as $key => $value) { + $sql .= str_replace('options_', '', $key) . ' = "' . $value . '", '; + } + $sql = substr($sql, 0, strlen($sql)-2) . ' WHERE fk_object = ' . $object->product_fourn_price_id; + } + + // Execute the sql command from above + $db->query($sql); + $newprice = price2num(GETPOST("price", "alpha")); if ($conf->multicurrency->enabled) @@ -362,7 +397,7 @@ if ($id > 0 || $ref) $object->next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -402,7 +437,7 @@ if ($id > 0 || $ref) // Form to add or update a price - if (($action == 'add_price' || $action == 'updateprice' ) && $usercancreate) + if (($action == 'add_price' || $action == 'update_price' ) && $usercancreate) { $langs->load("suppliers"); @@ -418,7 +453,7 @@ if ($id > 0 || $ref) print '
'; print ''; - print ''; + print ''; dol_fiche_head(); @@ -730,6 +765,25 @@ SCRIPT; print ''; } + $extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + // Extrafields + $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $rowid); + if ($db->num_rows($resql) != 1) { + foreach ($extralabels as $key => $value) { + if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . '' . $extrafields->showInputField($key, '', '', '', '', '', 0, 'product_fournisseur_price') . ''; + } + } + } else { + $resql = $db->fetch_object($resql); + foreach ($extralabels as $key => $value) { + if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . '' . $extrafields->showInputField($key, $resql->{$key}, '', '', '', '', 0, 'product_fournisseur_price') . ''; + } + } + } + if (is_object($hookmanager)) { $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id); @@ -754,7 +808,7 @@ SCRIPT; print "\n
\n"; - if ($action != 'add_price' && $action != 'updateprice') + if ($action != 'add_price' && $action != 'update_price') { $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -817,6 +871,17 @@ SCRIPT; print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right '); + + // fetch optionals attributes and labels + $extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + print_liste_field_titre($value, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + } + if (is_object($hookmanager)) { $parameters=array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); @@ -938,6 +1003,23 @@ SCRIPT; print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour"); print ''; + // Extrafields + $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $productfourn->product_fourn_price_id); + if ($db->num_rows($resql) != 1) { + foreach ($extralabels as $key => $value) { + if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + print ""; + } + } + } else { + $resql = $db->fetch_object($resql); + foreach ($extralabels as $key => $value) { + if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + print '' . $extrafields->showOutputField($key, $resql->{$key}) . ""; + } + } + } + if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); @@ -948,7 +1030,7 @@ SCRIPT; print ''; if ($usercancreate) { - print ''.img_edit().""; + print ''.img_edit().""; print '   '; print ''.img_picto($langs->trans("Remove"), 'delete').''; } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index a92d2cd071a..87e5eb6d2fb 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -95,6 +95,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -107,6 +108,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print ''; print '
'; } @@ -266,7 +268,7 @@ print '
'; /* - * Last modified products + * Latest modified products */ $max=15; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; @@ -299,11 +301,11 @@ if ($result) print '
'; print ''; - $colnb=4; + $colnb=2; if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++; print ''; - print ''; while ($i < $num) @@ -359,10 +361,10 @@ if ($result) else print price($objp->price).' '.$langs->trans("HT"); print ''; } - print '"; - print '"; print "\n"; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 639b04cdbcc..2659d325676 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -72,8 +72,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index e9284781a5d..4434f82fbcf 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -57,7 +57,7 @@ class Inventory extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_RECORDED = 2; - const STATUS_CANCELED = 9; + const STATUS_CANCELED = -1; /** * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') @@ -396,49 +396,16 @@ class Inventory extends CommonObject // phpcs:enable global $langs; - if ($mode == 0) + if (empty($this->labelStatus)) { - $prefix=''; - if ($status == 0) return $langs->trans('Draft'); - elseif ($status == 1) return $langs->trans('Enabled'); - elseif ($status == -1) return $langs->trans('Canceled'); - } - elseif ($mode == 1) - { - if ($status == 0) return $langs->trans('Draft'); - elseif ($status == 1) return $langs->trans('Enabled'); - elseif ($status == -1) return $langs->trans('Canceled'); - } - elseif ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6').' '.$langs->trans('Canceled'); - } - elseif ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6').' '.$langs->trans('Canceled'); - } - elseif ($mode == 5) - { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'), 'statut6'); + global $langs; + //$langs->load("mrp"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', 'status'.$status, $mode); } /** diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index df67fbd0940..4ee108595e6 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -72,8 +72,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 0362a3767c3..9a20f00341b 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -68,9 +68,9 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) // Protection if external user +if ($user->socid > 0) // Protection if external user { - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 2b36582025f..2f13c4921a9 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -485,6 +485,8 @@ if ($resql) if($type == Product::TYPE_SERVICE) $rightskey='service'; if($user->rights->{$rightskey}->creer) { + $oldtype=$type; + if ($type === "") { $newcardbutton.= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); $type = Product::TYPE_SERVICE; @@ -492,7 +494,9 @@ if ($resql) $label='NewProduct'; if($type == Product::TYPE_SERVICE) $label='NewService'; $newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); - } + + $type=$oldtype; + } print ''; if ($optioncss != '') print ''; diff --git a/htdocs/product/note.php b/htdocs/product/note.php index c9a8bc6b1f9..d5593acfb78 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -40,7 +40,7 @@ $action = GETPOST('action', 'aZ09'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); @@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref)) $object->next_prev_filter=" fk_product_type = ".$object->type; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index a25ba2808d5..c50ca3538aa 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -36,7 +36,7 @@ $langs->load('propal'); $type=GETPOST("type", "int"); // Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'produit|service'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index e8e332d95b5..f6820bc37bc 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -62,7 +62,7 @@ $search_soc = GETPOST('search_soc'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid = $user->societe_id; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if ($id > 0 || ! empty($ref)) @@ -706,7 +706,7 @@ $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1); dol_fiche_end(); } diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 58d65810772..e819110c344 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -40,7 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -104,7 +104,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 56746cb33bc..ae3b642355a 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -39,8 +39,8 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (! empty($user->societe_id)) - $socid = $user->societe_id; +if (! empty($user->socid)) + $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index f779ced92ee..8a14c3f19a4 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -37,7 +37,7 @@ $ref = GETPOST('ref', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index d14eba99fae..6c5379d1ddb 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -41,7 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -122,7 +122,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 78ee704293d..70643e9c996 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -41,7 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -127,7 +127,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; - $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; + $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; @@ -221,7 +221,8 @@ if ($id > 0 || ! empty($ref)) $supplierinvoicestatic->id = $objp->facid; $supplierinvoicestatic->ref = $objp->ref; $supplierinvoicestatic->ref_supplier = $objp->ref_supplier; - $supplierinvoicestatic->libelle = $objp->libelle; + $supplierinvoicestatic->libelle = $objp->label; + $supplierinvoicestatic->label = $objp->label; $supplierinvoicestatic->total_ht = $objp->total_ht; $supplierinvoicestatic->total_ttc = $objp->total_ttc; $supplierinvoicestatic->total_tva = $objp->total_tva; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 0b8ae599809..4c58a6fb982 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -40,7 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index fbab22a0d2f..0dc19a47691 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -40,7 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 94012c1b9cf..22f7cc03b63 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -378,7 +378,7 @@ else $morehtmlref.=''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 57dd181bc91..361497189f9 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -44,26 +44,20 @@ class Entrepot extends CommonObject */ public $table_element='entrepot'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto='stock'; public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** - * Warehouse closed, inactive + * @var string Label + * @deprecated */ - const STATUS_CLOSED = 0; - - /** - * Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corrections allowed. - */ - const STATUS_OPEN_ALL = 1; - - /** - * Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch). - */ - const STATUS_OPEN_INTERNAL = 2; - public $libelle; + public $label; + /** * @var string description */ @@ -118,6 +112,21 @@ class Entrepot extends CommonObject 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), ); + /** + * Warehouse closed, inactive + */ + const STATUS_CLOSED = 0; + + /** + * Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corrections allowed. + */ + const STATUS_OPEN_ALL = 1; + + /** + * Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch). + */ + const STATUS_OPEN_INTERNAL = 2; + /** * Constructor @@ -443,7 +452,7 @@ class Entrepot extends CommonObject $this->id = $obj->rowid; $this->fk_parent = $obj->fk_parent; $this->ref = $obj->label; - $this->label = $obj->label; // deprecated + $this->label = $obj->label; $this->libelle = $obj->label; // deprecated $this->description = $obj->description; $this->statut = $obj->statut; @@ -642,49 +651,23 @@ class Entrepot extends CommonObject /** * Return label of a given status * - * @param int $statut Status + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; + $statusType = 'status5'; + if ($status > 0) $statusType = 'status4'; + $langs->load('stocks'); + $label = $langs->trans($this->statuts[$status]); + $labelshort = $langs->trans($this->statuts[$status]); - $picto = 'statut5'; - $label = $langs->trans($this->statuts[$statut]); - - - if ($mode == 0) - { - return $label; - } - elseif ($mode == 1) - { - return $label; - } - elseif ($mode == 2) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 3) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 4) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 5) - { - if ($statut > 0) $picto = 'statut4'; - return $label.' '.img_picto($label, $picto); - } + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 24d8e89e03b..a85b375b085 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -585,7 +585,7 @@ class MouvementStock extends CommonObject $sql .= " t.batch,"; $sql .= " t.eatby,"; $sql .= " t.sellby,"; - $sql .= " t.fk_projet"; + $sql .= " t.fk_projet as fk_project"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql.= ' WHERE 1 = 1'; //if (null !== $ref) { @@ -618,6 +618,7 @@ class MouvementStock extends CommonObject $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); + $this->fk_project = $obj->fk_project; } // Retreive all extrafield diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 3848a592f21..dbd0354cea3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -45,6 +45,9 @@ class Productlot extends CommonObject */ public $table_element = 'product_lot'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto='barcode'; /** @@ -501,11 +504,11 @@ class Productlot extends CommonObject /** * Return label of a given status * - * @param int $statut Status + * @param int $status Status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index e4786ae5a5a..496d4b4f109 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -61,12 +61,13 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print '
'.$transRecordedType.''.$langs->trans("FullList").''; + print ''.$langs->trans("FullList").''; print '
'; + print ''; print $product_static->LibStatut($objp->tosell, 3, 0); print "'; + print ''; print $product_static->LibStatut($objp->tobuy, 3, 1); print "
'; print ""; print ''; print "'; - print "
'.$langs->trans("Search").'
"; print $langs->trans("Warehouse").':

"; + print "

"; } @@ -85,6 +86,7 @@ if ($result) $i = 0; + print '
'; print ''; print ''; @@ -105,6 +107,7 @@ if ($result) $db->free($result); } print "
'.$langs->trans("Warehouses").'
"; + print '
'; } else { @@ -137,6 +140,7 @@ if ($resql) { $num = $db->num_rows($resql); + print '
'; print ''; print ""; print ''; @@ -185,6 +189,7 @@ if ($resql) $db->free($resql); print "
'.$langs->trans("LastMovements", min($num, $max)).'
"; + print '
'; } //print ''; diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 3314fcf642c..692fe17a83d 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -60,7 +60,7 @@ $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref.='
'; $shownav = 1; -if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; +if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 5324ef80243..0f4e5476fd2 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); // Security check -if ($user->societe_id) { - $socid = $user->societe_id; +if ($user->socid) { + $socid = $user->socid; } $result=restrictedArea($user, 'produit|service'); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index b04b8b8a220..5f4e1b97aa6 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -444,7 +444,7 @@ $formproduct=new FormProduct($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; -$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; +$sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; $sql.= " m.type_mouvement,"; @@ -567,7 +567,7 @@ if ($resql) $morehtmlref.='
'; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -978,7 +978,8 @@ if ($resql) $productlot->sellby= $objp->sellby; $warehousestatic->id=$objp->entrepot_id; - $warehousestatic->libelle=$objp->stock; + $warehousestatic->libelle=$objp->warehouse_ref; // deprecated + $warehousestatic->label=$objp->warehouse_ref; $warehousestatic->lieu=$objp->lieu; $arrayofuniqueproduct[$objp->rowid]=$objp->produit; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ef307842017..85f40a9d214 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -429,7 +429,7 @@ $sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e. $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; $sql.= " m.type_mouvement,"; -$sql.= " m.fk_projet,"; +$sql.= " m.fk_projet as fk_project,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields @@ -549,7 +549,7 @@ if ($resql) $morehtmlref.=''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -859,7 +859,7 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; print '  '; print ''; @@ -986,7 +986,7 @@ if ($resql) $warehousestatic->id=$objp->entrepot_id; $warehousestatic->ref=$objp->warehouse_ref; - $warehousestatic->libelle=$objp->warehouse_ref; + $warehousestatic->libelle=$objp->warehouse_ref; // deprecated $warehousestatic->label=$objp->warehouse_ref; $warehousestatic->lieu=$objp->lieu; $warehousestatic->fk_parent = $objp->fk_parent; @@ -1115,9 +1115,9 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; - if ($objp->fk_projet != 0) print $movement->get_origin($objp->fk_projet, 'project'); + if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project, 'project'); print ''; } // Action column diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 060bcc57960..3428b75f395 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -76,7 +76,7 @@ if (!empty($batchnumber)) { } // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); @@ -548,7 +548,7 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 00299c94459..c7f9a5ae8fa 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -53,7 +53,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='list'; // Protection if external user -if ($user->societe_id > 0) +if ($user->socid > 0) { //accessforbidden(); } @@ -318,7 +318,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = '' . $langs->trans("BackToList") . ''; $shownav = 1; - if ($user->societe_id && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index ed4aea8c010..5fb9cc23bca 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -48,7 +48,7 @@ $confirm= GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : ''); $fieldtype = 'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -132,7 +132,7 @@ if ($object->id) $linkback = '' . $langs->trans("BackToList") . ''; $shownav = 1; - if ($user->societe_id && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 9596c87c9d3..fd2a7c70c13 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -67,9 +67,9 @@ if (! $sortorder) $sortorder="ASC"; // Protection if external user $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; //accessforbidden(); } @@ -105,13 +105,16 @@ $arrayfields=array( //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Load object if id or ref is provided as parameter if (($id > 0 || ! empty($ref)) && $action != 'add') diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index b992be282d4..168ed5e54f9 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -38,8 +38,8 @@ require_once './lib/replenishment.lib.php'; $langs->loadLangs(array('products', 'stocks', 'orders')); // Security check -if ($user->societe_id) { - $socid = $user->societe_id; +if ($user->socid) { + $socid = $user->socid; } $result=restrictedArea($user, 'produit|service'); @@ -140,7 +140,6 @@ if ($action == 'order' && isset($_POST['valid'])) if ($qty) { //might need some value checks - $obj = $db->fetch_object($resql); $line = new CommandeFournisseurLigne($db); $line->qty = $qty; $line->fk_product = $idprod; @@ -179,7 +178,7 @@ if ($action == 'order' && isset($_POST['valid'])) $error=$db->lasterror(); dol_print_error($db); } - $db->free($resql); + unset($_POST['fourn' . $i]); } unset($_POST[$i]); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index d618e40ab38..27834923a0e 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Regis Houssin * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2019 Juanjo Menent * * 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 @@ -37,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('products', 'stocks', 'orders')); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service'); $sall = GETPOST('search_all', 'alphanohtml'); @@ -140,7 +141,9 @@ if (GETPOST('statut', 'int')) { $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); -$sql .= $db->plimit($limit+1, $offset); +if (! $sproduct) { + $sql .= $db->plimit($limit+1, $offset); +} $resql = $db->query($sql); if ($resql) @@ -257,7 +260,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $conf->liste_limit)) + while ($i < min($num, $sproduct?$num:$conf->liste_limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 054947183ab..19a23e1e9d2 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -42,7 +42,7 @@ $cancel=GETPOST('cancel', 'alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -203,7 +203,7 @@ dol_fiche_head($head, 'translation', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; -if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; +if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 7a8e3ff2591..cf1249aa9eb 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -36,7 +36,7 @@ if ($search_project_user == $user->id) $mine = 1; // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +if ($user->socid > 0) $socid=$user->socid; //$result = restrictedArea($user, 'projet', $projectid); if (!$user->rights->projet->lire) accessforbidden(); @@ -111,6 +111,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -123,6 +124,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print '
'; print '
'; } @@ -130,6 +132,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /* Affichage de la liste des projets d'aujourd'hui */ +print '
'; print ''; print ''; print ''; @@ -179,12 +182,14 @@ print ''; print ''; print "\n"; print "
'.$langs->trans('ActivityOnProjectToday').''.$langs->trans('Total').''.convertSecondToTime($total, 'allhourmin').'
"; +print '
'; print '
'; /* Affichage de la liste des projets d'hier */ +print '
'; print ''; print ''; print ''; @@ -234,6 +239,7 @@ print ''; print ''; print "\n"; print "
'.$langs->trans('ActivityOnProjectYesterday').''.$langs->trans('Total').''.convertSecondToTime($total, 'allhourmin').'
"; +print '
'; @@ -243,6 +249,7 @@ if ($db->type != 'pgsql') print '
'; // Affichage de la liste des projets de la semaine + print '
'; print ''; print ''; print ''; @@ -291,7 +298,7 @@ if ($db->type != 'pgsql') print ''; print ''; print "\n"; - print "
'.$langs->trans("ActivityOnProjectThisWeek").''.$langs->trans('Total').''.convertSecondToTime($total, 'allhourmin').'

"; + print "

"; } */ @@ -299,6 +306,7 @@ if ($db->type != 'pgsql') /* Affichage de la liste des projets du mois */ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) { + print '
'; print ''; print ''; print ''; @@ -343,11 +351,13 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print ''; print "\n"; print "
'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now, "%B %Y").''.convertSecondToTime($total, 'allhourmin').'
"; + print '
'; } /* Affichage de la liste des projets de l'annee */ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) { + print '
'; print '
'; print ''; print ''; @@ -393,6 +403,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; print "\n"; print "
'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).''.convertSecondToTime($total, 'allhourmin').'
"; + print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) @@ -467,6 +478,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S //print load_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'
'; + print '
'; print ''; print ''; //print ''; @@ -566,6 +578,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S } print "
'.$langs->trans('TaskRessourceLinks').'
"; + print '
'; $db->free($resql); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index b07b41c1b88..77dcaa641d2 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -56,7 +56,7 @@ $hookmanager->initHooks(array('timesheetperdaycard')); // Security check $socid=0; // For external user, no check is done on company because readability is managed by public status of project and assignement. -//if ($user->societe_id > 0) $socid=$user->societe_id; +//if ($user->socid > 0) $socid=$user->socid; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index e51b2e4b404..8af733394bf 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -56,7 +56,7 @@ $hookmanager->initHooks(array('timesheetperweekcard')); // Security check $socid=0; // For external user, no check is done on company because readability is managed by public status of project and assignement. -// if ($user->societe_id > 0) $socid=$user->societe_id; +// if ($user->socid > 0) $socid=$user->socid; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f15499d4682..5b3d69777b7 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -71,7 +71,7 @@ if ($id > 0 || ! empty($ref)) // Security check $socid=GETPOST('socid', 'int'); -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $object->id, 'projet&project'); // fetch optionals attributes and labels @@ -509,7 +509,7 @@ if ($action == 'create' && $user->rights->projet->creer) dol_fiche_head(); - print ''; + print '
'; $defaultref=''; $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index a873b53dbc0..e049945f235 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -60,6 +60,9 @@ class Project extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'projectpub'; /** @@ -1453,7 +1456,7 @@ class Project extends CommonObject // Security check $socid=0; - if ($user->societe_id > 0) $socid = $user->societe_id; + if ($user->socid > 0) $socid = $user->socid; $tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0); @@ -1533,7 +1536,7 @@ class Project extends CommonObject // Security check $socid=0; - if ($user->societe_id > 0) $socid = $user->societe_id; + if ($user->socid > 0) $socid = $user->socid; $tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); @@ -1764,7 +1767,7 @@ class Project extends CommonObject global $conf, $langs; // For external user, no check is done on company because readability is managed by public status of project and assignement. - //$socid=$user->societe_id; + //$socid=$user->socid; $projectsListId = null; if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 1bd044bc985..dcc4c18c497 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -47,6 +47,9 @@ class Task extends CommonObject */ public $fk_element='fk_task'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'task'; /** @@ -1839,11 +1842,11 @@ class Task extends CommonObject /** * Return status label for an object * - * @param int $statut Id statut + * @param int $status Id status * @param integer $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable // list of Statut of the task @@ -1862,59 +1865,59 @@ class Task extends CommonObject if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); - elseif ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5').' '.$langs->trans($this->statuts_short[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3'); - elseif ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); - elseif ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); - elseif ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5'); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); + elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); + elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5').' '.$langs->trans($this->statuts[$statut]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); + elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - /*if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); - elseif ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); - elseif ($statut==2) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); - elseif ($statut==3) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - elseif ($statut==4) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - elseif ($statut==5) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); + /*if ($status==0) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut0'); + elseif ($status==1) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut1'); + elseif ($status==2) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut3'); + elseif ($status==3) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut6'); + elseif ($status==4) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut6'); + elseif ($status==5) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut5'); */ //else return $this->progress.' %'; return ' '; } elseif ($mode == 6) { - /*if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); - elseif ($statut==1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); - elseif ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); - elseif ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - elseif ($statut==4) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - elseif ($statut==5) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); + /*if ($status==0) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut0'); + elseif ($status==1) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut1'); + elseif ($status==2) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut3'); + elseif ($status==3) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut6'); + elseif ($status==4) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut6'); + elseif ($status==5) return $langs->trans($this->statuts[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut5'); */ //else return $this->progress.' %'; return ' '; @@ -1966,7 +1969,7 @@ class Task extends CommonObject global $conf, $langs; // For external user, no check is done on company because readability is managed by public status of project and assignement. - //$socid=$user->societe_id; + //$socid=$user->socid; $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); @@ -2039,7 +2042,7 @@ class Task extends CommonObject // phpcs:enable global $user; - $mine=0; $socid=$user->societe_id; + $mine=0; $socid=$user->socid; $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid); diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index b535b0f6ada..064f4a12729 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -49,7 +49,7 @@ $planned_workload=((GETPOST('planned_workloadhour', 'int')!='' || GETPOST('plann // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index a1735e20ad6..82eb598190b 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -47,7 +47,7 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $hookmanager->initHooks(array('projectcontactcard','globalcard')); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 10c7a140df7..f77419f2e75 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -42,7 +42,7 @@ $mine = (GETPOST('mode', 'alpha') == 'mine' ? 1 : 0); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result=restrictedArea($user, 'projet', $id, 'projet&project'); $object = new Project($db); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 44b803571ba..14dccfedb8d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -83,17 +83,16 @@ if (! isset($_POST['datesrfc']) && ! isset($_POST['datesday']) && ! empty($conf- //$dates=dol_time_plus_duree($datee, -1, 'y'); $dates=dol_get_first_day($tmp['year'], 1); } -if ($id == '' && $projectid == '' && $ref == '') +if ($id == '' && $ref == '') { - dol_print_error('', 'Bad parameter'); - exit; + setEventMessage($langs->trans('ErrorBadParameters'), 'errors'); + header('Location: list.php'); + exit(); } $mine = $_REQUEST['mode']=='mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -$projectid=$id; // For backward compatibility - $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -101,8 +100,8 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob // Security check $socid=$object->socid; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $projectid, 'projet&project'); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); $hookmanager->initHooks(array('projectOverview')); @@ -539,7 +538,7 @@ if ($action=="addelement") elseif ($action == "unlink") { $tablename = GETPOST("tablename", "aZ09"); - $projectField = GETPOST("projectfield", "aZ09"); + $projectField = GETPOST('projectfield', 'aZ09') ? GETPOST('projectfield', 'aZ09') : 'fk_projet'; $elementselectid = GETPOST("elementselect", "int"); $result = $object->remove_element($tablename, $elementselectid, $projectField); @@ -558,7 +557,7 @@ $showdatefilter=0; if (! $showdatefilter) { print '
'; - print '
'; + print ''; print ''; print ''; print ''; @@ -781,7 +780,7 @@ foreach ($listofreferent as $key => $value) if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field)?$project_field:'fk_projet'); - if (! $selectList || ($selectList<0)) + if ($selectList<0) { setEventMessages($formproject->error, $formproject->errors, 'errors'); } @@ -789,7 +788,7 @@ foreach ($listofreferent as $key => $value) { // Define form with the combo list of elements to link $addform.='
'; - $addform.=''; + $addform.=''; $addform.=''; $addform.=''; $addform.=''; @@ -916,7 +915,7 @@ foreach ($listofreferent as $key => $value) { if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true { - print ''; + print ''; print img_picto($langs->trans('Unlink'), 'unlink'); print ''; } diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 8b718f1d898..725d99fb673 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -46,7 +46,7 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); // Load translation files required by the page @@ -377,6 +377,8 @@ if (count($tasksarray)>0) //var_dump($dateformatinput); //var_dump($dateformatinput2); + print '
'; + print '
'; print '
'."\n"; diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 7d75544ef93..0987a47e507 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -55,20 +55,20 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $listofstatus=array_keys($listofoppstatus); foreach ($listofstatus as $status) { - $labelstatus = ''; + $labelStatus = ''; $code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code'); - if ($code) $labelstatus = $langs->trans("OppStatus".$code); - if (empty($labelstatus)) $labelstatus=$listofopplabel[$status]; + if ($code) $labelStatus = $langs->trans("OppStatus".$code); + if (empty($labelStatus)) $labelStatus=$listofopplabel[$status]; - //$labelstatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; - //$labelstatus .= ' - '.price2num($listofoppstatus[$status]).'%'; + //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; + //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%'; - $dataseries[]=array($labelstatus, (isset($valsamount[$status])?(float) $valsamount[$status]:0)); + $dataseries[]=array($labelStatus, (isset($valsamount[$status])?(float) $valsamount[$status]:0)); if (! $conf->use_javascript_ajax) { print '
'; - print ''; + print ''; print ''; print "\n"; } diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 734af5cb7ff..a2526171b9b 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -45,7 +45,7 @@ if ($search_project_user == $user->id) $mine = 1; // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); @@ -139,18 +139,20 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print '
'.$labelstatus.''.$labelStatus.''.price((isset($valsamount[$status])?(float) $valsamount[$status]:0), 0, '', 1, -1, -1, $conf->currency).'
'; $i=0; foreach($listofsearchfields as $key => $value) { if ($i == 0) print ''; - print ''; + print ''; print ''; if ($i == 0) print ''; print ''; $i++; } print '
'.$langs->trans("Search").'
'; + print '
'; print ''; print '
'; } @@ -169,7 +171,7 @@ print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppst print '
'; -// Last modified projects +// Latest modified projects $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.tms as datem,"; $sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; @@ -241,7 +243,7 @@ if ($resql) } print ''; print ''.dol_print_date($db->jdate($obj->datem), 'day').''; - print ''.$projectstatic->LibStatut($obj->fk_statut, 5).''; + print ''.$projectstatic->LibStatut($obj->fk_statut, 3).''; print ''; $i++; } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 207bd245d08..ff361e75d3d 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -62,7 +62,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); // Security check $id = GETPOST("id", 'int'); $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result=restrictedArea($user, 'projet', $id, ''); if (!$user->rights->projet->lire) accessforbidden(); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 8524e940f36..6cbe9d68127 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -48,7 +48,7 @@ $title = $langs->trans("Projects"); // Security check $socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if ($socid > 0) { $soc = new Societe($db); @@ -76,7 +76,6 @@ $search_categ=GETPOST("search_categ", 'alpha'); $search_ref=GETPOST("search_ref", 'alpha'); $search_label=GETPOST("search_label", 'alpha'); $search_societe=GETPOST("search_societe", 'alpha'); -$search_year=GETPOST("search_year", 'int'); $search_status=GETPOST("search_status", 'int'); $search_opp_status=GETPOST("search_opp_status", 'alpha'); $search_opp_percent=GETPOST("search_opp_percent", 'alpha'); @@ -141,13 +140,16 @@ $arrayfields=array( 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -175,7 +177,6 @@ if (empty($reshook)) $search_ref=""; $search_label=""; $search_societe=""; - $search_year=""; $search_status=-1; $search_opp_status=-1; $search_opp_amount=''; diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index ef324bb63bb..73c9d39d64d 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -43,7 +43,7 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $permissionnote=$user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index f8480f8f322..a7e6bf510b3 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -38,10 +38,10 @@ $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); $year = GETPOST('year')>0?GETPOST('year'):$nowyear; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 2abfea6e64e..0bffd50ce62 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -66,8 +66,7 @@ $search_progressdeclare=GETPOST('search_progressdeclare'); $object = new Project($db); $taskstatic = new Task($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); +$extrafields = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); @@ -75,13 +74,13 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob if ($id > 0 || ! empty($ref)) { // fetch optionals attributes and labels - $extrafields_project->fetch_name_optionals_label($object->table_element); + $extrafields->fetch_name_optionals_label($object->table_element); } -$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); +$extrafields->fetch_name_optionals_label($taskstatic->table_element); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; @@ -115,14 +114,17 @@ $arrayfields=array( 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +// Extra fields project +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -260,8 +262,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) $task->progress = $progress; // Fill array 'array_options' with data from add form - $extrafields->fetch_name_optionals_label($task->table_element); - $ret = $extrafields_task->setOptionalsFromPost(null, $task); + $ret = $extrafields->setOptionalsFromPost(null, $task); $taskid = $task->create($user); @@ -604,9 +605,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields_task->attribute_label)) + if (empty($reshook) && ! empty($extrafields[$taskstatic->table_element]['label'])) { - print $taskstatic->showOptionals($extrafields_task, 'edit'); // Do not use $object here that is object of project + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } print ''; @@ -635,13 +636,15 @@ elseif ($id > 0 || ! empty($ref)) $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); // Extra fields - if (is_array($extrafields_task->attribute_label) && count($extrafields_task->attribute_label)) + if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach($extrafields_task->attribute_label as $key => $val) + foreach($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields_task->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields_task->attribute_label[$key], 'checked'=>(($extrafields_task->attribute_list[$key]<0)?0:1), 'position'=>$extrafields_task->attribute_pos[$key], 'enabled'=>(abs($extrafields_task->attribute_list[$key])!=3 && $extrafields_task->attribute_perms[$key])); + if (! empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } + $arrayfields = dol_sort_array($arrayfields, 'position'); print '
'; diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index d9a251b3c53..31211e59dbf 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -49,7 +49,7 @@ $planned_workload=((GETPOST('planned_workloadhour', 'int')!='' || GETPOST('plann // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index b09d8345177..aa94d413fc9 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -42,7 +42,7 @@ $project_ref=GETPOST('project_ref', 'alpha'); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. //$result = restrictedArea($user, 'projet', $id, 'projet_task'); if (! $user->rights->projet->lire) accessforbidden(); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 52795f7a249..1944de13f61 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -46,7 +46,7 @@ $project_ref = GETPOST('project_ref', 'alpha'); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. //$result=restrictedArea($user,'projet',$id,''); if (!$user->rights->projet->lire) accessforbidden(); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e13b7092b26..8718806004b 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -83,7 +83,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); $diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index de2707bf734..42dbaa48cc2 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -40,7 +40,7 @@ $project_ref = GETPOST('project_ref', 'alpha'); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index c94a412be9c..c9e8bc335e7 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -38,10 +38,10 @@ $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); $year = GETPOST('year')>0?GETPOST('year'):$nowyear; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 78431f983a4..0bc07537ccf 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -48,7 +48,7 @@ $planned_workload=((GETPOST('planned_workloadhour', 'int')!='' || GETPOST('plann // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2eb6697be82..24e5d067186 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -68,7 +68,7 @@ $search_valuebilled=GETPOST('search_valuebilled', 'int'); // Security check $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -88,11 +88,9 @@ $hookmanager->initHooks(array('projecttasktime','globalcard')); $object = new Task($db); $projectstatic = new Project($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); - -$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); -$extrafields_task->fetch_name_optionals_label($object->table_element); +$extrafields = new ExtraFields($db); +$extrafields->fetch_name_optionals_label($projectstatic->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); /* @@ -761,7 +759,6 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('tasktimelist')); - $extrafields = new ExtraFields($db); // Definition of fields for list $arrayfields=array(); @@ -777,13 +774,15 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); $arrayfields['valuebilled'] =array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((! empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT))?0:1) && $projectstatic->usage_bill_time)); // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } + $arrayfields = dol_sort_array($arrayfields, 'position'); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index d2f11419ef9..9b76f2b90b3 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -220,7 +220,7 @@ if ($format == 'rss') $result=readfile($outputfile); if (! $result) print 'File '.$outputfile.' was empty.'; - // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); + // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); exit; } else diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index adb6aa03c8d..48cdd1508e8 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -115,7 +115,7 @@ if (! empty($tag) && ($unsuscrib=='1')) */ // Update status communication of email (new usage) - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; $resql=$db->query($sql); //if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 5fd655f73ac..7cd935c4d2c 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -560,7 +560,6 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) else { $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - //print $adht->libelle; print ''; } // Moral/Physic attribute diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index f82e3549630..4a3d08f6602 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1725,6 +1725,7 @@ if ($action != 'dopayment') { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe print '
'; + print ''; print '
'; print ''.$langs->trans("CreditOrDebitCard").''; print '
'; @@ -1858,12 +1859,12 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment $service = 'StripeLive'; $servicestatus = 1; - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { $service = 'StripeTest'; $servicestatus = 0; } + $stripe = new Stripe($db); $stripeacc = $stripe->getStripeAccount($service); $stripecu = null; @@ -1871,49 +1872,47 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus); + $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. + $paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); + // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already payed) + //var_dump($paymentintent); if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); } } //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) //{ - print ' - - '; + print '
'; + print ' + + -
'; - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
'; - } + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
'; + } - print ' -
+ print '
'; + print ''; - '; + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
'; + } - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
'; - } + print '
+ +
'; - print '
- -
+ print ' + +
'; - - + print '
'; + print ''; + print ''; -
- -
'; - - print ''; - print ''; - - print ' -
'; + print '
'; //} if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) @@ -2006,7 +2005,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment { print $e->getMessage(); } - ?> + ?> // Code for payment with option STRIPE_USE_NEW_CHECKOUT set // Create a Stripe client. @@ -2049,11 +2048,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment }); - global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - ?> + ?> // Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set // Create a Stripe client. @@ -2153,11 +2152,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment } }); - + ?> // Old code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off and STRIPE_USE_NEW_CHECKOUT off // Create a Stripe client. @@ -2209,7 +2208,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment global->STRIPE_USE_3DSECURE)) // Ask credit card directly, no 3DS test { - ?> + ?> /* Use token */ stripe.createToken(card).then(function(result) { if (result.error) { @@ -2221,11 +2220,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment stripeTokenHandler(result.token); } }); - + ?> /* Use 3DS source */ stripe.createSource(card).then(function(result) { if (result.error) { @@ -2237,7 +2236,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment stripeSourceHandler(result.source); } }); - }); @@ -2291,7 +2290,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment form.submit(); } - '; diff --git a/htdocs/public/theme/common/company.png b/htdocs/public/theme/common/company.png new file mode 100644 index 00000000000..b6abd4432af Binary files /dev/null and b/htdocs/public/theme/common/company.png differ diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index ce93ec020c3..0bde25460e3 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -348,7 +348,7 @@ llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss print '
'; if ($action != "infos_success") { - $formticket->withfromsocid = isset($socid) ? $socid : $user->societe_id; + $formticket->withfromsocid = isset($socid) ? $socid : $user->socid; $formticket->withtitletopic = 1; $formticket->withcompany = 0; $formticket->withusercreate = 1; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 2c34cd55ee8..2e9dbe5f57b 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -72,7 +72,7 @@ $line_id = GETPOST('lineid', 'int')?GETPOST('lineid', 'int'):''; // Security check $socid=''; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; if ($origin == 'reception') $result=restrictedArea($user, $origin, $id); else { @@ -102,7 +102,6 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element_line); - // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -561,12 +560,12 @@ if (empty($reshook)) { if ($lines[$i]->id == $line_id) { - // delete single warehouse line - $line->id = $line_id; - if (! $error && $line->delete($user) < 0) - { - $error++; - } + // delete single warehouse line + $line->id = $line_id; + if (! $error && $line->delete($user) < 0) + { + $error++; + } } unset($_POST["lineid"]); } @@ -821,7 +820,7 @@ if ($action == 'create') print ""; // Note Private - if ($object->note_private && ! $user->societe_id) + if ($object->note_private && ! $user->socid) { print ''.$langs->trans("NotePrivate").''; print ''; @@ -834,7 +833,7 @@ if ($action == 'create') print ''; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int')); + $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -845,7 +844,7 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size"); + $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -869,17 +868,16 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + // Here $object can be of an object Order + $extrafields->fetch_name_optionals_label($object->table_element); + if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order - $orderExtrafields = new Extrafields($db); - $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); - if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); } print $object->showOptionals($extrafields, 'edit'); } - // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -951,31 +949,28 @@ if ($action == 'create') print ''; - print '
'; - print ''; - // Load receptions already done for same order $object->loadReceptions(); @@ -1115,59 +1110,57 @@ if ($action == 'create') $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number $deliverableQty=$dispatchLines[$indiceAsked]['qty']; + // Quantity to send + print ''; - - // Quantity to send - print ''; - - // Stock - if (! empty($conf->stock->enabled)) + else { - print ''; + } + + if (!empty($conf->productbatch->enabled)) + { + if (!empty($product->status_batch)) + { + print ''; + print ''; + print ''; } - - if (!empty($conf->productbatch->enabled)) - { - if (!empty($product->status_batch)) - { - print ''; - print ''; - print ''; - } - else { - print ''; - } + else { + print ''; } - print "\n"; + } + print "\n"; } //Display lines extrafields @@ -1446,7 +1439,7 @@ elseif ($id || $ref) print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ' '; print ' '; print ''; @@ -1454,16 +1447,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units, "weight"):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0,"weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print ''; @@ -1471,19 +1462,19 @@ elseif ($id || $ref) // Width print ''; // Height print ''; @@ -1499,7 +1490,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1519,15 +1510,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0,"volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -1792,8 +1781,6 @@ elseif ($id || $ref) print ''; // Volume print ''; @@ -2032,7 +2019,7 @@ elseif ($id || $ref) * Boutons actions */ - if (($user->societe_id == 0) && ($action!='presend')) + if (($user->socid == 0) && ($action!='presend')) { print '
'; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index dd819adff0a..48a35412987 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -48,7 +48,11 @@ class Reception extends CommonObject public $table_element="reception"; public $table_element_line="commande_fournisseur_dispatch"; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - public $picto = 'reception'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'reception'; public $socid; public $ref_supplier; @@ -80,8 +84,14 @@ class Reception extends CommonObject * @var int */ public $date_reception; - public $date_creation; - public $date_valid; + + /** + * @var integer|string date_creation + */ + public $date_creation; + + + public $date_valid; public $meths; public $listmeths; // List of carriers @@ -1136,44 +1146,44 @@ class Reception extends CommonObject /** * Return label of a status * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable global $langs; if ($mode==0) { - if ($statut==0) return $langs->trans($this->statuts[$statut]); - elseif ($statut==1) return $langs->trans($this->statuts[$statut]); - elseif ($statut==2) return $langs->trans($this->statuts[$statut]); + if ($status==0) return $langs->trans($this->statuts[$status]); + elseif ($status==1) return $langs->trans($this->statuts[$status]); + elseif ($status==2) return $langs->trans($this->statuts[$status]); } elseif ($mode==1) { - if ($statut==0) return $langs->trans('StatusReceptionDraftShort'); - elseif ($statut==1) return $langs->trans('StatusReceptionValidatedShort'); - elseif ($statut==2) return $langs->trans('StatusReceptionProcessedShort'); + if ($status==0) return $langs->trans('StatusReceptionDraftShort'); + elseif ($status==1) return $langs->trans('StatusReceptionValidatedShort'); + elseif ($status==2) return $langs->trans('StatusReceptionProcessedShort'); } elseif ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return img_picto($langs->trans('StatusReceptionProcessed'), 'statut6'); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return img_picto($langs->trans('StatusReceptionProcessed'), 'statut6'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - elseif ($statut==2) return img_picto($langs->trans('StatusReceptionProcessed'), 'statut6').' '.$langs->trans('StatusReceptionProcessed'); + if ($status==0) return img_picto($langs->trans($this->statuts[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status==1) return img_picto($langs->trans($this->statuts[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status==2) return img_picto($langs->trans('StatusReceptionProcessed'), 'statut6').' '.$langs->trans('StatusReceptionProcessed'); } elseif ($mode == 5) { - if ($statut==0) return $langs->trans('StatusReceptionDraftShort').' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return $langs->trans('StatusReceptionValidatedShort').' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - elseif ($statut==2) return $langs->trans('StatusReceptionProcessedShort').' '.img_picto($langs->trans('StatusReceptionProcessedShort'), 'statut6'); + if ($status==0) return $langs->trans('StatusReceptionDraftShort').' '.img_picto($langs->trans($this->statuts[$status]), 'statut0'); + elseif ($status==1) return $langs->trans('StatusReceptionValidatedShort').' '.img_picto($langs->trans($this->statuts[$status]), 'statut4'); + elseif ($status==2) return $langs->trans('StatusReceptionProcessedShort').' '.img_picto($langs->trans('StatusReceptionProcessedShort'), 'statut6'); } } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index c49eec5c82d..da074c420b5 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -44,7 +44,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'reception', $id, ''); $object = new Reception($db); diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 17b5cd03c06..5844365b56f 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -58,11 +58,12 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print '
'; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + // Stock + if (! empty($conf->stock->enabled)) + { + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); - print ''; - print ''; + // Show warehouse combo list + $ent = "entl".$indiceAsked; + $idl = "idl".$indiceAsked; + $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; + if ($line->fk_product > 0) + { + print ''; + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); + } } - else print $langs->trans("NA"); - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? - { - // Show warehouse combo list - $ent = "entl".$indiceAsked; - $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; - if ($line->fk_product > 0) - { - print ''; - print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); - } - } - else - { - print $langs->trans("Service"); - } + print $langs->trans("Service"); + } + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, ""); + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, ""); print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, ""); - print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, ""); - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string($object->width_units, "size"):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->reception->creer).''; - if($action=='edittrueHeight') + if ($action=='edittrueHeight') { print '
'; print ''; print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); print ' '; print ' '; print '
'; @@ -1491,7 +1482,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units, "size"):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string($object->depth_units, "size"):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - - $text=$lines[$i]->product->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->product->description)); @@ -1959,13 +1946,13 @@ elseif ($id || $ref) // Weight print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->weight_units, "weight"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->volume_units, "volume"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); else print ' '; print '
'; print ''; print ''; - print "
'.$langs->trans("Search").'
'; print $langs->trans("Reception").':

\n"; + print "

\n"; } /* @@ -93,6 +94,7 @@ if ($resql) $num = $db->num_rows($resql); if ($num) { + print '
'; print ''; print ''; print ''; @@ -116,7 +118,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("ReceptionsToValidate").'

"; + print "

"; } } @@ -143,6 +145,7 @@ if ($resql) $langs->load("orders"); $i = 0; + print '
'; print ''; print ''; print ''; @@ -172,7 +175,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("SuppliersOrdersToProcess").'

"; + print "

"; } } @@ -203,6 +206,7 @@ if ( $resql ) if ($num) { $i = 0; + print '
'; print ''; print ''; print ''; @@ -231,7 +235,7 @@ if ( $resql ) print ''; $i++; } - print "
'.$langs->trans("SuppliersOrdersInProcess").'

"; + print "

"; } } else dol_print_error($db); @@ -263,6 +267,7 @@ if ($resql) if ($num) { $i = 0; + print '
'; print ''; print ''; print ''; @@ -289,7 +294,7 @@ if ($resql) print ''; $i++; } - print "
'.$langs->trans("LastReceptions", $num).'

"; + print "

"; } $db->free($resql); } diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index f90f1f73df1..a7d7c51b7b1 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -34,10 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->load("receptions"); -$langs->load("deliveries"); -$langs->load('companies'); -$langs->load('bills'); +$langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills')); $socid=GETPOST('socid', 'int'); $massaction=GETPOST('massaction', 'alpha'); @@ -45,7 +42,7 @@ $toselect = GETPOST('toselect', 'array'); // Security check $receptionid = GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'reception', $receptionid, ''); $diroutputmassaction=$conf->reception->dir_output . '/temp/massgeneration/'.$user->id; @@ -79,12 +76,14 @@ $contextpage='receptionlist'; $viewstatut=GETPOST('viewstatut'); +$object = new Reception($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('receptionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('reception'); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost(null, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -111,15 +110,17 @@ $arrayfields=array( 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))) ); - // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -145,7 +146,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_town=''; $search_zip=""; $search_state=""; - $search_type=''; $search_country=''; $search_type_thirdparty=''; $search_billed=''; @@ -305,29 +305,28 @@ if (empty($reshook)) { $fk_parent_line = 0; } - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->qty, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - 'HT', - $product_type, - $i, - false, - 0, - null, - $lines[$i]->rowid, - 0, - $lines[$i]->ref_supplier - + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->qty, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + 'HT', + $product_type, + $i, + false, + 0, + null, + $lines[$i]->rowid, + 0, + $lines[$i]->ref_supplier ); $rcp->add_object_linked('facture_fourn_det', $result); @@ -533,9 +532,9 @@ if ($resql) } - $arrayofmassactions = array( -// 'presend'=>$langs->trans("SendByMail"), -); + $arrayofmassactions = array( + // 'presend'=>$langs->trans("SendByMail"), + ); if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier"); if($massaction == 'createbills') $arrayofmassactions=array(); @@ -628,8 +627,9 @@ if ($resql) print '
'; print ''."\n"; - // Fields title search - print ''; + // Fields title search + // -------------------------------------------------------------------- + print ''; // Ref if (! empty($arrayfields['e.ref']['checked'])) { @@ -694,28 +694,8 @@ if ($resql) print ''; } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -902,23 +882,8 @@ if ($resql) } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index cbc1185aaab..5a2e8745cb7 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -48,7 +48,7 @@ $action=GETPOST('action', 'alpha'); // Security check $socid=''; -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result=restrictedArea($user, $origin, $origin_id); $object = new Reception($db); diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 76315ccce03..06304a2afb8 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -35,10 +35,10 @@ $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -74,7 +74,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png'; } @@ -114,7 +114,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png'; } @@ -152,7 +152,7 @@ if (! $mesg) /* $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png'; } diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 944e1f5e4f5..e4bae7558d1 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -42,38 +42,38 @@ $langs->load("receptions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); $total=0; $ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> - - + + + if ($user->rights->reception->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> - 1) { diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index 0f2e79ef86f..803190ec699 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -37,6 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; // Load translation files required by the page $langs->load("companies"); +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + if (GETPOST('actioncode', 'array')) { $actioncode=GETPOST('actioncode', 'array', 3); @@ -48,21 +55,6 @@ else } $search_agenda_label=GETPOST('search_agenda_label'); -// Security check -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -if ($user->societe_id) $id=$user->societe_id; -// Protection if external user -if ($user->socid > 0) -{ - accessforbidden(); -} - -if( ! $user->rights->resource->read) -{ - accessforbidden(); -} - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -74,9 +66,20 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep,a.id'; if (! $sortorder) $sortorder='DESC,DESC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new DolResource($db); +$object->fetch($id, $ref); + +// Initialize technical objects +//$object=new MyObject($db); +$extrafields = new ExtraFields($db); $hookmanager->initHooks(array('agendaresource')); +// Security check +if( ! $user->rights->resource->read) +{ + accessforbidden(); +} + /* * Actions @@ -110,10 +113,9 @@ if (empty($reshook)) */ $contactstatic = new Contact($db); - $form = new Form($db); -if ($id > 0 || $ref) +if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -121,9 +123,6 @@ if ($id > 0 || $ref) $langs->load("companies"); $picto = 'resource'; - $object = new Dolresource($db); - $result = $object->fetch($id); - $title=$langs->trans("Agenda"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref." - ".$title; llxHeader('', $title); @@ -138,13 +137,15 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; - $shownav = 1; - if ($user->societe_id && ! in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + $morehtmlref='
'; + $morehtmlref.='
'; - dol_banner_tab($object, 'id', $linkback, $shownav, 'id'); + $shownav = 1; + if ($user->socid && ! in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; - print '
'; print '
'; @@ -153,11 +154,9 @@ if ($id > 0 || $ref) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { - print '
'; - - $param='&id='.$id; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param='&id='.$object->id.'&socid='.$socid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 2b4092671dc..f52da4934b0 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -63,9 +63,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); -/******************************************************************* - * ACTIONS - ********************************************************************/ +/* + * Actions + */ $hookmanager->initHooks(array('resource', 'resource_card','globalcard')); $parameters=array('resource_id'=>$id); @@ -211,18 +211,17 @@ if (empty($reshook)) } -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * View + */ + $title = $langs->trans($action == 'create' ? 'AddResource' : 'ResourceSingular'); llxHeader('', $title, ''); $form = new Form($db); $formresource = new FormResource($db); -if ($action == 'create' || $object->fetch($id) > 0) +if ($action == 'create' || $object->fetch($id, $ref) > 0) { if ($action == 'create') { diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index c85f040f896..db64c635fd5 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -39,7 +39,10 @@ class Dolresource extends CommonObject */ public $table_element='resource'; - public $picto = 'resource'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'resource'; public $resource_id; public $resource_type; diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index 872078ac51d..3e2a004e194 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -39,7 +39,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); $object = new DolResource($db); diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index fef78e8088c..e023134b9f5 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -44,7 +44,7 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); @@ -82,7 +82,7 @@ $form = new Form($db); llxHeader('', $langs->trans("Resource")); -if ($object->id) +if ($object->id > 0) { $object->fetch_thirdparty(); @@ -100,7 +100,7 @@ if ($object->id) } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index a0c1a724ed8..2ab64799f1d 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -357,7 +357,7 @@ else } $morehtmlref.='
'; - dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); + dol_banner_tab($act, 'element_id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); print '
'; @@ -453,7 +453,7 @@ else dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($socstatic, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom', '', '&element='.$element); + dol_banner_tab($socstatic, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '&element='.$element); print '
'; @@ -557,7 +557,7 @@ else dol_fiche_head($head, 'resources', $titre, -1, $picto); $shownav = 1; - if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element); dol_fiche_end(); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index ee1ec735086..0f003f05eb6 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -113,19 +113,17 @@ $arrayfields = array( ), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach ($extrafields->attribute_label as $key => $val) { - $typeofextrafield=$extrafields->attribute_type[$key]; - if ($typeofextrafield!='separate') { - $arrayfields["ef." . $key] = array( - 'label' => $extrafields->attribute_label[$key], - 'checked' => $extrafields->attribute_list[$key], - 'position' => $extrafields->attribute_pos[$key], - 'enabled' => $extrafields->attribute_perms[$key] - ); - } +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index 8c7f106285f..322088ef317 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -37,7 +37,7 @@ $ref = GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'resource', $id, 'resource'); $object = new DolResource($db); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 21ffa62bb8f..4e9b9dac118 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -48,7 +48,7 @@ $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOS // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); $object = new PaymentSalary($db); @@ -390,19 +390,20 @@ if ($id) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->salaries->write) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index a7b92d63efb..7bd9a14a718 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -45,7 +45,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index 5ba53c45665..a96db0cbd5f 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -36,7 +36,7 @@ $action=GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 816b734ea23..02a729cb16c 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -33,7 +33,7 @@ $langs->loadLangs(array("compta","salaries","bills","hrm")); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index a301dc927a1..38a568d5fc0 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -38,7 +38,7 @@ $id = GETPOST('id', 'int'); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); $nowyear=strftime("%Y", dol_now()); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 56b92c42057..e7184764e7b 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -311,17 +311,17 @@ if ($action == 'sethideinactivethirdparty') } } if($action=='setonsearchandlistgooncustomerorsuppliercard'){ - $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 231174a0afa..ae2622d7f93 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -47,7 +47,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -117,7 +117,7 @@ if ($socid > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 28f2ec7306b..aafcd8ffc69 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -266,7 +266,7 @@ abstract class ActionsCardCommon $this->tpl['showhead']=dol_get_fiche_head($head, 'card', '', 0, 'company'); $this->tpl['showend']=dol_get_fiche_end(); - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); $this->tpl['checkcustomercode'] = $this->object->check_codeclient(); $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur(); diff --git a/htdocs/societe/canvas/company/tpl/card_create.tpl.php b/htdocs/societe/canvas/company/tpl/card_create.tpl.php index 0557f8608f9..80e0a23bdd6 100644 --- a/htdocs/societe/canvas/company/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_create.tpl.php @@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf)) control->tpl['error']; ?> use_javascript_ajax) { ?> -control->tpl['ajax_selecttype']; ?> + control->tpl['ajax_selecttype']; ?>
-trans("ThirdPartyType") ?>:   + trans("ThirdPartyType") ?>:   -trans("CompanyFoundation"); ?>     + trans("CompanyFoundation"); ?>     trans("Individual"); ?> (trans("ToCreateContactWithSameName") ?>)

-control->tpl['ajax_selectcountry']; ?> + control->tpl['ajax_selectcountry']; ?> control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?> @@ -96,14 +96,15 @@ if (empty($conf) || ! is_object($conf)) -control->tpl['suppliercategory']) > 0) { ?> + control->tpl['suppliercategory']) > 0) { ?>
- + barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> diff --git a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php index f2de27c0ba1..3f1740d395c 100644 --- a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php @@ -23,7 +23,6 @@ if (empty($conf) || ! is_object($conf)) exit; } - $contact = $GLOBALS['objcanvas']->control->object; ?> @@ -59,7 +58,7 @@ $contact = $GLOBALS['objcanvas']->control->object; @@ -99,7 +98,7 @@ $contact = $GLOBALS['objcanvas']->control->object; control->tpl['ismodifiable_suppliercode']) { ?> - control->tpl['suppliercode']; ?> + control->tpl['suppliercode']; ?> @@ -116,12 +115,11 @@ if ($this->control->tpl['fournisseur']) { - -barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> @@ -209,9 +207,9 @@ for ($i=1; $i<=4; $i++) { - +control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> +if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
 '; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print '
trans("Reception"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' getNomUrl(1); ?>date_delivery, 'day'); ?>date_delivery, 'day'); ?> rights->reception->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> - element != 'order_supplier') { - ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - element != 'order_supplier') { ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> +
trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?>
trans('Gencod'); ?> control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?> - control->tpl['prefix_comm']; ?> + control->tpl['prefix_comm']; ?> @@ -78,7 +77,7 @@ $contact = $GLOBALS['objcanvas']->control->object; control->tpl['ismodifiable_customercode']) { ?> - control->tpl['customercode']; ?> + control->tpl['customercode']; ?> trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?>
trans('Gencod'); ?> trans("DefaultLang"); ?> control->tpl['select_lang']; ?>

diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 69e7dc48171..9048b272995 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -25,10 +25,8 @@ if (empty($conf) || ! is_object($conf)) $soc = $GLOBALS['objcanvas']->control->object; -?> - -\n"; $head = societe_prepare_head($soc); diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index 54d09bf3c29..8493027bef7 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf)) control->tpl['error']; ?> use_javascript_ajax) { ?> -control->tpl['ajax_selecttype']; ?> + control->tpl['ajax_selecttype']; ?>
-trans("ThirdPartyType") ?>:   + trans("ThirdPartyType") ?>:   -trans("CompanyFoundation"); ?>     + trans("CompanyFoundation"); ?>     trans("Individual"); ?> (trans("ToCreateContactWithSameName") ?>)

-control->tpl['ajax_selectcountry']; ?> + control->tpl['ajax_selectcountry']; ?>
" method="POST" name="formsoc"> @@ -106,14 +106,15 @@ if (empty($conf) || ! is_object($conf)) -control->tpl['suppliercategory']) > 0) { ?> + control->tpl['suppliercategory']) > 0) { ?> trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?> - + barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> trans('Gencod'); ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 487da67c593..976b00962d8 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -56,7 +56,7 @@ if (empty($conf) || ! is_object($conf)) control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?> - control->tpl['prefix_comm']; ?> + control->tpl['prefix_comm']; ?> @@ -75,7 +75,7 @@ if (empty($conf) || ! is_object($conf)) control->tpl['ismodifiable_customercode']) { ?> - control->tpl['customercode']; ?> + control->tpl['customercode']; ?> @@ -96,7 +96,7 @@ if (empty($conf) || ! is_object($conf)) control->tpl['ismodifiable_suppliercode']) { ?> - control->tpl['suppliercode']; ?> + control->tpl['suppliercode']; ?> @@ -113,7 +113,7 @@ if ($this->control->tpl['fournisseur']) { trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?> - diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index e7e122b9114..b1e5d052adc 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -25,19 +25,15 @@ if (empty($conf) || ! is_object($conf)) $object = $GLOBALS['objcanvas']->control->object; -?> - -\n"; $head = societe_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); -?> - -control->tpl['error']) echo $this->control->tpl['error']; ?> -control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> +if ($this->control->tpl['error']) echo $this->control->tpl['error']; +if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> @@ -230,6 +226,5 @@ $result=show_contacts($conf, $langs, $db, $object); // Projects list $result=show_projects($conf, $langs, $db, $object); -?> - +print "\n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index f4016dc4f5a..edfb3767f11 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -61,7 +61,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; if (empty($socid) && $action == 'view') $action='create'; $object = new Societe($db); @@ -599,11 +599,11 @@ if (empty($reshook)) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; + $errors[] = "ErrorFileSizeTooLarge"; + break; case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + $errors[] = "ErrorFilePartiallyUploaded"; + break; } } // Gestion du logo de la société @@ -764,11 +764,11 @@ if (empty($reshook)) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; + $errors[] = "ErrorFileSizeTooLarge"; + break; case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + $errors[] = "ErrorFilePartiallyUploaded"; + break; } } // Gestion du logo de la société @@ -1855,7 +1855,7 @@ else print ''; } else - { + { print $object->code_fournisseur; print ''; } @@ -2241,7 +2241,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -2663,7 +2663,7 @@ else if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").'
'."\n"; + print ''.$langs->trans("Modify").''."\n"; } if (! empty($conf->adherent->enabled)) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 1ed4916e3c9..42fae860666 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -850,6 +850,46 @@ class Thirdparties extends DolibarrApi return $result; } + /** + * Get representatives of thirdparty + * + * @param int $id ID of the thirdparty + * @param string $mode 0=Array with properties, 1=Array of id. + * + * @url GET {id}/representatives + * + * @return array List of representatives of thirdparty + * + * @throws 400 + * @throws 401 + * @throws 404 + */ + public function getSalesRepresentatives($id, $mode = 0) + { + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + if(empty($id)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $result = $this->company->getSalesRepresentatives(DolibarrApiAccess::$user, $mode); + + return $result; + } + /** * Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...) * @@ -1060,12 +1100,13 @@ class Thirdparties extends DolibarrApi $returnAccounts = array(); - foreach($accounts as $account){ - $object= array(); - foreach($account as $key => $value) - if(in_array($key, $fields)){ + foreach ($accounts as $account) { + $object = array(); + foreach ($account as $key => $value) { + if (in_array($key, $fields)) { $object[$key] = $value; } + } $returnAccounts[] = $object; } @@ -1264,7 +1305,7 @@ class Thirdparties extends DolibarrApi } } - /** + /** * Get a specific gateway attached to a thirdparty (by specifying the site key) * * @param int $id ID of thirdparty @@ -1321,12 +1362,13 @@ class Thirdparties extends DolibarrApi $returnAccounts = array(); - foreach($accounts as $account){ - $object= array(); - foreach($account as $key => $value) - if(in_array($key, $fields)){ + foreach ($accounts as $account) { + $object = array(); + foreach ($account as $key => $value) { + if(in_array($key, $fields)) { $object[$key] = $value; } + } $returnAccounts[] = $object; } @@ -1439,16 +1481,18 @@ class Thirdparties extends DolibarrApi $account->fk_soc = $id; $account->site = $site; - if ($account->create(DolibarrApiAccess::$user) < 0) + if ($account->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error creating SocieteAccount entity.'); - // We found an existing SocieteAccount entity, we are replacing it + } + // We found an existing SocieteAccount entity, we are replacing it } else { - if(isset($request_data['site']) && $request_data['site'] !== $site) { + if (isset($request_data['site']) && $request_data['site'] !== $site) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows !== 0) + if ($result->num_rows !== 0) { throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key."); + } } $obj = $db->fetch_object($result); @@ -1632,6 +1676,13 @@ class Thirdparties extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->nom); // ->name already defined and nom deprecated + unset($object->name_bis); // ->name_alias already defined + unset($object->note); // ->note_private and note_public already defined + unset($object->departement); + unset($object->departement_code); + unset($object->pays); + unset($object->particulier); + unset($object->prefix_comm); unset($object->total_ht); unset($object->total_tva); @@ -1642,6 +1693,8 @@ class Thirdparties extends DolibarrApi unset($object->lines); unset($object->thirdparty); + unset($object->fk_delivery_address); // deprecated feature + return $object; } @@ -1664,12 +1717,12 @@ class Thirdparties extends DolibarrApi return $thirdparty; } - /** - * Fetch properties of a thirdparty object. - * - * Return an array with thirdparty informations - * - * @param int $rowid Id of third party to load + /** + * Fetch properties of a thirdparty object. + * + * Return an array with thirdparty informations + * + * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) * @param string $ref_int Internal reference of third party (not used by dolibarr) @@ -1681,38 +1734,38 @@ class Thirdparties extends DolibarrApi * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) * @param string $email Email of third party (Warning, this can return several records) * @param string $ref_alias Name_alias of third party (Warning, this can return several records) - * @return array|mixed data without useless information - * - * @throws RestException - */ - private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') - { - if(! DolibarrApiAccess::$user->rights->societe->lire) { - throw new RestException(401); - } + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') + { + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } - $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); - if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); - } + $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; - } + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; + } - $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote); - $this->company->absolute_discount = price2num($absolute_discount, 'MT'); - $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT'); + $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote); + $this->company->absolute_discount = price2num($absolute_discount, 'MT'); + $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT'); - return $this->_cleanObjectDatas($this->company); - } + return $this->_cleanObjectDatas($this->company); + } } diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index 9c6c15e2f66..c345d195935 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -63,7 +63,7 @@ class Client extends Societe $sql = "SELECT count(s.rowid) as nb, s.client"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 45f11c5a4ce..d403499a79e 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/societe/class/companybankaccount.class.php - * \ingroup societe - * \brief File of class to manage bank accounts description of third parties + * \file htdocs/societe/class/companybankaccount.class.php + * \ingroup societe + * \brief File of class to manage bank accounts description of third parties */ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; @@ -174,27 +174,27 @@ class CompanyBankAccount extends Account $result = $this->db->query($sql); if ($result) { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_RIB_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - if(! $error ) + if (! $notrigger) { - return 1; + // Call trigger + $result=$this->call_trigger('COMPANY_RIB_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + if(! $error ) + { + return 1; + } + else + { + return -1; + } } else { - return -1; + return 1; } } else - { - return 1; - } - } - else { dol_print_error($this->db); return -1; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c999c9016f4..9ba0bdcfd12 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -69,6 +69,9 @@ class Societe extends CommonObject */ protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto = 'company'; /** @@ -316,11 +319,12 @@ class Societe extends CommonObject * @var string */ public $user_modification; + /** - * Date of creation - * @var string + * @var integer|string date_creation */ public $date_creation; + /** * User that created the thirdparty * @var User @@ -395,9 +399,16 @@ class Societe extends CommonObject */ public $note_public; - //! code statut prospect + /** + * Status prospect id + * @var int + */ public $stcomm_id; - public $statut_commercial; + /** + * Status prospect label + * @var int + */ + public $status_prospect_label; /** * Assigned price level @@ -1226,7 +1237,7 @@ class Societe extends CommonObject } } else - { + { $this->db->rollback(); dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING); return -3; @@ -1350,9 +1361,9 @@ class Societe extends CommonObject $this->state = ($obj->state!='-'?$obj->state:''); $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); - $libelle=($transcode!='StatusProspect'.$obj->fk_stcomm?$transcode:$obj->stcomm); - $this->stcomm_id = $obj->fk_stcomm; // id statut commercial - $this->statut_commercial = $libelle; // libelle statut commercial + $label = ($transcode!='StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcomm; // id status prospect + $this->status_prospect_label = $label; // label status prospect $this->email = $obj->email; $this->skype = $obj->skype; @@ -1865,7 +1876,7 @@ class Societe extends CommonObject $reparray=array(); - $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; + $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.office_phone, u.job, u.email, u.statut, u.entity, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { @@ -1894,6 +1905,8 @@ class Societe extends CommonObject $reparray[$i]['lastname']=$obj->lastname; $reparray[$i]['firstname']=$obj->firstname; $reparray[$i]['email']=$obj->email; + $reparray[$i]['phone']=$obj->office_phone; + $reparray[$i]['job']=$obj->job; $reparray[$i]['statut']=$obj->statut; $reparray[$i]['entity']=$obj->entity; $reparray[$i]['login']=$obj->login; @@ -2126,8 +2139,8 @@ class Societe extends CommonObject if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { - $label.= '' . $langs->trans("ShowCustomer") . ''; - $linkstart = ''; + $linkstart = 'trans("InActivity"); + $this->labelStatus[0] = $langs->trans("ActivityCeased"); + $this->labelStatus[1] = $langs->trans("InActivity"); + $this->labelStatusShort[0] = $langs->trans("ActivityCeased"); + $this->labelStatusShort[1] = $langs->trans("InActivity"); } - elseif ($mode == 1) - { - if ($statut==0) return $langs->trans("ActivityCeased"); - elseif ($statut==1) return $langs->trans("InActivity"); - } - elseif ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - elseif ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - elseif ($mode == 5) - { - if ($statut==0) return ''.$langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 6) - { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -2378,6 +2368,7 @@ class Societe extends CommonObject $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; $sql.= " WHERE fk_soc = ".$this->id; + $sql.= " ORDER BY lastname, firstname"; $resql=$this->db->query($sql); if ($resql) @@ -3088,8 +3079,8 @@ class Societe extends CommonObject //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else + return 1; + else return -1; //algorithm checking type code CIF @@ -3101,29 +3092,29 @@ class Societe extends CommonObject //Chek special NIF if (preg_match('/^[KLM]{1}/', $string)) if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else + return 1; + else return -1; //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else + return 2; + else return -2; //Check NIE T if (preg_match('/^[T]{1}/', $string)) if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else + return 3; + else return -3; //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else + return 3; + else return -3; //Can not be verified @@ -3734,12 +3725,12 @@ class Societe extends CommonObject /** * Return label of a given status * - * @param int|string $statut Id or code for prospection status + * @param int|string $status Id or code for prospection status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @param string $label Label to use for status for added status * @return string Libelle du statut */ - public function LibProspCommStatut($statut, $mode = 0, $label = '') + public function LibProspCommStatut($status, $mode = 0, $label = '') { // phpcs:enable global $langs; @@ -3747,38 +3738,38 @@ class Societe extends CommonObject if ($mode == 2) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } if ($mode == 3) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0); } } if ($mode == 4) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } @@ -3975,19 +3966,19 @@ class Societe extends CommonObject /** * Return the label of the customer/prospect status * - * @param int $statut Id statut + * @param int $status Id statut * @return string Libelle du statut */ - public function LibCustProspStatut($statut) + public function LibCustProspStatut($status) { // phpcs:enable global $langs; $langs->load('companies'); - if ($statut==0) return $langs->trans("NorProspectNorCustomer"); - elseif ($statut==1) return $langs->trans("Customer"); - elseif ($statut==2) return $langs->trans("Prospect"); - elseif ($statut==3) return $langs->trans("ProspectCustomer"); + if ($status==0) return $langs->trans("NorProspectNorCustomer"); + elseif ($status==1) return $langs->trans("Customer"); + elseif ($status==2) return $langs->trans("Prospect"); + elseif ($status==3) return $langs->trans("ProspectCustomer"); } diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index bf94c522f68..f93dfd0ea68 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -124,7 +124,13 @@ class SocieteAccount extends CommonObject public $date_last_login; public $date_previous_login; public $note_private; + + /** + * @var integer|string date_creation + */ public $date_creation; + + public $tms; /** diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 85df9b4f069..0039504e950 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); if ($socid > 0) $object->fetch($socid); @@ -109,7 +109,7 @@ dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company') $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 1b119e9c89a..352c9c53c35 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -56,7 +56,7 @@ $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm'); $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; if (empty($socid) && $action == 'view') $action='create'; $object = new Societe($db); @@ -150,7 +150,7 @@ dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 971944c4f30..8e0c36aa451 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -40,10 +40,10 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { unset($action); - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'societe', $id, '&societe'); @@ -117,7 +117,7 @@ if ($object->id) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 5bd493fdeba..5aadc5d3606 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -38,10 +38,10 @@ $hookmanager->initHooks(array('thirdpartiesindex')); $langs->load("companies"); $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; // Security check -$result=restrictedArea($user, 'societe', 0, '', '', '', ''); +$result = restrictedArea($user, 'societe', 0, '', '', '', ''); $thirdparty_static = new Societe($db); @@ -51,10 +51,10 @@ $thirdparty_static = new Societe($db); */ $transAreaType = $langs->trans("ThirdPartiesArea"); -$helpurl='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros'; +$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros'; llxHeader("", $langs->trans("ThirdParties"), $helpurl); -$linkback=''; +$linkback = ''; print load_fiche_titre($transAreaType, $linkback, 'companies'); @@ -73,26 +73,26 @@ $third = array( 'supplier' => 0, 'other' =>0 ); -$total=0; +$total = 0; $sql = "SELECT s.rowid, s.client, s.fournisseur"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND s.rowid = ".$socid; -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible //print $sql; $result = $db->query($sql); if ($result) { while ($objp = $db->fetch_object($result)) { - $found=0; - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } - if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } + $found = 0; + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; } + if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; } if ($found) $total++; } } @@ -101,14 +101,14 @@ else dol_print_error($db); print '
'; print '
'."\n"; print ''; -if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) +if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) { print '"; - $statstring.= ''; - $statstring.= ""; + $statstring .= ''; + $statstring .= ""; } - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { - $statstring.= ""; - $statstring.= ''; - $statstring.= ""; + $statstring .= ""; + $statstring .= ''; + $statstring .= ""; } - if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) + if (!empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) { $statstring2 = ""; - $statstring2.= ''; - $statstring2.= ""; + $statstring2 .= ''; + $statstring2 .= ""; } print $statstring; print $statstring2; @@ -149,7 +149,7 @@ print ''; print '
'.$langs->trans("Statistics").'
'; - $dataseries=array(); - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); - if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); + $dataseries = array(); + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier'])); + if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other'])); include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); @@ -122,23 +122,23 @@ if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(rou } else { - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { $statstring = "
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'; print '
'; -if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) +if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $elementtype = 'societe'; @@ -161,41 +161,41 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS print ''.$langs->trans("Categories").''; print ''; $sql = "SELECT c.label, count(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; - $sql.= " WHERE c.type = 2"; - if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; - $sql.= " AND c.entity IN (".getEntity('category').")"; - $sql.= " GROUP BY c.label"; - $total=0; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; + $sql .= " WHERE c.type = 2"; + if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; + $sql .= " AND c.entity IN (".getEntity('category').")"; + $sql .= " GROUP BY c.label"; + $total = 0; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i=0; - if (! empty($conf->use_javascript_ajax) ) + $i = 0; + if (!empty($conf->use_javascript_ajax)) { - $dataseries=array(); - $rest=0; - $nbmax=10; + $dataseries = array(); + $rest = 0; + $nbmax = 10; while ($i < $num) { $obj = $db->fetch_object($result); if ($i < $nbmax) { - $dataseries[]=array($obj->label, round($obj->nb)); + $dataseries[] = array($obj->label, round($obj->nb)); } else { - $rest+=$obj->nb; + $rest += $obj->nb; } - $total+=$obj->nb; + $total += $obj->nb; $i++; } if ($i > $nbmax) { - $dataseries[]=array($langs->trans("Other"), round($rest)); + $dataseries[] = array($langs->trans("Other"), round($rest)); } include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -214,7 +214,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS $obj = $db->fetch_object($result); print ''.$obj->label.''.$obj->nb.''; - $total+=$obj->nb; + $total += $obj->nb; $i++; } } @@ -232,22 +232,22 @@ print '
'; /* - * Last third parties modified + * Latest modified third parties */ -$max=15; +$max = 15; $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; -$sql.= ", s.code_client"; -$sql.= ", s.code_fournisseur"; -$sql.= ", s.logo"; -$sql.= ", s.canvas, s.tms as datem, s.status as status"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND s.rowid = ".$socid; -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; -$sql.= $db->order("s.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= ", s.code_client"; +$sql .= ", s.code_fournisseur"; +$sql .= ", s.logo"; +$sql .= ", s.canvas, s.tms as datem, s.status as status"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; +$sql .= $db->order("s.tms", "DESC"); +$sql .= $db->plimit($max, 0); //print $sql; $result = $db->query($sql); @@ -274,16 +274,16 @@ if ($result) { $objp = $db->fetch_object($result); - $thirdparty_static->id=$objp->rowid; - $thirdparty_static->name=$objp->name; - $thirdparty_static->client=$objp->client; - $thirdparty_static->fournisseur=$objp->fournisseur; + $thirdparty_static->id = $objp->rowid; + $thirdparty_static->name = $objp->name; + $thirdparty_static->client = $objp->client; + $thirdparty_static->fournisseur = $objp->fournisseur; $thirdparty_static->logo = $objp->logo; - $thirdparty_static->datem=$db->jdate($objp->datem); - $thirdparty_static->status=$objp->status; + $thirdparty_static->datem = $db->jdate($objp->datem); + $thirdparty_static->status = $objp->status; $thirdparty_static->code_client = $objp->code_client; $thirdparty_static->code_fournisseur = $objp->code_fournisseur; - $thirdparty_static->canvas=$objp->canvas; + $thirdparty_static->canvas = $objp->canvas; $thirdparty_static->email = $objp->email; print ''; @@ -293,21 +293,21 @@ if ($result) print "\n"; // Type print ''; - if ($thirdparty_static->client==1 || $thirdparty_static->client==3) + if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3) { - $thirdparty_static->name=$langs->trans("Customer"); + $thirdparty_static->name = $langs->trans("Customer"); print $thirdparty_static->getNomUrl(0, 'customer', 0, 1); } if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; - if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $thirdparty_static->name=$langs->trans("Prospect"); + $thirdparty_static->name = $langs->trans("Prospect"); print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1); } - if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) + if (!empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) { if ($thirdparty_static->client) print " / "; - $thirdparty_static->name=$langs->trans("Supplier"); + $thirdparty_static->name = $langs->trans("Supplier"); print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1); } print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7420c417aae..8f0d1895c1b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -55,7 +55,7 @@ if ($contextpage == 'poslist') // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, ''); $search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); @@ -210,15 +210,16 @@ $arrayfields=array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } - -$object = new Societe($db); +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -233,7 +234,7 @@ if ($action=="change") // Change customer for TakePOS // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); - ?> + ?> - '; if ($companystatic->fk_parent > 0) { - $companyparent->fetch($companystatic->fk_parent); - print $companyparent->getNomUrl(1); + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(1); } print ""; if (! $i) $totalarray['nbfield']++; @@ -1278,7 +1279,7 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''.$companystatic->getLibStatut(3).''; + print ''.$companystatic->getLibStatut(5).''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.import_key']['checked'])) diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 4d20f050518..0f2bc4d8002 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -35,7 +35,7 @@ $langs->load("companies"); // Security check $id = GETPOST('id')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); @@ -78,7 +78,7 @@ if ($object->id > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); $cssclass='titlefield'; //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 54536fa7502..d3f4c30f575 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -39,7 +39,7 @@ $actionid = GETPOST('actionid'); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -156,7 +156,7 @@ if ($result > 0) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 6cb1b4abbbe..5ed2b9a148f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -44,7 +44,7 @@ $langs->loadLangs(array("companies","commercial","banks","bills",'paypal','strip // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', '', ''); $id=GETPOST("id", "int"); @@ -564,13 +564,13 @@ if (empty($reshook)) $db->begin(); - if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; - } else { - $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; - $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } + if (empty($newcu)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + } else { + $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; + $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; + $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } $resql = $db->query($sql); $num = $db->num_rows($resql); @@ -609,37 +609,33 @@ if (empty($reshook)) $db->begin(); - if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; - } else { - try { - $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); - $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; - $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; - $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } - catch(Exception $e) - { - $error++; - setEventMessages($e->getMessage(), null, 'errors'); - } + if (empty($newsup)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; + } else { + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; + $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; + $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } catch(Exception $e) { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); } + } $resql = $db->query($sql); $num = $db->num_rows($resql); if (empty($num) && !empty($newsup)) { - try { - $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); - $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; - $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; - } - catch(Exception $e) - { + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; + $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; + } catch(Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -700,23 +696,25 @@ if (empty($reshook)) { try { if (preg_match('/pm_/', $source)) - { - $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); - if ($payment_method) - { - $payment_method->detach(); + { + $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); + if ($payment_method) + { + $payment_method->detach(); } } else { - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); - $card=$cu->sources->retrieve("$source"); - if ($card) - { - // $card->detach(); Does not work with card_, only with src_ - if (method_exists($card, 'detach')) $card->detach(); - else $card->delete(); - } + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); + $card = $cu->sources->retrieve("$source"); + if ($card) { + // $card->detach(); Does not work with card_, only with src_ + if (method_exists($card, 'detach')) { + $card->detach(); + } else { + $card->delete(); + } + } } $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; @@ -806,7 +804,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -1296,54 +1294,60 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } print ""; print "
"; - print '
'; + print '
'; } // List of Stripe payment modes if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); - $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); + print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; - $currencybalance = array(); + $currencybalance = array(); if (is_array($balance->available) && count($balance->available)) { foreach ($balance->available as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) $currencybalance[$cpt->currency]->available=$cpt->amount / 100; - else $currencybalance[$cpt->currency]->available=$cpt->amount; - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + } else { + $currencybalance[$cpt->currency]->available=$cpt->amount; + } + $currencybalance[$cpt->currency]->currency=$cpt->currency; } } - if (is_array($balance->pending) && count($balance->pending)) + if (is_array($balance->pending) && count($balance->pending)) { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; - else $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + } else { + $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + } } - } + } if (is_array($currencybalance)) { foreach ($currencybalance as $cpt) { - print ''; + print ''; } } - print '
'.$langs->trans('Currency').''.$langs->trans('Available').''.$langs->trans('Pending').''.$langs->trans('Total').'
'.$langs->trans('Total').'
'.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
'.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
'; - print '
'; + print ''; + print '
'; } // List of bank accounts @@ -1394,12 +1398,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $string .= $rib->code_guichet.' '; } elseif ($val == 'BankAccountNumberKey') { $string .= $rib->cle_rib.' '; - /* Already output after - }elseif ($val == 'BIC') { - $string .= $rib->bic.' '; - }elseif ($val == 'IBAN') { - $string .= $rib->iban.' ';*/ } + // Already output after + // } elseif ($val == 'BIC') { + // $string .= $rib->bic.' '; + // } elseif ($val == 'IBAN') { + // $string .= $rib->iban.' ';*/ + //} } if (! empty($rib->label) && $rib->number) { if (! checkBanForAccount($rib)) { @@ -1610,7 +1615,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -1716,7 +1721,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -1764,7 +1769,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -1864,7 +1869,7 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 967f91ca39d..d3c4c75fca5 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -46,8 +46,8 @@ $cancel = GETPOST('cancel', 'alpha'); // Security check $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->societe_id) - $socid = $user->societe_id; +if ($user->socid) + $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); @@ -187,7 +187,7 @@ dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 8f825bfc18c..1ff2c24956e 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -35,7 +35,7 @@ $langs->loadLangs(array("companies", "projects")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -82,7 +82,7 @@ if ($socid) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index db18a1bf6af..0894935b962 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -51,7 +51,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $id, ''); $object = new Societe($db); @@ -166,7 +166,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); print '
'; @@ -301,6 +301,8 @@ if ($id > 0 || ! empty($ref)) // Type $membertypestatic->id=$objp->type_id; $membertypestatic->libelle=$objp->type; + $membertypestatic->label=$objp->type; + print ''; print $membertypestatic->getNomUrl(1, 32); print ''; diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 8bb112fa998..9a17ac1e202 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -42,6 +42,8 @@ if ($nbofsalesrepresentative > 0) $userstatic->statut=$val['statut']; $userstatic->photo=$val['photo']; $userstatic->email=$val['email']; + $userstatic->phone=$val['phone']; + $userstatic->job=$val['job']; $userstatic->entity=$val['entity']; print $userstatic->getNomUrl(-1); print ' '; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 0e0c5ac2cc8..6878ea8ed44 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -47,7 +47,7 @@ $search_status=GETPOST('search_status'); // Security check $id = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -195,7 +195,7 @@ dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); $linkback = '' . $langs->trans("BackToList") . ''; -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 05d8937f293..e101a40ffbf 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -177,12 +177,12 @@ print "\n"; print ''; print ''; print $langs->trans("StripeLiveEnabled").''; - if ($conf->use_javascript_ajax) { +if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_LIVE'); - } else { +} else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); - } +} print ''; if (empty($conf->stripeconnect->enabled)) @@ -203,7 +203,7 @@ if (empty($conf->stripeconnect->enabled)) print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; + print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; @@ -239,7 +239,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); } - //print $endpoint; + //print $endpoint; } else { @@ -275,8 +275,8 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; + print ''; + print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; @@ -312,7 +312,7 @@ if (empty($conf->stripeconnect->enabled)) print '
'; print img_picto($langs->trans("Disabled"), 'switch_off'); } - //print $endpoint; + //print $endpoint; } else { @@ -366,14 +366,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? // Activate Payment Request API if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { - print ''; + print ''; print $langs->trans("STRIPE_PAYMENT_REQUEST_API").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); + } print ''; } @@ -382,12 +382,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { print ''; print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); + } print ''; } diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 99abc1fd510..f398a013fb6 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Thibault FOUCART + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +33,7 @@ $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -121,29 +122,28 @@ if (!$rowid) //print $list; foreach ($list->data as $charge) { - if ($charge->refunded=='1'){ + if ($charge->refunded=='1') { $status = img_picto($langs->trans("refunded"), 'statut6'); - } elseif ($charge->paid=='1'){ - $status = img_picto($langs->trans("".$charge->status.""), 'statut4'); - } else { + } elseif ($charge->paid=='1') { + $status = img_picto($langs->trans("".$charge->status.""), 'statut4'); + } else { $label="Message: ".$charge->failure_message."
"; $label.="Réseau: ".$charge->outcome->network_status."
"; $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); $status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1); - } + } - if ($charge->payment_method_details->type=='card') - { + if ($charge->payment_method_details->type=='card') { $type = $langs->trans("card"); - } elseif ($charge->source->type=='card'){ + } elseif ($charge->source->type=='card'){ $type = $langs->trans("card"); - } elseif ($charge->payment_method_details->type=='three_d_secure'){ + } elseif ($charge->payment_method_details->type=='three_d_secure'){ $type = $langs->trans("card3DS"); - } + } - if (! empty($charge->payment_intent)) { - $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent); - } + if (! empty($charge->payment_intent)) { + $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent); + } // The metadata FULLTAG is defined by the online payment page $FULLTAG=$charge->metadata->FULLTAG; @@ -211,19 +211,25 @@ if (!$rowid) print "\n"; // Origine print ""; - if ($charge->metadata->dol_type=="order"){ + if ($charge->metadata->dol_type=="order") { $object = new Commande($db); $object->fetch($charge->metadata->dol_id); - if ($object->id > 0) { - print "
".img_picto('', 'object_order')." ".$object->ref.""; - } else print $FULLTAG; - } elseif ($charge->metadata->dol_type=="invoice"){ + if ($object->id > 0) { + print "".img_picto('', 'object_order')." ".$object->ref.""; + } else { + print $FULLTAG; + } + } elseif ($charge->metadata->dol_type=="invoice") { $object = new Facture($db); $object->fetch($charge->metadata->dol_id); - if ($object->id > 0) { - print "".img_picto('', 'object_invoice')." ".$object->ref.""; - } else print $FULLTAG; - } else print $FULLTAG; + if ($object->id > 0) { + print "".img_picto('', 'object_invoice')." ".$object->ref.""; + } else { + print $FULLTAG; + } + } else { + print $FULLTAG; + } print "\n"; // Date payment print ''.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."\n"; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 593447919a7..c30e3169ee5 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -62,6 +62,9 @@ class Stripe extends CommonObject public $code; public $declinecode; + /** + * @var string Message + */ public $message; /** @@ -315,9 +318,10 @@ class Stripe extends CommonObject * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) * @param string $payment_method 'pm_....' (if known) * @param string $off_session If we use an already known payment method to pay off line. + * @param string $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ - public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0) + public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0, $noidempotency_key = 0) { global $conf; @@ -338,17 +342,21 @@ class Stripe extends CommonObject } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100); - else $stripefee = round($fee); + if (! in_array($currency_code, $arrayzerounitcurrency)) { + $stripefee = round($fee * 100); + } else { + $stripefee = round($fee); + } $paymentintent = null; if (is_object($object)) { // Warning. If a payment was tried and failed, a payment intent was created. - // But if we change someting on object to pay (amount or other), reusing same payment intent is not allowed. - // Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), - // that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old that will not be used) + // But if we change someting on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed. + // Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), Stripe will + // automatically return the existing payment intent if idempotency is provided when we try to create the new one. + // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) /* $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; @@ -439,14 +447,15 @@ class Stripe extends CommonObject global $stripearrayofkeysbyenv; \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); - // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. - if (empty($key)) { // If the Stripe connect account not set, we use common API usage - $paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description")); - //$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array()); - } else { - $paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description", "stripe_account" => $key)); - //$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("stripe_account" => $key)); + $arrayofoptions = array(); + if (empty($noidempotency_key)) { + $arrayofoptions["idempotency_key"] = $description; } + // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. + if (! empty($key)) { // If the Stripe connect account not set, we use common API usage + $arrayofoptions["stripe_account"] = $key; + } + $paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions); // Store the payment intent if (is_object($object)) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 0030bdb5535..0226c724165 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/lib/Stripe.php'; -global $stripe; +//global $stripe; global $conf; global $stripearrayofkeysbyenv; @@ -46,13 +46,13 @@ $stripearrayofkeysbyenv = array( $stripearrayofkeys = array(); if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { - $stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test + $stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test } else { - $stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live + $stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live } \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion("2019-05-16"); // force version API +\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2019-05-16" : $conf->global->STRIPE_FORCE_VERSION); // force version API diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 45af7923fca..e0ed986bfd6 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -65,9 +65,9 @@ $multicurrency_amountsresttopay=array(); // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->socid > 0) { - $socid = $user->societe_id; + $socid = $user->socid; } $object=new Facture($db); @@ -186,12 +186,12 @@ if (empty($reshook)) } } - // Check parameters -// if (! GETPOST('paiementcode')) -// { -// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); -// $error++; -// } + // Check parameters + /*if (! GETPOST('paiementcode')) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); + $error++; + }*/ if (! empty($conf->banque->enabled)) { @@ -209,11 +209,11 @@ if (empty($reshook)) $error++; } -// if (empty($datepaye)) -// { -// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); -// $error++; -// } + /*if (empty($datepaye)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); + $error++; + }*/ // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 70988b339b5..e2f19c560be 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 6dc0a1e0815..3bc1050f867 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 3bbd8d8a33f..1a8aa755e71 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -74,7 +74,7 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($co $NBLINES = 4; // Security check -if (! empty($user->societe_id)) $socid = $user->societe_id; +if (! empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'supplier_proposal', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -319,78 +319,92 @@ if (empty($reshook)) $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + $srcobject->fetch_lines(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; + } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $result = $object->addline( - $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, $lines[$i]->remise_percent, - 'HT', 0, $lines[$i]->info_bits, $product_type, - $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, - $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, - $lines[$i]->ref_supplier, $lines[$i]->fk_unit - ); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; } - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + 'HT', + 0, + $lines[$i]->info_bits, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, $label, + $array_options, + $lines[$i]->ref_supplier, + $lines[$i]->fk_unit + ); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; $error ++; - } else { - setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) { $error ++; } + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error ++; + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; @@ -736,64 +750,64 @@ if (empty($reshook)) if (! $error && $result > 0) { - $db->commit(); + $db->commit(); - $ret=$object->fetch($object->id); // Reload to get new records + $ret=$object->fetch($object->id); // Reload to get new records - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records - unset($_POST['prod_entry_mode']); + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db, $result); + } - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['pu']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['label']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($localtax1_tx); - unset($localtax2_tx); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprodfournprice']); - unset($_POST['idprod']); + unset($_POST['prod_entry_mode']); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['pu']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['label']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($localtax1_tx); + unset($localtax2_tx); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprodfournprice']); + unset($_POST['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { @@ -801,7 +815,6 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - //} } } @@ -1452,19 +1465,20 @@ if ($action == 'create') $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bee290878c1..dede1c9eec9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -66,6 +66,9 @@ class SupplierProposal extends CommonObject */ public $fk_element='fk_supplier_proposal'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ public $picto='propal'; /** @@ -158,8 +161,8 @@ class SupplierProposal extends CommonObject public $lines = array(); public $line; - public $labelstatut=array(); - public $labelstatut_short=array(); + public $labelStatus=array(); + public $labelStatusShort=array(); public $nbtodo; public $nbtodolate; @@ -1364,9 +1367,9 @@ class SupplierProposal extends CommonObject $line->fk_product = $objp->fk_product; - $line->ref = $objp->product_ref; // TODO deprecated + $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // TODO deprecated + $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; @@ -1698,22 +1701,22 @@ class SupplierProposal extends CommonObject * Close the askprice * * @param User $user Object user that close - * @param int $statut Statut + * @param int $status Status * @param string $note Comment * @return int <0 if KO, >0 if OK */ - public function cloture($user, $statut, $note) + public function cloture($user, $status, $note) { global $langs,$conf; - $this->statut = $statut; + $this->statut = $status; $error=0; $now=dol_now(); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql.= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); @@ -1722,7 +1725,7 @@ class SupplierProposal extends CommonObject $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; - if ($statut == 2) + if ($status == 2) { $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; @@ -1732,23 +1735,22 @@ class SupplierProposal extends CommonObject $result = $this->updateOrCreatePriceFournisseur($user); } } - if ($statut == 4) + if ($status == 4) { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } // Call trigger @@ -2188,44 +2190,39 @@ class SupplierProposal extends CommonObject /** * Return label of a status (draft, validated, ...) * - * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 1) + public function LibStatut($status, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + // Init/load array of translation of status + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelStatus[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelStatus[self::STATUS_VALIDATED]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelStatus[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelStatus[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelStatus[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelStatusShort[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelStatusShort[self::STATUS_VALIDATED]=$langs->trans("Opened"); + $this->labelStatusShort[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelStatusShort[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelStatusShort[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosedShort"); + } - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + $statusnew=''; + if ($status==self::STATUS_DRAFT) $statusnew='status0'; + elseif ($status==self::STATUS_VALIDATED) $statusnew='status1'; + elseif ($status==self::STATUS_SIGNED) $statusnew='status3'; + elseif ($status==self::STATUS_NOTSIGNED) $statusnew='status5'; + elseif ($status==self::STATUS_CLOSE) $statusnew='status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusnew, $mode); } @@ -2264,15 +2261,16 @@ class SupplierProposal extends CommonObject if ($resql) { $label = $labelShort = ''; + $status = ''; if ($mode == 'opened') { $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - $statut = self::STATUS_VALIDATED; + $status = self::STATUS_VALIDATED; $label = $langs->trans("SupplierProposalsToClose"); $labelShort = $langs->trans("ToAcceptRefuse"); } if ($mode == 'signed') { $delay_warning=$conf->supplier_proposal->facturation->warning_delay; - $statut = self::STATUS_SIGNED; + $status = self::STATUS_SIGNED; $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered $labelShort = $langs->trans("ToClose"); } @@ -2281,7 +2279,7 @@ class SupplierProposal extends CommonObject $response->warning_delay = $delay_warning/60/60/24; $response->label = $label; $response->labelShort = $labelShort; - $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$status; $response->img = img_object('', "propal"); // This assignment in condition is not a bug. It allows walking the results. diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 69c6f0d193e..84b007c53fc 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -39,7 +39,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', ''); $object = new SupplierProposal($db); @@ -158,20 +158,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoedit) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 7c5d533a401..da76e9ea897 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -45,9 +45,9 @@ $ref = GETPOST('ref', 'alpha'); // Security check $socid=''; -if (! empty($user->societe_id)) +if (! empty($user->socid)) { - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'supplier_proposal', $id); @@ -113,20 +113,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index dd2acd27311..55bde878918 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -38,10 +38,10 @@ $langs->loadLangs(array('supplier_proposal', 'companies')); // Security check $socid=GETPOST('socid', 'int'); -if (isset($user->societe_id) && $user->societe_id > 0) +if (isset($user->socid) && $user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $result = restrictedArea($user, 'supplier_proposal'); @@ -90,7 +90,7 @@ $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; -if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; +if ($user->socid) $sql.=' AND p.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND p.fk_statut IN (0,1,2,3,4)"; $sql.= " GROUP BY p.fk_statut"; diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index e34ba2cd06c..7b259b166e4 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -39,7 +39,7 @@ $id=GETPOST('id', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; $result = restrictedArea($user, 'supplier_proposal', $id); @@ -78,20 +78,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 687d98911f2..c48f3756611 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -103,7 +103,7 @@ $NBLINES=4; $module='supplier_proposal'; $dbtable=''; $objectid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($user->socid)) $socid=$user->socid; if (! empty($socid)) { $objectid=$socid; diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index b827117d7c5..0e12da2c104 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -40,7 +40,7 @@ $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; +if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal'); $object = new SupplierProposal($db); @@ -98,20 +98,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index 05cf99f3170..c87bb46adf3 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -24,39 +24,38 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("SupplierProposal"); ?> trans("ShowSupplierProposal"), "supplier_proposal").' '.$objectlink->ref; ?> datec, 'day'); ?> rights->supplier_proposal->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->supplier_proposal->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - 1) { @@ -72,6 +71,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/takepos/ChangeLog.md b/htdocs/takepos/ChangeLog.md deleted file mode 100644 index 7b623eaa252..00000000000 --- a/htdocs/takepos/ChangeLog.md +++ /dev/null @@ -1,5 +0,0 @@ -# CHANGELOG TAKEPOS FOR DOLIBARR ERP CRM - -## 1.0 -Initial version - diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 6289f382273..a1f07f4f7ad 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -79,7 +79,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) { @@ -247,15 +247,15 @@ $formmail = new FormMail($db); $nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1); // We set lang=null to get in priority record with no lang //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); $arrayofmessagename=array(); -if (is_array($formmail->lines_model)) -{ - foreach($formmail->lines_model as $modelmail) - { - //var_dump($modelmail); - $moreonlabel=''; - if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; - $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; - } +if (is_array($formmail->lines_model)) { + foreach($formmail->lines_model as $modelmail) { + //var_dump($modelmail); + $moreonlabel=''; + if (! empty($arrayofmessagename[$modelmail->label])) { + $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; + } + $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; + } } //var_dump($arraydefaultmessage); //var_dump($arrayofmessagename); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index b34889a3dce..167735e901d 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -45,14 +45,14 @@ $langs->loadLangs(array("admin", "cashdesk")); global $db; -$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; +$sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; $sql.= " AND active = 1"; $sql.= " ORDER BY libelle"; $resql = $db->query($sql); $paiements = array(); -if($resql){ - while ($obj = $db->fetch_object($resql)){ +if ($resql) { + while ($obj = $db->fetch_object($resql)) { array_push($paiements, $obj); } } @@ -152,7 +152,7 @@ if (! empty($conf->banque->enabled)) foreach($paiements as $modep) { if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; // Already managed before $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; - print ''.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->libelle).''; + print ''.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).''; print ''; if (! empty($conf->global->$name)) $atleastonefound++; $cour=preg_match('/^LIQ.*/', $modep->code)?2:1; @@ -166,12 +166,12 @@ if (! empty($conf->stock->enabled)) print ''.$langs->trans("CashDeskDoNotDecreaseStock").''; // Force warehouse (this is not a default value) print ''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); } else { if (!$conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, 1, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, 1, 'chaine', 0, '', $conf->entity); } print $langs->trans("Yes").'
'; print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 74e83ffbef3..cd45d0c1792 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -157,8 +157,7 @@ $( document ).ready(function() { $('#'+val.label).draggable().bind('click', function(){ $(this).focus(); }) - + $('body').append('
'+val.label+'
'); }); @@ -168,13 +167,13 @@ $( document ).ready(function() { -admin){?> +admin) {?> diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2fcb9e0a6d8..126fea907a9 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -260,6 +260,9 @@ if ($action == "addline") $prod = new Product($db); $prod->fetch($idproduct); + $customer = new Societe($db); + $customer->fetch($invoice->socid); + $price = $prod->price; $tva_tx = $prod->tva_tx; $price_ttc = $prod->price_ttc; @@ -267,16 +270,13 @@ if ($action == "addline") if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - $price = $prod->multiprices[$customer->price_level]; $tva_tx = $prod->multiprices_tva_tx[$customer->price_level]; $price_ttc = $prod->multiprices_ttc[$customer->price_level]; $price_base_type = $prod->multiprices_base_type[$customer->price_level]; } - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); $invoice->fetch($placeid); } diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 349c03540b2..aea8d14ebba 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -223,7 +223,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> @@ -236,11 +236,11 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> + $button = array_pop($action_buttons); + ?> @@ -251,12 +251,11 @@ $button = array_pop($action_buttons); if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> - - + @@ -265,17 +264,17 @@ $button = array_pop($action_buttons); + ?> - + ?> -
diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 38ad9103ab9..bdf38c2bafe 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -100,7 +100,8 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) trans('Date')." ".dol_print_date($object->date, 'day').'
'; if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) print $conf->global->TAKEPOS_RECEIPT_NAME." "; -print $object->ref; +if ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); +else print $object->ref; if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOMER) { $soc = new Societe($db); @@ -130,16 +131,17 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME lines as $line) { - ?> + ?> - product_label)) echo $line->product_label; - else echo $line->description;?> + + product_label)) echo $line->product_label; + else echo $line->description;?> qty;?> total_ttc/$line->qty;?> total_ttc);?> - @@ -150,30 +152,28 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME trans("TotalHT");?> total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> -global->TAKEPOS_TICKET_VAT_GROUPPED):?> -global->TAKEPOS_TICKET_VAT_GROUPPED) { $vat_groups = array(); foreach ($object->lines as $line) { - if(!array_key_exists($line->tva_tx, $vat_groups)){ + if(!array_key_exists($line->tva_tx, $vat_groups)) { $vat_groups[$line->tva_tx] = 0; } $vat_groups[$line->tva_tx] += $line->total_tva; } - foreach($vat_groups as $key => $val){ - ?> + foreach($vat_groups as $key => $val) { + ?> trans("VAT").' '.vatrate($key, 1);?> currency)."\n";?> - - +} else { ?> trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> - + trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index d3a0f466fc8..001fd842165 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -562,23 +562,23 @@ function MoreActions(totalactions){ } } +// Popup to select the terminal to use function TerminalsDialog() { jQuery("#dialog-info").dialog({ resizable: false, - height:220, - width:400, + height: global->TAKEPOS_NUM_TERMINALS / 3 * 20); ?>, + width: dol_optimize_smallscreen ? 316 : 400); ?>, modal: true, buttons: { - Terminal1: function() { + 'trans("Terminal")) ?> 1': function() { location.href='takepos.php?setterminal=1'; } global->TAKEPOS_NUM_TERMINALS; $i++) { - print " - , - Terminal".$i.": function() { + print ", + '".dol_escape_js($langs->trans("Terminal"))." ".$i."': function() { location.href='takepos.php?setterminal=".$i."'; } "; @@ -747,7 +747,7 @@ $menus[$r++]=array('title'=>'< print ' '; print ''.img_picto('', 'searchclear').''; print '
'; -?> + ?>
@@ -759,7 +759,7 @@ $menus[$r++]=array('title'=>'< $count=0; while ($count < $MAXCATEG) { - ?> + ?>
id="catdiv"> '<
+
-
@@ -794,7 +794,7 @@ $menus[$r++]=array('title'=>'< $count=0; while ($count < $MAXPRODUCT) { - ?> + ?>
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > '<
+
- diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 0f635941a8e..27fc142d991 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -22,6 +22,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> box-sizing: border-box; } +.badge-status { + font-size: 1em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ +} + .badge-pill, .tabs .badge { padding-right: .5em; padding-left: .5em; @@ -31,8 +36,8 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .badge-dot { padding: 0; border-radius: 50%; - padding: 0.25rem; - vertical-align: middle; + padding: 0.45em; + vertical-align: text-top; } a.badge:focus, a.badge:hover { @@ -168,10 +173,12 @@ a.badge-dark:focus, a.badge-dark:hover { background-color: ; } + /* -* STATUS BADGES -*/ - + + +/* + * BTN LINK + */ + +.btn-link{ + margin-right: 5px; + border: 1px solid #ddd; + color: #333; + padding: 5px 10px; + border-radius:1em; + text-decoration: none !important; +} + +.btn-link:hover{ + background-color: #ddd; + border: 1px solid #ddd; +} diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 89df0813ca4..6db99927fb1 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -280,7 +280,7 @@ input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; } -div#moretabsListaction { +div#moretabsList, div#moretabsListaction { z-index: 5; } @@ -473,6 +473,12 @@ textarea.centpercent { .paddingright2 { padding-: 2px; } +.marginleft2 { + margin-: 2px; +} +.marginright2 { + margin-: 2px; +} .cursordefault { cursor: default; } @@ -488,6 +494,9 @@ textarea.centpercent { .backgroundblank { background-color: #fff; } +.nobackground, .nobackground tr { + background: unset !important; +} .checkboxattachfilelabel { font-size: 0.85em; opacity: 0.7; @@ -510,13 +519,16 @@ body[class*="colorblind-"] .text-success{ color : } -.editfielda span.fa-pencil-alt { +.editfielda span.fa-pencil-alt, .editfielda span.fa-trash { color: #ccc !important; } -.editfielda span.fa-pencil-alt:hover { +.editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { color: rgb() !important; } +.fa-toggle-on, .fa-toggle-off { font-size: 2em; } +.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off, +.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } /* Themes for badges */ @@ -555,7 +567,7 @@ div.divsearchfield { browser->layout == 'phone') { -?> + ?> .divsearchfieldfilter { white-space: nowrap; } @@ -2529,6 +2541,9 @@ span.tabspan { margin: 0px !important; padding: 0px !important; } +.noborderspacing { + border-spacing: 0; +} tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd { border: 0px; @@ -2753,6 +2768,7 @@ table.listwithfilterbefore { .tagtable, .table-border { display: table; } .tagtr, .table-border-row { display: table-row; } .tagtd, .table-border-col, .table-key-border-col, .table-val-border-col { display: table-cell; } +.confirmquestions .tagtr .tagtd:not(:first-child) { padding-left: 10px; } /* Pagination */ @@ -4399,6 +4415,14 @@ pre#editfilecontentaceeditorid { #comment .comment-delete:hover { background:rgba(250,20,20,0.8); } +#comment .comment-edit { + width: 100px; + text-align:center; + vertical-align:middle; +} +#comment .comment-edit:hover { + background:rgba(0,184,148,0.8); +} #comment textarea { width: 100%; } @@ -5788,7 +5812,7 @@ div.tabsElem a.tab { } .dropdown dd ul { - max-width: 300px; + max-width: 350px; } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @@ -5817,6 +5841,10 @@ div.tabsElem a.tab { margin-top: 2px; left: 4px; } + + .dropdown dd ul { + max-width: 300px; + } } /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index a483b3d758d..2ceaa70911a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -149,46 +149,56 @@ a.info-box-text{ text-decoration: none;} /* ICONS INFO BOX */ -.info-box-icon { - color: #fff !important; -} - global->THEME_AGRESSIVITY_RATIO='.$conf->global->THEME_AGRESSIVITY_RATIO.' */'."\n"; -if (! isset($conf->global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-40; -if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); + +$prefix=''; +$prefix = 'background-'; +if (! empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; + +if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO) && $prefix) $conf->global->THEME_AGRESSIVENESS_RATIO=-50; +if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENESS_RATIO=GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); +//var_dump($conf->global->THEME_AGRESSIVENESS_RATIO); ?> +.info-box-icon { + + color: #fff !important; + + background-color: #eee !important; + + opacity: 0.95; +} + .bg-infoxbox-project{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-action{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-propal, .bg-infoxbox-facture, .bg-infoxbox-commande{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-supplier_proposal, .bg-infoxbox-invoice_supplier, .bg-infoxbox-order_supplier{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-contrat{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-bank_account{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-adherent{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-expensereport{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-holiday{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } diff --git a/htdocs/theme/eldy/progress.inc.php b/htdocs/theme/eldy/progress.inc.php index 3e330745440..a211c40efb4 100644 --- a/htdocs/theme/eldy/progress.inc.php +++ b/htdocs/theme/eldy/progress.inc.php @@ -21,10 +21,10 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> height: 20px; overflow: hidden; background-color: #f5f5f5; - background-color: rgba(0,0,0,0.1); + background-color: rgba(128, 128, 128, 0.1); border-radius: 4px; - -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1); - box-shadow: inset 0 1px 2px rgba(0,0,0,.1); + -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); } .progress.spaced{ @@ -167,7 +167,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> } .progress-bar-yellow, .progress-bar-warning { - background-color: #f39c12; + background-color: #bc9526; } .progress-striped .progress-bar-yellow, .progress-striped .progress-bar-warning { @@ -184,4 +184,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} +.progress-bar-consumed { + background-color: rgb(0, 0, 0, 0.15); } \ No newline at end of file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 086b7f942e6..ed1ca8a9279 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -236,7 +236,7 @@ print 'fontsizesmaller='.$fontsizesmaller."\n"; print 'topMenuFontSize='.$topMenuFontSize."\n"; print 'toolTipBgColor='.$toolTipBgColor."\n"; print 'toolTipFontColor='.$toolTipFontColor."\n"; -print 'conf->global->THEME_AGRESSIVITY_RATIO='.$conf->global->THEME_AGRESSIVITY_RATIO." (must be between -100 and +100)\n"; +print 'conf->global->THEME_AGRESSIVENESS_RATIO='.$conf->global->THEME_AGRESSIVENESS_RATIO." (must be between -100 and +100)\n"; print '*/'."\n"; diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 386a81f0afd..24e7e6f7d41 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -81,7 +81,7 @@ $toolTipFontColor='#333'; $textSuccess ='#28a745'; $colorblind_deuteranopes_textSuccess ='#37de5d'; $textDanger ='#dc3545'; -$textWarning ='#f39c12'; +$textWarning ='#bc9526'; $colorblind_deuteranopes_textWarning = $textWarning; // currently not tested with a color blind people so use default color diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 2cb3461d713..76ca244e572 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -125,7 +125,12 @@ a.timeline-btn:hover font-weight: normal; line-height: 1.1; } -.timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-header { + +.timeline > li > .timeline-item > .timeline-footer { + border-top: 1px solid #f4f4f4; +} + +.timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-header, .timeline > li.timeline-code-ticket_msg_private > .timeline-item > .timeline-footer { border-color: #ecebda; } @@ -195,3 +200,12 @@ a.timeline-btn:hover background-color: #0073b7 !important; color: #fff !important; } + +.timeline-documents-container{ + +} + +.timeline-documents{ + margin-right: 5px; +} + diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index ac6eb9de53c..11536240ee0 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -21,7 +21,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> border-color: rgba(255,255,255,0); box-sizing: border-box; } -/* Themes for badges */ + +.badge-status { + font-size: 1em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ +} .badge-pill, .tabs .badge { padding-right: .5em; @@ -32,8 +36,8 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .badge-dot { padding: 0; border-radius: 50%; - padding: 0.25rem; - vertical-align: middle; + padding: 0.35em; + vertical-align: unset; } a.badge:focus, a.badge:hover { @@ -158,46 +162,74 @@ a.badge-dark:focus, a.badge-dark:hover { background-color: ; } + /* -* STATUS BADGES -*/ - -/* Default Status */ - + * STATUS BADGES + */ global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-100; -if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); +if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO)) $conf->global->THEME_AGRESSIVENESS_RATIO=-100; +if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENESS_RATIO=GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); ?> .bg-infoxbox-project i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-action i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-propal i.fa, .bg-infoxbox-facture i.fa, .bg-infoxbox-commande i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-supplier_proposal i.fa, .bg-infoxbox-invoice_supplier i.fa, .bg-infoxbox-order_supplier i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-contrat i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-bank_account i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-adherent i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-expensereport i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-holiday i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b2845c27b11..04fe7e85d77 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -507,7 +507,7 @@ input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; } -div#moretabsListaction { +div#moretabsList, div#moretabsListaction { z-index: 5; } @@ -676,6 +676,12 @@ textarea.centpercent { .paddingright2 { padding-: 2px; } +.marginleft2 { + margin-: 2px; +} +.marginright2 { + margin-: 2px; +} .cursordefault { cursor: default; } @@ -691,6 +697,9 @@ textarea.centpercent { .backgroundblank { background-color: #fff; } +.nobackground, .nobackground tr { + background: unset !important; +} .checkboxattachfilelabel { font-size: 0.85em; opacity: 0.7; @@ -720,6 +729,9 @@ body[class*="colorblind-"] .text-success{ color: rgb() !important; } +.fa-toggle-on, .fa-toggle-off { font-size: 2em; } +.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } + /* Themes for badges */ @@ -1230,11 +1242,12 @@ td.showDragHandle { display: block; font-family: "RobotoDraft","Roboto",sans-serif; left: 0; -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> position: fixed; top: 50px; - + z-index: 90; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); @@ -1259,12 +1272,14 @@ td.showDragHandle { -moz-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); -webkit-overflow-scrolling: touch; -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> overflow-x: hidden; overflow-y: auto; - - + } /* @@ -1315,11 +1330,12 @@ div.login_block { } .side-nav { -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> overflow-x: initial !important; overflow-y: scroll; - + display: block; position: relative; @@ -1363,11 +1379,12 @@ div.login_block { z-index: 91; background: rgb(); border-right: 1px solid rgba(0,0,0,0.3); -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> top: 50px ! important; - + top: 60px ! important; - + } div.fiche { margin-: 6px !important; @@ -1506,7 +1523,8 @@ table.noborder tr.liste_titre td { padding-: 3px; } .pictowarning { - vertical-align: text-bottom; + /* vertical-align: text-bottom; */ + color: #9f4705; } .pictomodule { width: 14px; @@ -1729,12 +1747,12 @@ li.tmenu, li.tmenusel { vertical-align: bottom; global->MAIN_MENU_INVERT)) { ?> float: ; - + height: px; padding: 0px 0px 2px 0px; - + padding: 0px 0px 0px 0px; - + position:relative; display: block; margin: 0px 0px 0px 0px; @@ -1755,9 +1773,9 @@ div.tmenuleft margin-top: 0px; dol_optimize_smallscreen)) { ?> width: 5px; - + height: px; - + } div.tmenucenter @@ -1886,82 +1904,82 @@ div.mainmenu.website { background-image: url(); } -'name of class for div') + 'name of class for div') -$moduletomainmenu=array( - 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', - 'produit'=>'products','service'=>'products','stock'=>'products', - 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', - 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', - 'fournisseur'=>'companies', - 'barcode'=>'','fckeditor'=>'','categorie'=>'', -); -$mainmenuused='home'; -foreach($conf->modules as $val) -{ - $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); -} -$mainmenuusedarray=array_unique(explode(',', $mainmenuused)); - -$generic=1; -// Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','mrp','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); -// Put here list of menu entries we are sure we don't want -$divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); -foreach($mainmenuusedarray as $val) -{ - if (empty($val) || in_array($val, $divalreadydefined)) continue; - if (in_array($val, $divnotrequired)) continue; - //print "XXX".$val; - - // Search img file in module dir - $found=0; $url=''; - foreach($conf->file->dol_document_root as $dirroot) + $moduletomainmenu=array( + 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', + 'produit'=>'products','service'=>'products','stock'=>'products', + 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', + 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', + 'fournisseur'=>'companies', + 'barcode'=>'', + 'fckeditor'=>'', + 'categorie'=>'', + ); + $mainmenuused='home'; + foreach($conf->modules as $val) { - if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) - { - $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); - $found=1; - break; - } - elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); + } + $mainmenuusedarray=array_unique(explode(',', $mainmenuused)); + + $generic=1; + // Put here list of menu entries when the div.mainmenu.menuentry was previously defined + $divalreadydefined=array('home','companies','products','mrp','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); + // Put here list of menu entries we are sure we don't want + $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); + foreach($mainmenuusedarray as $val) + { + if (empty($val) || in_array($val, $divalreadydefined)) continue; + if (in_array($val, $divnotrequired)) continue; + //print "XXX".$val; + + // Search img file in module dir + $found=0; $url=''; + foreach($conf->file->dol_document_root as $dirroot) { - $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); - $found=1; - break; + if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); + $found=1; + break; + } + elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); + $found=1; + break; + } + } + // Img file not found + if (! $found) + { + if (! defined('DISABLE_FONT_AWSOME')) { + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + print 'div.mainmenu.'.$val.'::before { + content: "\f249"; + }'; + } + else + { + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); + print "div.mainmenu.".$val." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; + } + $generic++; + } + else + { + print "div.mainmenu.".$val." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; } } - // Img file not found - if (! $found) - { - if (! defined('DISABLE_FONT_AWSOME')) { - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - print 'div.mainmenu.'.$val.'::before { - content: "\f249"; - }'; - } - else - { - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; - } - $generic++; - } - else - { - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; - } -} -// End of part to add more div class css -?> - - + // End of part to add more div class css +} // End test if $dol_hide_topmenu ?> .tmenuimage { padding:0 0 0 0 !important; @@ -2614,7 +2632,6 @@ span.tabspan { margin-top: px; } - .paddingrightonly { border-collapse: collapse; border: 0px; @@ -2627,6 +2644,9 @@ span.tabspan { margin: 0px !important; padding: 0px !important; } +.noborderspacing { + border-spacing: 0; +} tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd { border: 0px; @@ -2832,6 +2852,8 @@ table.listwithfilterbefore { .tagtable, .table-border { display: table; } .tagtr, .table-border-row { display: table-row; } .tagtd, .table-border-col, .table-key-border-col, .table-val-border-col { display: table-cell; } +.confirmquestions .tagtr .tagtd:not(:first-child) { padding-left: 10px; } + /* Pagination */ div.refidpadding { diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index 9ee8363dc46..6db51996d12 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -78,19 +78,19 @@ if (!$action) { // Security check $id = GETPOST("id", 'int'); $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result=restrictedArea($user, 'ticket', $id, ''); if (!$user->rights->ticket->read) { accessforbidden(); } // restrict access for externals users -if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)) +if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { accessforbidden(); } // or for unauthorized internals users -if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { +if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { accessforbidden(); } @@ -138,15 +138,15 @@ if ($socid > 0) { dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } -if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { +if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; -} elseif ($user->societe_id > 0) { - $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; +} elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '" . $user->socid . "'"; } $head = ticket_prepare_head($object); @@ -172,7 +172,7 @@ if (!empty($object->origin_email)) { if (! empty($conf->societe->enabled)) { $morehtmlref.='
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ $morehtmlref.=' : '; @@ -190,20 +190,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project'); if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -219,7 +220,7 @@ $morehtmlref.='
'; $linkback = '' . $langs->trans("BackToList") . ' '; -dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index eec2c813d26..6aa6d42e590 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -95,8 +95,8 @@ if ($id || $track_id || $ref) { $url_page_current = DOL_URL_ROOT.'/ticket/card.php'; // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; $result = restrictedArea($user, 'ticket', $object->id); $triggermodname = 'TICKET_MODIFY'; @@ -622,7 +622,7 @@ if ($action == 'create' || $action == 'presend') print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket'); - $formticket->withfromsocid = $socid ? $socid : $user->societe_id; + $formticket->withfromsocid = $socid ? $socid : $user->socid; $formticket->withfromcontactid = $contactid ? $contactid : ''; $formticket->withtitletopic = 1; $formticket->withnotifytiersatcreate = ($notifyTiers?1:0); @@ -645,7 +645,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd if ($res > 0) { // or for unauthorized internals users - if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { + if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { accessforbidden('', 0, 1); } @@ -741,14 +741,14 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $head = societe_prepare_head($object->thirdparty); dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } - if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; - } elseif ($user->societe_id > 0) { - $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '" . $user->socid . "'"; } $head = ticket_prepare_head($object); @@ -775,7 +775,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd if (! empty($conf->societe->enabled)) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' '; - if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 0) . ' : '; } if ($action == 'editcustomer') { @@ -821,7 +821,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $linkback = '' . $langs->trans("BackToList") . ' '; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref); print '
'; print '
'; @@ -845,9 +845,9 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd // Subject print ''; - print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->societe_id, 'string'); + print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string'); print ''; - print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->societe_id, 'string'); + print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string'); print ''; // Creation date @@ -889,7 +889,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } // Show user list to assignate one if status is "read" - if (GETPOST('set', 'alpha') == "assign_ticket" && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + if (GETPOST('set', 'alpha') == "assign_ticket" && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { print '
'; print ''; print ''; @@ -906,7 +906,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print ''; - if ($action != 'progression' && $object->fk_statut < 8 && !$user->societe_id) { + if ($action != 'progression' && $object->fk_statut < 8 && !$user->socid) { print ''; } print '
'; print $langs->trans('Progression') . ''; print '' . img_edit($langs->trans('Modify')) . '
'; @@ -1033,7 +1033,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd // Display navbar with links to change ticket status print ''; - if (!$user->societe_id && $user->rights->ticket->write && $object->fk_status < 8 && GETPOST('set') !== 'properties') { + if (!$user->socid && $user->rights->ticket->write && $object->fk_status < 8 && GETPOST('set') !== 'properties') { $actionobject->viewStatusActions($object); } @@ -1187,12 +1187,12 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } // Re-open ticket - if (!$user->socid && $object->fk_statut == Ticket::STATUS_CLOSED && !$user->societe_id) { + if (!$user->socid && $object->fk_statut == Ticket::STATUS_CLOSED && !$user->socid) { print ''; } // Delete ticket - if ($user->rights->ticket->delete && ! $user->societe_id) { + if ($user->rights->ticket->delete && ! $user->socid) { print ''; } } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index a4c71476269..c95b092cf2e 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -148,9 +148,9 @@ class Tickets extends DolibarrApi // String for user assigned if ($this->ticket->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($this->ticket->fk_user_assign); - $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + $userStatic = new User($this->db); + $userStatic->fetch($this->ticket->fk_user_assign); + $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; } // Messages of ticket @@ -296,9 +296,9 @@ class Tickets extends DolibarrApi $ticket_static = new Ticket($db); if ($ticket_static->fetch($obj->rowid)) { if ($ticket_static->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($ticket_static->fk_user_assign); - $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + $userStatic = new User($this->db); + $userStatic->fetch($ticket_static->fk_user_assign); + $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; } $obj_ret[] = $this->_cleanObjectDatas($ticket_static); } @@ -435,7 +435,7 @@ class Tickets extends DolibarrApi throw new RestException(500); } - return array( + return array( 'success' => array( 'code' => 200, 'message' => 'Ticket deleted' diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 0daba74be77..494d6b351b8 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1169,123 +1169,123 @@ class Ticket extends CommonObject /** * Return status label of object * - * @param string $statut id statut + * @param string $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; if ($mode == 0) { - return $langs->trans($this->statuts[$statut]); + return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { - if ($statut == self::STATUS_NOT_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + if ($status == self::STATUS_NOT_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut0.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut1.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_ASSIGNED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut2.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_ASSIGNED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut2.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_IN_PROGRESS) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_IN_PROGRESS) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_NEED_MORE_INFO) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_NEED_MORE_INFO) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_WAITING) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_WAITING) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_CLOSED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_CLOSED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut8.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_CANCELED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut9.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_CANCELED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut9.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } } elseif ($mode == 3) { - if ($statut == self::STATUS_NOT_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0.png@ticket'); + if ($status == self::STATUS_NOT_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut0.png@ticket'); } - elseif ($statut == self::STATUS_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1.png@ticket'); + elseif ($status == self::STATUS_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut1.png@ticket'); } - elseif ($statut == self::STATUS_ASSIGNED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut2.png@ticket'); + elseif ($status == self::STATUS_ASSIGNED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut2.png@ticket'); } - elseif ($statut == self::STATUS_IN_PROGRESS) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3.png@ticket'); + elseif ($status == self::STATUS_IN_PROGRESS) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3.png@ticket'); } - elseif ($statut == self::STATUS_NEED_MORE_INFO) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5.png@ticket'); + elseif ($status == self::STATUS_NEED_MORE_INFO) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5.png@ticket'); } - elseif ($statut == self::STATUS_WAITING) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6.png@ticket'); + elseif ($status == self::STATUS_WAITING) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6.png@ticket'); } - elseif ($statut == self::STATUS_CLOSED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8.png@ticket'); + elseif ($status == self::STATUS_CLOSED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut8.png@ticket'); } - elseif ($statut == self::STATUS_CANCELED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut9.png@ticket'); + elseif ($status == self::STATUS_CANCELED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut9.png@ticket'); } } elseif ($mode == 4) { - if ($statut == self::STATUS_NOT_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + if ($status == self::STATUS_NOT_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut0.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_READ) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut1.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_READ) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut1.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_ASSIGNED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut2.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_ASSIGNED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut2.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_IN_PROGRESS) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut3.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_IN_PROGRESS) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut3.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_NEED_MORE_INFO) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut5.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_NEED_MORE_INFO) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut5.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_WAITING) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_WAITING) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut6.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_CLOSED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut8.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_CLOSED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut8.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } - elseif ($statut == self::STATUS_CANCELED) { - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut9.png@ticket') . ' ' . $langs->trans($this->statuts_short[$statut]); + elseif ($status == self::STATUS_CANCELED) { + return img_picto($langs->trans($this->statuts_short[$status]), 'statut9.png@ticket') . ' ' . $langs->trans($this->statuts_short[$status]); } } elseif ($mode == 5 || $mode == 6) { - if ($statut == self::STATUS_NOT_READ) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut0.png@ticket'); + if ($status == self::STATUS_NOT_READ) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut0.png@ticket'); } - elseif ($statut == self::STATUS_READ) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut1.png@ticket'); + elseif ($status == self::STATUS_READ) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut1.png@ticket'); } - elseif ($statut == self::STATUS_ASSIGNED) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut2.png@ticket'); + elseif ($status == self::STATUS_ASSIGNED) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut2.png@ticket'); } - elseif ($statut == self::STATUS_IN_PROGRESS) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut3.png@ticket'); + elseif ($status == self::STATUS_IN_PROGRESS) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut3.png@ticket'); } - elseif ($statut == self::STATUS_NEED_MORE_INFO) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut5.png@ticket'); + elseif ($status == self::STATUS_NEED_MORE_INFO) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut5.png@ticket'); } - elseif ($statut == self::STATUS_WAITING) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut6.png@ticket'); + elseif ($status == self::STATUS_WAITING) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut6.png@ticket'); } - elseif ($statut == self::STATUS_CLOSED) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut8.png@ticket'); + elseif ($status == self::STATUS_CLOSED) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut8.png@ticket'); } - elseif ($statut == self::STATUS_CANCELED) { - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut9.png@ticket'); + elseif ($status == self::STATUS_CANCELED) { + return $langs->trans($this->statuts_short[$status]) . ' ' . img_picto($langs->trans($this->statuts_short[$status]), 'statut9.png@ticket'); } } } @@ -2228,13 +2228,13 @@ class Ticket extends CommonObject * Get array of all contacts for a ticket * Override method of file commonobject.class.php to add phone number * - * @param int $statut Status of lines to get (-1=all) + * @param int $status Status of lines to get (-1=all) * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array Array of contacts */ - public function listeContact($statut = -1, $source = 'external', $list = 0, $code = '') + public function listeContact($status = -1, $source = 'external', $list = 0, $code = '') { global $langs; @@ -2258,7 +2258,7 @@ class Ticket extends CommonObject $sql .= ", t.phone as phone, t.phone_mobile as phone_mobile, t.phone_perso as phone_perso"; } - $sql .= ", tc.source, tc.element, tc.code, tc.libelle"; + $sql .= ", tc.source, tc.element, tc.code, tc.libelle as type_contact_label"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_type_contact tc"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact ec"; if ($source == 'internal') { @@ -2281,8 +2281,8 @@ class Ticket extends CommonObject } $sql .= " AND tc.active=1"; - if ($statut >= 0) { - $sql .= " AND ec.statut = '" . $statut . "'"; + if ($status >= 0) { + $sql .= " AND ec.statut = '" . $status . "'"; } $sql .= " ORDER BY t.lastname ASC"; @@ -2296,7 +2296,7 @@ class Ticket extends CommonObject if (!$list) { $transkey = "TypeContact_" . $obj->element . "_" . $obj->source . "_" . $obj->code; - $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label); $tab[$i] = array( 'source' => $obj->source, 'socid' => $obj->socid, diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 42a319c3720..78e78b86f7d 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -51,8 +51,8 @@ $ligne = GETPOST('ligne', 'int'); $lineid = GETPOST('lineid', 'int'); // Protection if external user -if ($user->societe_id > 0) { - $socid = $user->societe_id; +if ($user->socid > 0) { + $socid = $user->socid; accessforbidden(); } @@ -129,14 +129,14 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $object->fetch_thirdparty(); $head = societe_prepare_head($object->thirdparty); dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } - if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; - } elseif ($user->societe_id > 0) { - $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '" . $user->socid . "'"; } $head = ticket_prepare_head($object); @@ -163,7 +163,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { if (! empty($conf->societe->enabled)) { $morehtmlref.='
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ $morehtmlref.=' : '; @@ -181,20 +181,21 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -210,7 +211,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $linkback = '' . $langs->trans("BackToList") . ' '; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); dol_fiche_end(); diff --git a/htdocs/ticket/css/styles.css.php b/htdocs/ticket/css/styles.css.php index 1d0626d190b..906d50602a1 100644 --- a/htdocs/ticket/css/styles.css.php +++ b/htdocs/ticket/css/styles.css.php @@ -31,7 +31,7 @@ if (! defined('NOLOGIN')) define('NOLOGIN', 1); // File must be if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -session_cache_limiter(false); +session_cache_limiter('public'); require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index c1cbaa26902..5a6b2b131f1 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -94,14 +94,14 @@ if ($object->id) $object->fetch_thirdparty(); $head = societe_prepare_head($object->thirdparty); dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } - if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; - } elseif ($user->societe_id > 0) { - $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '" . $user->socid . "'"; } $head = ticket_prepare_head($object); @@ -128,7 +128,7 @@ if ($object->id) if (! empty($conf->societe->enabled)) { $morehtmlref.='
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ $morehtmlref.=' : '; @@ -146,20 +146,21 @@ if ($object->id) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -175,7 +176,7 @@ if ($object->id) $linkback = '' . $langs->trans("BackToList") . ' '; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index e2a9038ee62..d749aa25f02 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -44,8 +44,8 @@ $msg_id = GETPOST('msg_id', 'int'); $action = GETPOST('action', 'aZ09'); -if ($user->societe_id) { - $socid = $user->societe_id; +if ($user->socid) { + $socid = $user->socid; } // Security check @@ -141,8 +141,8 @@ if (!$user->rights->societe->client->voir && !$socid) { } // External users restriction -if ($user->societe_id > 0) { - $sql .= " AND t.fk_soc='" . $user->societe_id . "'"; +if ($user->socid > 0) { + $sql .= " AND t.fk_soc='" . $user->socid . "'"; } else { // For internals users, if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) { @@ -210,6 +210,7 @@ $stringtoshow .= ''; print ''; print ''; @@ -257,6 +258,7 @@ if (! empty($dataseries) && count($dataseries) > 1) { print ''; print '
' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '
'; +print '
'; // Build graphic number of object $data = $stats->getNbByMonth($endyear, $startyear); @@ -286,8 +288,8 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; } -if ($user->societe_id > 0) { - $sql .= " AND t.fk_soc='" . $user->societe_id . "'"; +if ($user->socid > 0) { + $sql .= " AND t.fk_soc='" . $user->socid . "'"; } else { // Restricted to assigned user only if ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && !$user->rights->ticket->manage) { diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index bfaa8ad3876..7c6f525a0c4 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -246,7 +246,7 @@ foreach($search as $key => $val) if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project, 2); -if (! $user->societe_id && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { +if (! $user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql.= " AND (t.fk_user_assign = ".$user->id; if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) $sql.=" OR t.fk_user_create = ".$user->id; $sql.=")"; @@ -319,7 +319,7 @@ if ($socid && ! $projectid && ! $project_ref && $user->rights->societe->lire) { dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($socstat, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index d5bda4297ca..11bd501bd17 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -77,19 +77,19 @@ if (!$action) { // Security check $id = GETPOST("id", 'int'); $socid=0; -//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result=restrictedArea($user, 'ticket', $id, ''); if (!$user->rights->ticket->read) { accessforbidden(); } // restrict access for externals users -if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)) +if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { accessforbidden(); } // or for unauthorized internals users -if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { +if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { accessforbidden(); } @@ -171,7 +171,7 @@ if (!empty($object->origin_email)) { if (! empty($conf->societe->enabled)) { $morehtmlref.='
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ $morehtmlref.=' : '; @@ -189,20 +189,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project'); if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index f3cb531bb09..a6baeef7c06 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -37,10 +37,10 @@ $object_status=GETPOST('object_status'); $userid=GETPOST('userid', 'int'); $socid=GETPOST('socid', 'int'); // Security check -if ($user->societe_id > 0) +if ($user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $nowyear=strftime("%Y", dol_now()); @@ -80,7 +80,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png'; @@ -121,7 +121,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); //var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png'; @@ -160,7 +160,7 @@ if (! $mesg) $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); -if (!$user->rights->societe->client->voir || $user->societe_id) +if (!$user->rights->societe->client->voir || $user->socid) { $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png'; diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 439feb121f8..538519bbf2e 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -21,11 +21,9 @@ if (empty($conf) || ! is_object($conf)) print "Error, template page can't be called as URL"; exit; } -?> - +print "\n"; -load('ticket'); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'datec', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Ticket"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' @@ -70,7 +69,7 @@ foreach($linkedObjectBlock as $key => $objectlink) ?> - 1) { @@ -86,6 +85,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index d6f2eedb430..245718bd171 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -55,7 +55,7 @@ $object->getrights(); // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 886e931e38f..284c88a867b 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha'); // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); // Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 4540933532b..c924aae08bf 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -83,7 +83,7 @@ if ($id) // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2='user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); @@ -1030,7 +1030,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Tel - print ''.$langs->trans("PhonePro").''; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; print ''; if (! empty($ldap_phone)) { @@ -1044,7 +1044,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; // Tel portable - print ''.$langs->trans("PhoneMobile").''; + print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; print ''; if (! empty($ldap_mobile)) { @@ -1058,7 +1058,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; // Fax - print ''.$langs->trans("Fax").''; + print ''.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; print ''; if (! empty($ldap_fax)) { @@ -1071,6 +1071,20 @@ if ($action == 'create' || $action == 'adduserldap') } print ''; + // EMail + print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print ''; + if (! empty($ldap_mail)) + { + print ''; + print $ldap_mail; + } + else + { + print ''; + } + print ''; + // Skype if (! empty($conf->socialnetworks->enabled)) { @@ -1139,20 +1153,6 @@ if ($action == 'create' || $action == 'adduserldap') print ''; } - // EMail - print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - if (! empty($ldap_mail)) - { - print ''; - print $ldap_mail; - } - else - { - print ''; - } - print ''; - // Accountancy code if ($conf->accounting->enabled) { @@ -2376,7 +2376,7 @@ else } // Tel pro - print "".''.$langs->trans("PhonePro").''; + print "".''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; print ''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2390,7 +2390,7 @@ else print ''; // Tel mobile - print "".''.$langs->trans("PhoneMobile").''; + print "".''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; print ''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2404,7 +2404,7 @@ else print ''; // Fax - print "".''.$langs->trans("Fax").''; + print "".''.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; print ''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2417,6 +2417,20 @@ else } print ''; + // EMail + print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print ''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->email; + } + print ''; + // Skype if (! empty($conf->socialnetworks->enabled)) { @@ -2485,20 +2499,6 @@ else print ''; } - // EMail - print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->email; - } - print ''; - // OpenID url if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) { diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 9549fbe2ef1..778823d3d7d 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -72,7 +72,7 @@ class Users extends DolibarrApi $obj_ret = array(); if(! DolibarrApiAccess::$user->rights->user->user->lire) { - throw new RestException(401, "You are not allowed to read list of users"); + throw new RestException(401, "You are not allowed to read list of users"); } // case of external user, $societe param is ignored and replaced by user's socid @@ -226,10 +226,10 @@ class Users extends DolibarrApi if ($field == 'statut') { $result = $this->useraccount->setstatus($value); if ($result < 0) { - throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); + throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); } } else { - $this->useraccount->$field = $value; + $this->useraccount->$field = $value; } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 86de44ff1e7..76d4d431561 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -201,6 +201,12 @@ class User extends CommonObject 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name','enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), ); + + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + + + /** * Constructor of the class * @@ -252,7 +258,7 @@ class User extends CommonObject $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job, u.skype, u.twitter, u.facebook, u.linkedin,"; $sql.= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,"; $sql.= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; - $sql.= " u.admin, u.login, u.note,"; + $sql.= " u.admin, u.login, u.note as note_private, u.note_public,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,"; $sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid, u.fk_user_expense_validator, u.fk_user_holiday_validator,"; $sql.= " u.statut, u.lang, u.entity,"; @@ -368,7 +374,9 @@ class User extends CommonObject $this->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; - $this->note = $obj->note; + $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note = $obj->note_private; $this->statut = $obj->statut; $this->photo = $obj->photo; $this->openid = $obj->openid; @@ -948,22 +956,22 @@ class User extends CommonObject /** * Change status of a user * - * @param int $statut Status to set + * @param int $status Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - public function setstatus($statut) + public function setstatus($status) { global $conf,$langs,$user; $error=0; // Check parameters - if ($this->statut == $statut) return 0; - else $this->statut = $statut; + if ($this->statut == $status) return 0; + else $this->statut = $status; $this->db->begin(); - // Deactivate user + // Save in database $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql.= " SET statut = ".$this->statut; $sql.= " WHERE rowid = ".$this->id; @@ -1216,7 +1224,8 @@ class User extends CommonObject require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $langs->load("stocks"); $entrepot = new Entrepot($this->db); - $entrepot->libelle = $langs->trans("PersonalStock", $this->getFullName($langs)); + $entrepot->label = $langs->trans("PersonalStock", $this->getFullName($langs)); + $entrepot->libelle = $entrepot->label; // For backward compatibility $entrepot->description = $langs->trans("ThisWarehouseIsPersonalStock", $this->getFullName($langs)); $entrepot->statut = 1; $entrepot->country_id = $mysoc->country_id; @@ -1509,7 +1518,8 @@ class User extends CommonObject $this->job = trim($this->job); $this->signature = trim($this->signature); - $this->note = trim($this->note); + $this->note_public = trim($this->note_public); + $this->note_private = trim($this->note_private); $this->openid = trim(empty($this->openid)?'':$this->openid); // Avoid warning $this->admin = $this->admin?$this->admin:0; $this->address = empty($this->address)?'':$this->address; @@ -1568,7 +1578,8 @@ class User extends CommonObject $sql.= ", color = '".$this->db->escape($this->color)."'"; $sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null'); $sql.= ", dateemploymentend=".(strval($this->dateemploymentend)!='' ? "'".$this->db->idate($this->dateemploymentend)."'" : 'null'); - $sql.= ", note = '".$this->db->escape($this->note)."'"; + $sql.= ", note = '".$this->db->escape($this->note_private)."'"; + $sql.= ", note_public = '".$this->db->escape($this->note_public)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); $sql.= ", fk_user = ".($this->fk_user > 0?"'".$this->db->escape($this->fk_user)."'":"null"); @@ -2320,9 +2331,10 @@ class User extends CommonObject $label.= '
'; $label.= '' . $langs->trans("User") . '
'; $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs, ''); - if (! empty($this->login)) - $label.= '
' . $langs->trans('Login') . ': ' . $this->login; - $label.= '
' . $langs->trans("EMail").': '.$this->email; + if (! empty($this->login)) $label.= '
' . $langs->trans('Login') . ': ' . $this->login; + if (! empty($this->job)) $label.= '
' . $langs->trans("Job").': '.$this->job; + $label.= '
' . $langs->trans("Email").': '.$this->email; + if (! empty($this->phone)) $label.= '
' . $langs->trans("Phone").': '.$this->phone; if (! empty($this->admin)) $label.= '
' . $langs->trans("Administrator").': '.yn($this->admin); if (! empty($this->socid) ) // Add thirdparty for external users @@ -2477,48 +2489,31 @@ class User extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return label of a status of user (active, inactive) * - * @param int $statut Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; - $langs->load('users'); - if ($mode == 0) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($statut == 1) return $langs->trans('Enabled'); - elseif ($statut == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 1) - { - if ($statut == 1) return $langs->trans('Enabled'); - elseif ($statut == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - } - elseif ($mode == 3) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); - } - elseif ($mode == 4) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - } - elseif ($mode == 5) - { - if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); - elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_DISABLED] = $langs->trans('Disabled'); } + + $statusType = 'status5'; + if ($status == self::STATUS_ENABLED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -2702,7 +2697,8 @@ class User extends CommonObject $this->lastname='DOLIBARR'; $this->firstname='SPECIMEN'; $this->gender='man'; - $this->note='This is a note'; + $this->note_public='This is a note public'; + $this->note_private='This is a note private'; $this->email='email@specimen.com'; $this->personal_email='personalemail@specimen.com'; $this->skype='skypepseudo'; @@ -2947,7 +2943,7 @@ class User extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau + * Build the hierarchy/tree of users into an array. * Set and return this->users that is an array sorted according to tree with arrays of: * id = id user * lastname diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index b624bdb34d9..aa4a6b3f8b6 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -52,7 +52,10 @@ class UserGroup extends CommonObject */ public $ismultientitymanaged = 1; - public $picto='group'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='group'; /** * @var int Entity of group @@ -836,11 +839,11 @@ class UserGroup extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id status * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 79b285bc114..f4c3e63f9cf 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -33,7 +33,7 @@ $id=GETPOST('id', 'int'); // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); @@ -110,7 +110,7 @@ if ($id > 0) // Edit mode if ($action == 'edit') { - print ''; + print '
'; if ($user->admin) { diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 1ae457fb907..63b31328716 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -64,7 +64,7 @@ if ($id) // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2='user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 1cdf76e5ca4..448f38aea50 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -49,7 +49,7 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $object = new Usergroup($db); $object->fetch($id); diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 258cb42388d..32118e05b7b 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -243,7 +243,7 @@ if ($object->id > 0) print ''; print ''; - $sql = "SELECT r.id, r.libelle, r.module"; + $sql = "SELECT r.id, r.libelle as label, r.module"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " AND r.entity = " . $entity; @@ -330,7 +330,7 @@ if ($object->id > 0) print ''; } - $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle))); + $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->label))); print ''; print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 8952b32f30b..dc990497808 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -4,6 +4,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,8 +37,8 @@ $langs->loadLangs(array('users', 'companies')); // Security check (for external users) $socid=0; -if ($user->societe_id > 0) - $socid = $user->societe_id; +if ($user->socid > 0) + $socid = $user->socid; $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_user=GETPOST('search_user', 'alpha'); @@ -81,138 +82,138 @@ if (! is_array($user_arbo) && $user_arbo < 0) } else { -// Define fulltree array -$fulltree=$user_arbo; -//var_dump($fulltree); -// Define data (format for treeview) -$data=array(); -$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); -foreach($fulltree as $key => $val) -{ - $userstatic->id=$val['id']; - $userstatic->ref=$val['label']; - $userstatic->login=$val['login']; - $userstatic->firstname=$val['firstname']; - $userstatic->lastname=$val['lastname']; - $userstatic->statut=$val['statut']; - $userstatic->email=$val['email']; - $userstatic->gender=$val['gender']; - $userstatic->societe_id=$val['fk_soc']; - $userstatic->admin=$val['admin']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + // Define fulltree array + $fulltree=$user_arbo; + //var_dump($fulltree); + // Define data (format for treeview) + $data=array(); + $data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); + foreach($fulltree as $key => $val) + { + $userstatic->id=$val['id']; + $userstatic->ref=$val['label']; + $userstatic->login=$val['login']; + $userstatic->firstname=$val['firstname']; + $userstatic->lastname=$val['lastname']; + $userstatic->statut=$val['statut']; + $userstatic->email=$val['email']; + $userstatic->gender=$val['gender']; + $userstatic->societe_id=$val['fk_soc']; + $userstatic->admin=$val['admin']; + $userstatic->entity=$val['entity']; + $userstatic->photo=$val['photo']; - $entity=$val['entity']; - $entitystring=''; + $entity=$val['entity']; + $entitystring=''; - // TODO Set of entitystring should be done with a hook - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($entity)) - { - $entitystring=$langs->trans("AllEntities"); - } - else - { - $mc->getInfo($entity); - $entitystring=$mc->label; - } - } + // TODO Set of entitystring should be done with a hook + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($entity)) + { + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; + } + } - $li=$userstatic->getNomUrl(-1, '', 0, 1); - if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity) - { - $li.=img_picto($langs->trans("SuperAdministrator"), 'redstar'); - } - elseif ($userstatic->admin) - { - $li.=img_picto($langs->trans("Administrator"), 'star'); - } - $li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; + $li=$userstatic->getNomUrl(-1, '', 0, 1); + if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity) + { + $li.=img_picto($langs->trans("SuperAdministrator"), 'redstar'); + } + elseif ($userstatic->admin) + { + $li.=img_picto($langs->trans("Administrator"), 'star'); + } + $li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; - $data[] = array( - 'rowid'=>$val['rowid'], - 'fk_menu'=>$val['fk_user'], - 'statut'=>$val['statut'], - 'entry'=>'
'.$langs->trans("Permissions").'
 '.$perm_libelle. '
'.$li.''.$userstatic->getLibStatut(3).'
' - ); -} + $data[] = array( + 'rowid'=>$val['rowid'], + 'fk_menu'=>$val['fk_user'], + 'statut'=>$val['statut'], + 'entry'=>'
'.$li.''.$userstatic->getLibStatut(3).'
' + ); + } -//var_dump($data); + //var_dump($data); -$title = $langs->trans("ListOfUsers"). ' - '.$langs->trans("HierarchicView"); + $title = $langs->trans("ListOfUsers"). ' - '.$langs->trans("HierarchicView"); -$param="search_statut=".urlencode($search_statut); + $param="search_statut=".urlencode($search_statut); -$newcardbutton=''; -if ($canadduser) -{ - $newcardbutton.= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1': '').'&leftmenu='); -} + $newcardbutton=''; + if ($canadduser) + { + $newcardbutton.= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1': '').'&leftmenu='); + } -$morehtmlright.= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/user/list.php'.(($search_statut != '' && $search_statut >= 0) ?'?search_statut='.$search_statut:'')); + $morehtmlright.= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/user/list.php'.(($search_statut != '' && $search_statut >= 0) ?'?search_statut='.$search_statut:'')); -print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton); + print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton); -print '
'."\n"; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + print ''."\n"; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; -print ''; + print '
'; -print ''; -print ''; -print ''; -// Status -print ''; -print ''; -print ''; + print ''; + print ''; + print ''; + // Status + print ''; + print ''; + print ''; -print ''; -print_liste_field_titre("HierarchicView"); -print_liste_field_titre('', $_SERVER['PHP_SELF'], "", '', "", 'align="center"'); -print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", 'align="right"'); -print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); -print ''; + print ''; + print_liste_field_titre("HierarchicView"); + print_liste_field_titre('', $_SERVER['PHP_SELF'], "", '', "", 'align="center"'); + print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", 'align="right"'); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); + print ''; -$nbofentries=(count($data) - 1); + $nbofentries=(count($data) - 1); -if ($nbofentries > 0) -{ - print ''; - print ''; - print ''; -} -else -{ - print ''; - print ''; - print ''; - print ''; -} + if ($nbofentries > 0) + { + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } -print "
  '; -print $form->selectarray('search_statut', array('-1'=>'','1'=>$langs->trans('Enabled')), $search_statut); -print ''; -$searchpicto=$form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
  '; + print $form->selectarray('search_statut', array('-1'=>'','1'=>$langs->trans('Enabled')), $search_statut); + print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; - tree_recur($data, $data[0], 0); - print '
'; - print ''; - print ''; - print ''; - print '
'.img_picto_common('', 'treemenu/branchbottom.gif').''; - print $langs->trans("NoCategoryYet"); - print ' 
'; - print '
'; + tree_recur($data, $data[0], 0); + print '
'; + print ''; + print ''; + print ''; + print '
'.img_picto_common('', 'treemenu/branchbottom.gif').''; + print $langs->trans("NoCategoryYet"); + print ' 
'; + print '
"; -print "
\n"; + print ""; + print "\n"; } // diff --git a/htdocs/user/home.php b/htdocs/user/home.php index b17eafb22e6..ec742f3e6a9 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -45,7 +45,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) // Security check (for external users) $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $companystatic = new Societe($db); $fuserstatic = new User($db); diff --git a/htdocs/user/info.php b/htdocs/user/info.php index 9296f0213ae..f10328e2a99 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -41,7 +41,7 @@ if ($id > 0 || ! empty($ref)) // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index da3f3c774c6..0f11b91cd9e 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -35,7 +35,7 @@ $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'userldap // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 5520465a75d..31e5c5382de 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -27,21 +27,24 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->categorie->enabled)) +if (! empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} -if (! $user->rights->user->user->lire && ! $user->admin) +if (! $user->rights->user->user->lire && ! $user->admin) { accessforbidden(); +} - // Load translation files required by page +// Load translation files required by page $langs->loadLangs(array('users', 'companies', 'hrm')); $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'userlist'; // To manage different context of search // Security check (for external users) $socid=0; -if ($user->societe_id > 0) - $socid = $user->societe_id; +if ($user->socid > 0) { + $socid = $user->socid; +} // Load mode employee $mode = GETPOST("mode", 'alpha'); @@ -108,13 +111,16 @@ $arrayfields=array( 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Init search fields $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); @@ -532,29 +538,29 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['u.firstname']['checked'])) { - print ''.$obj->firstname.''; + print ''.$obj->firstname.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.gender']['checked'])) { - print ''; - if ($obj->gender) print $langs->trans("Gender".$obj->gender); - print ''; + print ''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.employee']['checked'])) { - print ''.yn($obj->employee).''; + print ''.yn($obj->employee).''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.accountancy_code']['checked'])) { - print ''.$obj->accountancy_code.''; + print ''.$obj->accountancy_code.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.email']['checked'])) { - print ''.$obj->email.''; + print ''.$obj->email.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.api_key']['checked'])) @@ -577,7 +583,7 @@ while ($i < min($num, $limit)) print $langs->trans("DomainUser"); } else - { + { print $langs->trans("InternalUser"); } print ''; @@ -670,9 +676,9 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['u.statut']['checked'])) { - $userstatic->statut=$obj->statut; - print ''.$userstatic->getLibStatut(3).''; - if (! $i) $totalarray['nbfield']++; + $userstatic->statut=$obj->statut; + print ''.$userstatic->getLibStatut(5).''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 0fdbdd26b81..51f6740d636 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -43,7 +43,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessfor // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index b48823d2aa0..2d6bc021355 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'aZ09'); $actionid=GETPOST('actionid'); // Security check -if ($user->societe_id) $id=$user->societe_id; +if ($user->socid) $id=$user->socid; $result = restrictedArea($user, 'societe', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -208,7 +208,7 @@ if ($result > 0) print "\n"; -// $listofemails=$object->thirdparty_and_contact_email_array(); + // $listofemails=$object->thirdparty_and_contact_email_array(); if ($object->email) { $actions=array(); @@ -294,7 +294,7 @@ if ($result > 0) if ($num) { - $i = 0; + $i = 0; $userstatic=new user($db); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 813b5ab4b7f..736db8767ec 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -47,7 +47,7 @@ if ($id) // Security check $socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; +if ($user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index a49c3e930b0..26758f52ab0 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -56,7 +56,7 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) // Security check $socid=0; -if (isset($user->societe_id) && $user->societe_id > 0) $socid = $user->societe_id; +if (isset($user->socid) && $user->socid > 0) $socid = $user->socid; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); // A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) @@ -255,7 +255,7 @@ print '
'; if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); // Show warning about external users -if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n"; +if (empty($user->socid)) print info_admin(showModulesExludedForExternal($modules))."\n"; $parameters=array('permsgroupbyentity'=>$permsgroupbyentity); $reshook=$hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -283,7 +283,7 @@ print ''.$langs->trans("Permissions").''; print ''."\n"; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; -$sql = "SELECT r.id, r.libelle, r.module, r.module_position"; +$sql = "SELECT r.id, r.libelle as label, r.module, r.module_position"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " AND r.entity = " . $entity; @@ -421,7 +421,7 @@ if ($result) } // Label - $permlabel=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle))); + $permlabel=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->label))); print ''.$permlabel.''; print ''."\n"; diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index b6bfb90e22c..3e89df4e587 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -35,11 +35,11 @@ if ($_POST) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } - if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); - } + if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } else { + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + } } $title = $langs->trans('ModuleSetup').' '.$langs->trans('ProductAttributes'); diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php index 6f028f5aa8b..38affc574d2 100644 --- a/htdocs/variants/ajax/getCombinations.php +++ b/htdocs/variants/ajax/getCombinations.php @@ -31,18 +31,18 @@ header('Content-Type: application/json'); $id = GETPOST('id', 'int'); if (!$id) { -print json_encode(array( - 'error' => 'ID not set' - )); - exit(); + print json_encode(array( + 'error' => 'ID not set' + )); + exit(); } $product = new Product($db); if ($product->fetch($id) < 0) { -print json_encode(array( - 'error' => 'Product not found' - )); + print json_encode(array( + 'error' => 'Product not found' + )); } $prodcomb = new ProductCombination($db); diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index 0d72b16c5ed..866bac1ef78 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -31,19 +31,19 @@ header('Content-Type: application/json'); $id = GETPOST('id'); if (!$id) { -print json_encode(array( - 'error' => 'ID not set' - )); - exit(); + print json_encode(array( + 'error' => 'ID not set' + )); + exit(); } $prodattr = new ProductAttribute($db); if ($prodattr->fetch($id) < 0) { -print json_encode(array( - 'error' => 'Attribute not found' - )); - exit(); + print json_encode(array( + 'error' => 'Attribute not found' + )); + exit(); } $prodattrval = new ProductAttributeValue($db); @@ -51,10 +51,10 @@ $prodattrval = new ProductAttributeValue($db); $res = $prodattrval->fetchAllByProductAttribute($id); if ($res == -1) { -print json_encode(array( - 'error' => 'Internal error' - )); - exit(); + print json_encode(array( + 'error' => 'Internal error' + )); + exit(); } print json_encode($res); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index e425aa16c5d..5847aa259b4 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -144,58 +144,54 @@ if ($action == 'edit') { } -if ($action != 'edit') -{ +if ($action != 'edit') { print '
'; print '
'; } -?> - - - - - - - - - +print '
trans('Ref') ?> - ref.'">'; - } else { - print dol_htmlentities($object->ref); - } ?> -
trans('Label') ?> - label.'">'; - } else { - print dol_htmlentities($object->label); - } ?> -
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; -
'.$langs->trans('Ref').''; +if ($action == 'edit') { + print ''; +} else { + print dol_htmlentities($object->ref); +} +print '
'.$langs->trans('Label').''; +if ($action == 'edit') { + print ''; +} else { + print dol_htmlentities($object->label); +} +print '
+print ''; -'; } dol_fiche_end(); -if ($action == 'edit') { ?> -
-
- -     - -
-
-'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print '
'; +} else { if ($action == 'delete') { $form = new Form($db); -print $form->formconfirm( + print $form->formconfirm( "card.php?id=".$object->id, $langs->trans('Delete'), $langs->trans('ProductAttributeDeleteDialog'), @@ -208,7 +204,7 @@ print $form->formconfirm( if ($objectval->fetch($valueid) > 0) { $form = new Form($db); -print $form->formconfirm( + print $form->formconfirm( "card.php?id=".$object->id."&valueid=".$objectval->id, $langs->trans('Delete'), $langs->trans('ProductAttributeValueDeleteDialog', dol_htmlentities($objectval->value), dol_htmlentities($objectval->ref)), @@ -241,20 +237,19 @@ print $form->formconfirm( print ''; print ''; print ''; - } ?> + } - - - - - - + print '
trans('Ref') ?>trans('Value') ?>
'; + print ''; + print ''; + print ''; + print ''; + print ''; - fetchAllByProductAttribute($object->id) as $attrval) { - ?> - - id)): ?> + foreach ($objectval->fetchAllByProductAttribute($object->id) as $attrval) { + print ''; + if ($action == 'edit_value' && ($valueid == $attrval->id)) { + ?> - + - - - -
'.$langs->trans('Ref').''.$langs->trans('Value').'
@@ -262,31 +257,30 @@ print $form->formconfirm(     ref) ?> value) ?>
+ print ''; + } + print ''; - - - + if ($action == 'edit_value') { + print ''; + } - - - '; + print '
'; + print ''.$langs->trans('Create').''; + print '
'; + print '
'; } // End of page diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index db0d49a0e36..21346d6124e 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -572,9 +572,9 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; } if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; } else { - $newproduct->ref .= '_'.$prodattrval->ref; + $newproduct->ref .= '_'.$prodattrval->ref; } //The first one should not contain a linebreak diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 080242d3137..03f424f2dcc 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -304,7 +304,7 @@ if (! empty($id) || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1); print '
'; @@ -350,7 +350,7 @@ if (! empty($id) || ! empty($ref)) print ''.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string($object->weight_units, "weight"); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { @@ -425,7 +425,7 @@ if (! empty($id) || ! empty($ref)) fetch($pc2v->fk_prod_attr_val); - ?> + ?> variants_selected.index.push(fk_prod_attr ?>); variants_selected.info[fk_prod_attr ?>] = { attribute: variants_available[fk_prod_attr ?>], @@ -434,7 +434,7 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - @@ -484,7 +484,7 @@ if (! empty($id) || ! empty($ref)) }); - '; @@ -495,40 +495,36 @@ if (! empty($id) || ! empty($ref)) print ''; print ''."\n"; print ''."\n"; - if($valueid > 0) { + if ($valueid > 0) { print ''."\n"; } print dol_fiche_head(); - ?> - - - - - - '; + print '
- '; - print ''; - foreach ($prodattr_all as $attr) - { - //print ''; - print ''; - } - print ''; + print ''; + if ($action == 'add') { + print "\n"; + print ''; + print ''; + print ' @@ -555,15 +551,14 @@ if (! empty($id) || ! empty($ref)) - -
'; + if (is_array($prodattr_all)) { + print ''; + } - $htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); - print $form->textwithpicto('', $htmltext); - /*print '     id).'">'; - print $langs->trans("Create"); - print '';*/ + $htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); + print $form->textwithpicto('', $htmltext); + /*print '     id).'">'; + print $langs->trans("Create"); + print '';*/ - ?> + ?>
- -
- '; + print '
'; + } if (is_array($productCombination2ValuePairs1)) { - ?> + ?>
@@ -597,7 +592,7 @@ if (! empty($id) || ! empty($ref)) -isProduct()) { print ''; print ''; @@ -644,7 +639,7 @@ if (! empty($id) || ! empty($ref)) if ($productCombinations) { - ?> + ?> '; } @@ -3286,6 +3277,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if ($listofpages['code'] == 'OK') { + print ''."\n"; print '
'; if ($action == 'replacesiteconfirm') @@ -3317,7 +3309,8 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '
'; print ''; print ''; print ''; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index b9a1239449e..db8c5b632f6 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -61,8 +61,8 @@ foreach($object->fields as $key => $val) if (empty($action) && empty($id) && empty($ref)) $action='view'; // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'website', $id); $permissionnote=$user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 287f1b9e3b7..c4fb81065d5 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -149,7 +149,7 @@ class ZapierApi extends DolibarrApi $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; // Set to 1 if there is a field socid in table of object $restrictonsocid = 0; diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 81b76b1c81f..5c79d68aefe 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -633,37 +633,37 @@ class Hook extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) { + if (empty($this->labelStatus)) { global $langs; //$langs->load("zapier@zapier"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); + $this->labelStatus[1] = $langs->trans('Enabled'); + $this->labelStatus[0] = $langs->trans('Disabled'); } if ($mode == 0) { - return $this->labelstatus[$status]; + return $this->labelStatus[$status]; } elseif ($mode == 1) { - return $this->labelstatus[$status]; + return $this->labelStatus[$status]; } elseif ($mode == 2) { if ($status == 1) { - return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; } elseif ($status == 0) { - return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; } } elseif ($mode == 3) { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; + elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; } elseif ($mode == 5) { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + if ($status == 1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { if ($status == 1) { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); } elseif ($status == 0) { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); } } } diff --git a/htdocs/zapier/hook_agenda.php b/htdocs/zapier/hook_agenda.php index 6a10972a30e..52909360ba0 100644 --- a/htdocs/zapier/hook_agenda.php +++ b/htdocs/zapier/hook_agenda.php @@ -66,8 +66,8 @@ else $search_agenda_label=GETPOST('search_agenda_label'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index 1d8a042435e..aca2e59df9b 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -99,8 +99,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; 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 // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); diff --git a/htdocs/zapier/hook_document.php b/htdocs/zapier/hook_document.php index e5b4d8277b9..6ad31221cc4 100644 --- a/htdocs/zapier/hook_document.php +++ b/htdocs/zapier/hook_document.php @@ -54,8 +54,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); // Get parameters diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index c1437eb02f6..e622ce8bcff 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -116,9 +116,9 @@ if (! $sortorder) { // Security check $socid=0; -if ($user->societe_id > 0) { +if ($user->socid > 0) { // Protection if external user - //$socid = $user->societe_id; + //$socid = $user->socid; accessforbidden(); } //$result = restrictedArea($user, 'mymodule', $id, ''); diff --git a/htdocs/zapier/hook_note.php b/htdocs/zapier/hook_note.php index 718acc606d4..dcfba358da1 100644 --- a/htdocs/zapier/hook_note.php +++ b/htdocs/zapier/hook_note.php @@ -60,8 +60,8 @@ $hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that co $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; +//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); // Load object diff --git a/htdocs/zapier/zapierindex.php b/htdocs/zapier/zapierindex.php index 6e9e0491946..9bec765c35e 100644 --- a/htdocs/zapier/zapierindex.php +++ b/htdocs/zapier/zapierindex.php @@ -50,10 +50,10 @@ $action=GETPOST('action', 'alpha'); // Securite acces client if (! $user->rights->zapierfordolibarr->read) accessforbidden(); $socid=GETPOST('socid', 'int'); -if (isset($user->societe_id) && $user->societe_id > 0) +if (isset($user->socid) && $user->socid > 0) { $action = ''; - $socid = $user->societe_id; + $socid = $user->socid; } $max=5;
>
'.$langs->trans("Container").''; - print ''.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).''; + print $answerrecord->getNomUrl(1); + print ' ('.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).')'; print ''.$answerrecord->description; print '