diff --git a/ChangeLog b/ChangeLog index f6a1c949bf5..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. @@ -47,7 +50,6 @@ 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 @@ -116,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 @@ -135,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 @@ -156,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 @@ -186,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/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/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 a45f94760da..add7d7b643b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1867,7 +1867,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 e9b1a5e4de8..ff2e5082736 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -183,7 +183,7 @@ class Adherent extends CommonObject // -1:brouillon, 0:resilie, >=1:valide,paye // def in common object - //public $statut; + //public $status; public $photo; @@ -2165,61 +2165,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"); $statusType = ''; - $labelstatut = ''; - $labelstatutShort = ''; + $labelStatus = ''; + $labelStatusShort = ''; - if ($statut == -1) + if ($status == -1) { $statusType = 'status0'; - $labelstatut = $langs->trans("MemberStatusDraft"); - $labelstatutShort = $langs->trans("MemberStatusDraftShort"); + $labelStatus = $langs->trans("MemberStatusDraft"); + $labelStatusShort = $langs->trans("MemberStatusDraftShort"); } - elseif ($statut >= 1) { + elseif ($status >= 1) { if ($need_subscription == 0) { $statusType = 'status4'; - $labelstatut = $langs->trans("MemberStatusNoSubscription"); - $labelstatutShort = $langs->trans("MemberStatusNoSubscriptionShort"); + $labelStatus = $langs->trans("MemberStatusNoSubscription"); + $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } elseif (! $date_end_subscription) { $statusType = 'status1'; - $labelstatut = $langs->trans("MemberStatusActive"); - $labelstatutShort = $langs->trans("MemberStatusActiveShort"); + $labelStatus = $langs->trans("MemberStatusActive"); + $labelStatusShort = $langs->trans("MemberStatusActiveShort"); } elseif ($date_end_subscription < time()) { $statusType = 'status3'; - $labelstatut = $langs->trans("MemberStatusActiveLate"); - $labelstatutShort = $langs->trans("MemberStatusActiveLateShort"); + $labelStatus = $langs->trans("MemberStatusActiveLate"); + $labelStatusShort = $langs->trans("MemberStatusActiveLateShort"); } else { $statusType = 'status4'; - $labelstatut = $langs->trans("MemberStatusPaid"); - $labelstatutShort = $langs->trans("MemberStatusPaidShort"); + $labelStatus = $langs->trans("MemberStatusPaid"); + $labelStatusShort = $langs->trans("MemberStatusPaidShort"); } } - elseif ($statut == 0) + elseif ($status == 0) { $statusType = 'status6'; - $labelstatut = $langs->trans("MemberStatusResiliated"); - $labelstatutShort = $langs->trans("MemberStatusResiliatedShort"); + $labelStatus = $langs->trans("MemberStatusResiliated"); + $labelStatusShort = $langs->trans("MemberStatusResiliatedShort"); } - return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); + 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 3f3c77568c2..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) { @@ -294,7 +294,7 @@ print "
\n"; print '
'; /* - * Last modified members + * Latest modified members */ $max=5; @@ -342,7 +342,7 @@ if ($resql) print ''.$staticmember->getNomUrl(1, 32).''; print ''.$statictype->getNomUrl(1, 32).''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; - print ''.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 5).''; + print ''.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).''; 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/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 ''.$langs->trans("Example").''; print ''.$langs->trans("CodeBarGenerator").''; 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 ''; - 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/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..eb432b0dc72 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(); } @@ -393,7 +393,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) +foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index c39cc385313..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) { 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 074216dee3e..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 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..8ea4f46c89d 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,''); @@ -407,7 +407,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) +foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } 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/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 6186e809543..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); @@ -662,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')); @@ -693,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 444caa2a4da..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; @@ -809,19 +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'); } $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; - return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode); } /** 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 15a6f820647..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; @@ -861,11 +861,11 @@ if ($action == 'create') if (GETPOST('datep', 'int', 1)) $datep=dol_stringtotime(GETPOST('datep', 'int', 1), 0); 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'); } @@ -1612,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 8432ba786a1..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) { @@ -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/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 9ad3ef80dde..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=''; @@ -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 @@ -1735,7 +1735,7 @@ function sort_events_by_date($a, $b) } // 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) diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 02277fc30e8..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; + $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 1b33e5da9b8..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=''; @@ -488,7 +488,7 @@ if ($resql) if (! empty($arrayfields['a.tms']['checked'])) print ''; if (! empty($arrayfields['a.percent']['checked'])) { print ''; } 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 ce577de78bd..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=''; @@ -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 57239c355b4..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 '
'.$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 '
'; - 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 '
'; 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 e5d096dea26..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 $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")).''; } @@ -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) { diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 10314b597e7..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, ''); 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 c16d7237439..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'); 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 ''; print ''; - print "
'.$langs->trans("SearchAMailing").'
'; @@ -68,7 +69,7 @@ print '
'; print '
'; print $langs->trans("Other").':

\n"; + print "

\n"; //} @@ -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 113d3baf503..8f28a65473c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -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); @@ -1717,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') . ''; @@ -2202,11 +2202,11 @@ if ($action == 'create') print ''; - if ($action != 'editmulticurrencycode' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) print ''; print '
'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; print ''; - if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { + if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); @@ -2214,29 +2214,33 @@ if ($action == 'create') print ''; // Multicurrency rate - print ''; - print ''; - print ''; - if ($action != 'editmulticurrencyrate' && $object->statut == Propal::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) - print ''; - print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; - if ($object->statut == Propal::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { - if($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print ''; + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) + print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($object->statut ==$object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } } + print ''; } - print ''; } if ($soc->outstanding_limit) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a2b89dedb11..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; @@ -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. @@ -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; 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 cb798e2fdd6..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); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index c1719ddbe45..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); 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 848d707f22f..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); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 01d4c264667..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; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 7c3d58f64d5..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); 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/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 192aaccbddf..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; + $socid = $user->socid; } diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 0759c47c06c..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; + $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 e645bf3cee6..a6427dbd045 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); @@ -1803,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 ''; @@ -2057,12 +2057,8 @@ if ($action == 'create' && $usercancreate) if ($action == 'clone') { // Create an array for form $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' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)'))); + array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) + ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } @@ -2291,25 +2287,28 @@ if ($action == 'create' && $usercancreate) print ''; // Multicurrency rate - print ''; - print ''; - $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT; - print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); - print ''; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print ''; + print ''; + $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT; + print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); + print ''; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } } + print ''; } - print ''; } // Delivery delay 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 37dd5a8d570..5f9906b58dc 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; @@ -268,7 +268,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; @@ -769,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); @@ -785,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; @@ -974,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 7f96d9e28e7..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'); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 457e311d01c..773ee1e9255 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'); } @@ -1065,9 +1065,10 @@ if ($resql) } } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + $element = 'banktransaction'; + if (is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$element]['label'] as $key => $val) { if (! empty($arrayfields["ef.".$key]['checked'])) { 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/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 53fa268b750..57cff121010 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1188,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,"; @@ -1244,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,"; @@ -1283,7 +1283,7 @@ class Account extends CommonObject global $db, $conf, $user; //Protection against external users - if ($user->societe_id) { + if ($user->socid) { return 0; } 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 67a38e03cc6..1a250a83b10 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -46,12 +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; +if ($user->socid) + $socid = $user->socid; // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); 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 1b06a0e222b..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'); 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 cec68cf2c3a..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 diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 5cb9d3c9558..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); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 21598990aba..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 diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 7d55703802e..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', '', '', ''); /* 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 6a320970396..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 ''; print ''; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print ''; + print ''; + } + } + // Help of substitution key $dateexample=dol_now(); if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; @@ -1701,11 +1756,11 @@ else { if (empty($object->suspended)) { - print ''; + print ''; } else { - print ''; + print ''; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 08fbb019fd2..fce1fb7cb25 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -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); @@ -2579,7 +2579,6 @@ $title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Card'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); - // Mode creation if ($action == 'create') @@ -2600,18 +2599,19 @@ 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 = $reg[1]; + $subelement = $regs[2]; } if ($element == 'project') { $projectid = $originid; - if (!$cond_reglement_id) { + if (empty($cond_reglement_id)) { $cond_reglement_id = $soc->cond_reglement_id; } - if (!$mode_reglement_id) { + if (empty($mode_reglement_id)) { $mode_reglement_id = $soc->mode_reglement_id; } if (!$remise_percent) { @@ -2754,7 +2754,7 @@ if ($action == 'create') // Thirdparty print ''; - if ($soc->id > 0 && ! GETPOST('fac_rec', 'alpha')) + if ($soc->id > 0 && ! GETPOST('fac_rec', 'int')) { print ''; print ''; - print ''; - print ''; + print ''; } - print ''; } // Bank Account @@ -4099,7 +4111,7 @@ elseif ($id > 0 || ! empty($ref)) } $displayWarranty = false; - if( ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) ) + if (($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)))) { // Check if this situation invoice is 100% for real if(!empty($object->situation_final) && !empty($object->lines)){ @@ -4179,9 +4191,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; - - - if($displayWarranty) + if ($displayWarranty) { // Retained Warranty payment date limit print ''; print ''; @@ -672,6 +672,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''; print ''; print ''; + $tot_ttc+=$obj->amount; $i++; } @@ -957,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"; @@ -1074,9 +1075,8 @@ if ($resql) { $obj = $db->fetch_object($resql); - print ''; - print ''; + print ''; $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 0251173a863..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)) 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 ''; @@ -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..7faa2727ae4 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); @@ -117,8 +117,6 @@ if (GETPOST("orphelins", "alpha")) $sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,"; $sql.= " p.statut, p.num_paiement,"; $sql.= " c.code as paiement_code"; - // Add fields for extrafields - foreach ($extrafields->attribute_list as $key => $val) $sql.=",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 @@ -139,8 +137,6 @@ else $sql.= " c.code as paiement_code,"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,"; $sql.= " s.rowid as socid, s.nom as name, s.email"; - // Add fields for extrafields - foreach ($extrafields->attribute_list as $key => $val) $sql.=",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 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 def454f2ca5..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; } @@ -202,9 +202,9 @@ if ($action == 'create') 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").''; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 1b70641a6bc..0601c62fd80 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -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'); } } 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/fiche-rec.php b/htdocs/compta/facture/card-rec.php similarity index 94% rename from htdocs/compta/facture/fiche-rec.php rename to htdocs/compta/facture/card-rec.php index 79780402108..10eb2ac03c8 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -25,7 +25,7 @@ */ /** - * \file htdocs/compta/facture/fiche-rec.php + * \file htdocs/compta/facture/card-rec.php * \ingroup facture * \brief Page to show predefined invoice */ @@ -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); @@ -387,6 +387,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } + // Multicurrency Code + elseif ($action == 'setmulticurrencycode' && $usercancreate) { + $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); + } + + // Multicurrency rate + elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); + } // Delete line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) @@ -1039,7 +1048,7 @@ if ($action == 'create') print $doleditor->Create(1); // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print '
'; @@ -1346,6 +1355,52 @@ else } print '
'; + print ''; + if ($usercancreate && $action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + $htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname); + print '
'; + print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } + } + print '
' . $langs->trans('Customer') . ''; print $soc->getNomUrl(1); @@ -2797,7 +2797,7 @@ if ($action == 'create') $exampletemplateinvoice=new FactureRec($db); - // Overwrite value if creation of invoice is from a predefined invoice + // Overwrite some values if creation of invoice is from a predefined invoice if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { $invoice_predefined = new FactureRec($db); @@ -2811,6 +2811,9 @@ if ($action == 'create') $note_public = $invoice_predefined->note_public; $note_private = $invoice_predefined->note_private; + if (! empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; + if (! empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; + $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; @@ -2833,7 +2836,7 @@ if ($action == 'create') if (GETPOST('fac_rec') == $objp->rowid) { print ' selected'; - $exampletemplateinvoice->fetch(GETPOST('fac_rec')); + $exampletemplateinvoice->fetch(GETPOST('fac_rec', 'int')); } print '>' . $objp->title . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')'; $i ++; @@ -2921,12 +2924,17 @@ if ($action == 'create') // Next situation invoice $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); + print '
'; $tmp='' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) $tmp.=' disabled'; + if ($opt == ('') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) + $tmp.=' disabled'; $tmp.= '> '; $text = ' '; - $text .= '' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) + $text .= ' disabled'; + $text .='>'; $text .= $opt; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1, 'help', '', 0, 3); @@ -3334,7 +3342,7 @@ if ($action == 'create') print $doleditor->Create(1); // Private note - if (empty($user->societe_id)) + if (empty($user->socid)) { print '
'; @@ -3460,7 +3468,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); } @@ -4030,29 +4038,33 @@ elseif ($id > 0 || ! empty($ref)) $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname); print '
'; - print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; - print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print '
'; + print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } } + print '
'; @@ -4547,7 +4557,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(); @@ -5024,7 +5034,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print '' . $langs->trans("ChangeIntoRepeatableInvoice") . ''; + print '' . $langs->trans("ChangeIntoRepeatableInvoice") . ''; } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 25d92fad92a..da5ad40002b 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -565,7 +565,7 @@ class Invoices extends DolibarrApi throw new RestException(500); } - return array( + return array( 'success' => array( 'code' => 200, 'message' => 'Invoice deleted' diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 9ff90b7b025..408ce2c1303 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -896,7 +896,7 @@ class FactureRec extends CommonInvoice * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param int $fk_fournprice Id of origin supplier price - * @param int $pa_ht Price (without tax) of product when it was bought + * @param int $pa_ht Price (without tax) of product for margin calculation * @return int <0 if KO, Id of line if OK */ public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) @@ -920,8 +920,9 @@ class FactureRec extends CommonInvoice $remise_percent=price2num($remise_percent); $qty=price2num($qty); if (empty($info_bits)) $info_bits=0; - $pu_ht=price2num($pu_ht); - $pu_ttc=price2num($pu_ttc); + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pu_ht_devise = price2num($pu_ht_devise); $txtva=price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); @@ -1258,7 +1259,7 @@ class FactureRec extends CommonInvoice } } - $url = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id; + $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; if ($short) return $url; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8859578e94b..ac39b84e428 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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 @@ -3961,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; @@ -3970,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) @@ -4211,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 62960b71346..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); 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/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index f714d51cf6e..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); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5f1ce9e44c3..74c27c1e467 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; @@ -512,9 +512,8 @@ if (! $sall) $sql.= " p.rowid, p.ref, p.title"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields - 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) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } } else 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 cf59af89cf6..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); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index dadbb27b30d..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'; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 1453491fd11..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; @@ -624,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(); @@ -661,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 '
'.price($obj->sumpaid).''.$chargestatic->getLibStatut(3).'
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->libelle.' '.$obj->label.'
'.$obj->label.'
'.$langs->trans('PaymentMode').''.$labeltype; print $object->num_paiement?' - '.$object->num_paiement:''; 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 1282226623c..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'); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4016ebdc813..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(); @@ -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 3dbfec69461..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'); 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).'
'; 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 0503f31d6fb..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++; } 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 7399a7098c6..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)) { @@ -495,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 590269b332c..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'); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 5570b08435b..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'); 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 cf28a4cd5d6..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'); 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_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index d7cfe53b0bc..8ab92047daa 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -133,7 +133,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)) { print '
'; if ($user->rights->societe->contact->creer) { print ''.$langs->trans('Modify').''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 08b2e8e1d41..9642cdfa84c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -76,7 +76,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 @@ -181,7 +181,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'); @@ -377,7 +377,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'); @@ -638,8 +638,8 @@ else } // Civility - print '
'; print ''; @@ -962,8 +962,8 @@ else } // Civility - print ''; print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index c6c674bd4cd..f8a43d70494 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -213,7 +213,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"; @@ -222,7 +222,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) @@ -386,13 +386,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)."'"; @@ -1320,13 +1320,13 @@ class Contact extends CommonObject // phpcs:enable global $langs; - $labelstatus = array( + $labelStatus = array( 0 => 'ActivityCeased', 1 => 'InActivity', 4 => 'InActivity', 5 => 'ActivityCeased', ); - $labelstatusshort = array( + $labelStatusShort = array( 0 => 'ActivityCeased', 1 => 'InActivity', 4 => 'InActivity', @@ -1336,8 +1336,8 @@ class Contact extends CommonObject $statusType = 'status4'; if ($status==0 || $status==5) $statusType = 'status5'; - $label = $langs->trans($labelstatus[$status]); - $labelshort = $langs->trans($labelstatusshort[$status]); + $label = $langs->trans($labelStatus[$status]); + $labelshort = $langs->trans($labelStatusShort[$status]); return dolGetStatus($label, $labelshort, '', $statusType, $mode); } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 00817ee5799..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 '
'; @@ -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'; @@ -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 '
'; - print ''; + print ''; // Type of contact label print ''; $total_qty+=$objp->prod_qty; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 1dbc22d1a51..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 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 60232a052af..6694c363977 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -54,7 +54,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')); 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 df1629b46a6..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; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3a8e4f99a65..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 @@ -1256,7 +1256,7 @@ if ($action == 'create') print $doleditor->Create(1); print '
'; - if (empty($user->societe_id)) + if (empty($user->socid)) { print ''; print ''; print ''."\n"; + $choice .= ''; $choice .= ''; + $choice .= ''."\n"; $choice .= ''."\n"; + $positionkey = ($foundrecommandedchoice ? 999 : 0); if ($allowinstall) { - $available_choices[] = $choice; + $available_choices[$positionkey] = $choice; } else { - $notavailable_choices[] = $choice; + $notavailable_choices[$positionkey] = $choice; } // Show upgrade lines @@ -508,7 +508,8 @@ else } } - $choice .= "\n".''; + $choice .= "\n".''."\n"; + $choice .= ''; $choice .= ''; $choice .= ''."\n"; if ($allowupgrade) { - $available_choices[] = $choice; + $available_choices[$count] = $choice; } else { - $notavailable_choices[] = $choice; + $notavailable_choices[$count] = $choice; } } @@ -570,6 +571,7 @@ else } // Array of install choices + krsort($available_choices, SORT_NATURAL); print"\n"; 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 $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 $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 '
'.$prodreftxt.''.$objp->libelle.''.$objp->type_contact_label.''.$objp->prod_qty.'
'.$langs->trans("NotePrivate").''; $doleditor=new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); @@ -1890,7 +1890,7 @@ else print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''; - 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 '
'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a6ccd9f7cf1..0b9c6768eda 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -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 * @@ -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 81c0b13449b..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 != '') 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/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_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 327f06fc0c9..40d809fd6e7 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.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 09e33c5f6a8..5bdb17ba0b9 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -90,10 +90,10 @@ class box_contacts extends ModeleBoxes $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); 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_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/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 20889e1a742..6a9bc0c9f29 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -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) @@ -820,7 +843,7 @@ abstract class CommonDocGenerator $id = $object->array_options['options_'.$key]; if ($id != "") { - $param = $extrafields->attribute_param[$key]; + $param = $extrafields->attributes[$object->table_element]['param'][$key]; $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); $classname=$InfoFieldList[0]; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index ec27b83e0a0..b6381ccc7ca 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.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,20 +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 6adbba4366a..0cfe1958f03 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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) @@ -1064,13 +1069,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; @@ -1093,7 +1098,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); @@ -1748,7 +1753,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 @@ -5631,7 +5636,7 @@ abstract class CommonObject { $morecss = 'minwidth100imp'; } - elseif ($type == 'datetime') + elseif ($type == 'datetime' || $type == 'link') { $morecss = 'minwidth200imp'; } @@ -6100,7 +6105,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 { diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 61f02e0fa83..ef529f39d9a 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -1,6 +1,5 @@ +/* Copyright (C) 2015-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 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 6807e75ba80..83734acd36e 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'; } @@ -1586,7 +1586,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data + * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data * @return string Formated value */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') @@ -1611,6 +1611,7 @@ class ExtraFields } else // Old usage { + //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; $size=$this->attribute_size[$key]; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index f944ccdc0c0..0eed1a56580 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -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 7f1c2cbee50..0aca6a94213 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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"; @@ -3765,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 @@ -3773,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; @@ -3784,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"; @@ -3815,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++; } @@ -3823,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").''; } } @@ -3839,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; @@ -3856,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"; @@ -3886,7 +3886,7 @@ class Form print ''; $i++; } @@ -3894,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").''; } } @@ -4070,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; @@ -4090,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 @@ -4105,7 +4113,7 @@ class Form } // Now add questions - $more.=''."\n"; + $more.='
'."\n"; if (! empty($formquestion['text'])) $more.='
'."\n"; foreach ($formquestion as $key => $input) { @@ -4117,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'); @@ -4171,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. @@ -5336,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; @@ -5729,7 +5738,8 @@ class Form if ($conf->use_javascript_ajax && $adddateof) { $tmparray=dol_getdate($adddateof); - $retstring.=' -
'; -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){ diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 8b11814c33b..27df27f8c1c 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -389,7 +389,7 @@ else // Show title if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL)) { - print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).'
'; + print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; print $langs->trans("VersionProgram").': '.DOL_VERSION.''; //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print '
'; @@ -397,18 +397,17 @@ else } else print "
\n"; - print $langs->trans("InstallEasy")." "; - print $langs->trans("ChooseYourSetupMode"); - - print '
'; + //print $langs->trans("InstallEasy")." "; + print '

'.$langs->trans("ChooseYourSetupMode").'...

'; $foundrecommandedchoice=0; $available_choices = array(); $notavailable_choices = array(); - // Show first install line - $choice = "\n".'
'.$langs->trans("FreshInstall").''; + // Show line of first install choice + $choice = '
'.$langs->trans("FreshInstall").''; $choice .= ''; $choice .= $langs->trans("FreshInstallDesc"); @@ -429,15 +428,16 @@ else } else { - $choice .= $langs->trans("InstallNotAllowed"); + $choice .= ($foundrecommandedchoice ? '' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '' : ''); } - $choice .= '
'.$langs->trans("Upgrade").'
'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
'; $choice .= $langs->trans("UpgradeDesc"); @@ -541,7 +542,7 @@ else } if ($disabled) { - $choice .= ''.$langs->trans("NotAvailable").''; + $choice .= ''.$langs->trans("NotYetAvailable").''; } else { @@ -556,9 +557,9 @@ else $choice .= '
'; foreach ($available_choices as $choice) { diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 0e1e23f8f2c..7a3bb7b3290 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -82,6 +82,9 @@ div.soustitre { .minwidth400imp { min-width: 400px !important; } .minwidth500imp { min-width: 500px !important; } +tr.trlineforchoice { + height: 4em; +} /* Force values for small screen 570 */ @media only screen and (max-width: 570px) 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/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 3df02cdc470..a343215c611 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; @@ -142,9 +146,13 @@ ALTER TABLE llx_stock_mouvement ADD COLUMN fk_projet INTEGER NOT NULL DEFAULT 0 ALTER TABLE llx_oauth_token ADD COLUMN fk_soc integer DEFAULT NULL after token; -ALTER TABLE llx_mailing ADD COLUMN tms timestamp; -ALTER TABLE llx_mailing_cibles ADD COLUMN tms timestamp; +ALTER TABLE llx_adherent_type ADD COLUMN duration varchar(6) DEFAULT NULL after morphy; + +https://www.royalmail.com/track-your-item#/ +https://www.royalmail.com/track-your-item#/ +https://www.royalmail.com/track-your-item#/ +https://www.royalmail.com/track-your-item#/ ALTER TABLE llx_projet ADD COLUMN usage_opportunity integer DEFAULT 0; ALTER TABLE llx_projet ADD COLUMN usage_task integer DEFAULT 1; ALTER TABLE llx_projet CHANGE COLUMN bill_time usage_bill_time integer DEFAULT 0; -- rename existing field @@ -472,3 +480,5 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value 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_adherent_type.sql b/htdocs/install/mysql/tables/llx_adherent_type.sql index 5a2dee3b12b..1de63a52c1f 100644 --- a/htdocs/install/mysql/tables/llx_adherent_type.sql +++ b/htdocs/install/mysql/tables/llx_adherent_type.sql @@ -30,6 +30,7 @@ create table llx_adherent_type statut smallint NOT NULL DEFAULT 0, libelle varchar(50) NOT NULL, morphy varchar(3) NOT NULL, + duration varchar(6) NOT NULL DEFAULT NULL, subscription varchar(3) NOT NULL DEFAULT 'yes', vote varchar(3) NOT NULL DEFAULT 'yes', note text, 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_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 ''; - 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/main.inc.php b/htdocs/main.inc.php index 0a225bb3aaf..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(); } @@ -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/customerMargins.php b/htdocs/margin/customerMargins.php index b8f530660f1..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'); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index a4aed7f668a..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'); 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 0bb48af3b46..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 @@ -480,10 +480,15 @@ if ($dirins && $action == 'initcss' && !empty($module)) '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.'>':'') + '---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 { @@ -518,6 +523,11 @@ if ($dirins && $action == 'initjs' && !empty($module)) ); 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 { @@ -635,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); + } } } @@ -792,6 +810,26 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //'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); @@ -810,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$'); @@ -884,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; @@ -937,6 +985,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) if (! $error) { setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); + $tabobj = $objectname; } } @@ -1105,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)) { @@ -1132,8 +1181,6 @@ if ($dirins && $action == 'confirm_delete') } } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; $action = ''; $module = 'deletemodule'; } @@ -1155,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++; @@ -1190,8 +1241,6 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) } } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; $action = ''; $tabobj = 'deleteobject'; } @@ -1418,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'); @@ -1475,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=''; @@ -1508,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 @@ -1583,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").'

'; @@ -1623,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:''); @@ -1719,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') @@ -1738,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 '
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 29b452e76ba..232cee40440 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/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/main.lang b/htdocs/langs/en_US/main.lang index 8bd954b306b..6e3ba31d36c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -184,6 +184,7 @@ Hide=Hide ShowCardHere=Show card Search=Search SearchOf=Search +SearchMenuShortCut=Ctrl + shift + f Valid=Valid Approve=Approve Disapprove=Disapprove diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 1f8399d939a..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 @@ -66,8 +66,8 @@ 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 @@ -124,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 6bf86dac102..bc71a65f72a 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -2,7 +2,7 @@ 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 @@ -14,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 diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b66d501f3ce..1ca335da637 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -347,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/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 756461488cc..aa61848fc9d 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -26,7 +26,7 @@ PROFILE_P822D=P822D Profile PROFILE_STAR=Star Profile PROFILE_DEFAULT_HELP=Default Profile suitable for Epson printers PROFILE_SIMPLE_HELP=Simple Profile No Graphics -PROFILE_EPOSTEP_HELP=Epos Tep Profile Help +PROFILE_EPOSTEP_HELP=Epos Tep Profile PROFILE_P822D_HELP=P822D Profile No Graphics PROFILE_STAR_HELP=Star Profile DOL_ALIGN_LEFT=Left align text 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/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.'
'; 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 '
'; @@ -1913,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 ''; @@ -1965,9 +2022,12 @@ 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 ' '.$langs->trans("LanguageFile").' : '; + if (! is_array($dicts) || empty($dicts)) print ''.$langs->trans("NoDictionaries").''; + else print ''.$dicts['langs'].''; print '
'; - print ' '.$langs->trans("LanguageFile").' : '.$dicts['langs'].'
'; print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); @@ -2092,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++; @@ -2144,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 '
'; @@ -2152,7 +2214,6 @@ elseif (! empty($module)) print $langs->trans("or"); print '
'; print '
'; - print '
'; //print ' '; print $langs->trans("InitStructureFromExistingTable"); print ''; @@ -2415,7 +2476,7 @@ elseif (! empty($module)) print load_fiche_titre($langs->trans("ObjectProperties"), '', ''); - + print ''."\n"; print '
'; print ''; print ''; @@ -2425,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 ''; @@ -2455,11 +2522,17 @@ elseif (! empty($module)) print ''; print ''; print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; print ''; print ''; @@ -2503,7 +2582,7 @@ elseif (! empty($module)) print ''; - print ''; print ''; + print ''; print ''; @@ -2530,16 +2612,34 @@ elseif (! empty($module)) print $propvisible?$propvisible:''; print ''; print ''; print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ print ''; print ''; print ''; @@ -2666,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 '
'; @@ -2806,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 '
'; @@ -2903,7 +3003,7 @@ elseif (! empty($module)) $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; print ''; - print ''; + print ''; + print ''; } else { @@ -2970,8 +3070,8 @@ elseif (! empty($module)) print ''; - print ''; + print ''; + print ''; print ''; } } @@ -3026,8 +3126,8 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''; - print ''; + print ''; + print ''; } else { @@ -3078,8 +3178,8 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''; - print ''; + print ''; + print ''; } else { @@ -3134,9 +3234,8 @@ elseif (! empty($module)) $pathtofile = $widget['relpath']; print ''; - print ''; + print ''; print ''; } } @@ -3221,8 +3320,8 @@ elseif (! empty($module)) $pathtofile = $clifile['relpath']; print ''; - print ''; + print ''; + print ''; print ''; } } @@ -3273,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 '
'; @@ -3402,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/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 41d0af33d46..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 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,13 +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_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + '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), @@ -656,22 +656,22 @@ class MyObject extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus) || empty($this->labelstatusshort)) + 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->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $this->labelstatusshort[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'); } $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; - return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode); + 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 6b522a45364..86eb50aff9e 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -382,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') @@ -394,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/myobject/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php similarity index 99% rename from htdocs/modulebuilder/template/core/modules/myobject/doc/doc_generic_myobject_odt.modules.php rename to htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index bffc0d5c470..822d6110c4b 100644 --- a/htdocs/modulebuilder/template/core/modules/myobject/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -486,7 +486,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php similarity index 100% rename from htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_advanced.php rename to htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php diff --git a/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php similarity index 100% rename from htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_standard.php rename to htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php diff --git a/htdocs/modulebuilder/template/core/modules/myobject/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php similarity index 100% rename from htdocs/modulebuilder/template/core/modules/myobject/modules_myobject.php rename to htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php 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'; + ?> + + + + + + + + + + \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..f75e7d352f1 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,19 @@ $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); + +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php /* - * 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 +127,6 @@ if (empty($reshook)) * View */ -$contactstatic = new Contact($db); - $form = new Form($db); if ($object->id > 0) @@ -159,7 +158,7 @@ if ($object->id > 0) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) + if ($permissiontoadd) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index fcf8b1f8a06..111e190bcf3 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -100,16 +100,16 @@ 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); -$permissionnote = $user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php -$permissionedit = $user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd = $user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php -$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); +$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->mymodule->myobject->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && $object->status == 0); @@ -319,8 +319,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref='
'; /* // Ref bis - $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); + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->myobject->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->myobject->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project @@ -328,7 +328,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->write) + if ($permissiontoadd) { if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; @@ -451,13 +451,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '' . $langs->trans('SendMail') . ''."\n"; // Back to draft - if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED) + if (! empty($user->rights->mymodule->myobject->write) && $object->status == BOM::STATUS_VALIDATED) { print '' . $langs->trans("SetToDraft") . ''; } // Modify - if (! empty($user->rights->mymodule->write)) + if (! empty($user->rights->mymodule->myobject->write)) { print ''.$langs->trans("Modify").''."\n"; } @@ -467,13 +467,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - if (! empty($user->rights->mymodule->write)) + if (! empty($user->rights->mymodule->myobject->write)) { print '' . $langs->trans("ToClone") . ''."\n"; } /* - if ($user->rights->mymodule->write) + if ($user->rights->mymodule->myobject->write) { if ($object->status == 1) { @@ -487,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ // Delete (need delete permission, or if draft, just need create/modify permission) - if (! empty($user->rights->mymodule->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mymodule->write))) + if (! empty($user->rights->mymodule->myobject->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mymodule->myobject->write))) { print ''.$langs->trans('Delete').''."\n"; } @@ -512,11 +512,11 @@ 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 - $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card + $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mymodule->myobject->create; // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ @@ -536,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 8deb44b9009..9d0954d277e 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -80,10 +80,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->ref); // 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', $object->id); +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php + /* @@ -146,9 +148,9 @@ if ($object->id) dol_fiche_end(); $modulepart = 'mymodule'; - //$permission = $user->rights->mymodule->create; + //$permission = $user->rights->mymodule->myobject->write; $permission = 1; - //$permtoedit = $user->rights->mymodule->create; + //$permtoedit = $user->rights->mymodule->myobject->write; $permtoedit = 1; $param = '&id=' . $object->id; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 525fa879562..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_buildpath('/mymodule/myobject_card.php', 1).'?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..89a8ed5513b 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -59,16 +59,16 @@ $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 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; -$permissionnote=1; -//$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote=$user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -113,7 +113,7 @@ if ($id > 0 || ! empty($ref)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) + if ($permissiontoadd) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; 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 $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 ''; @@ -2486,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 ''; @@ -2520,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 ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -2912,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').'
'.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.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').'
trans("MyObject"); ?>getNomUrl(1); ?>date, 'day'); ?>getLibStatut(7); ?>'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; - 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 0525f71ab5f..2cff993a05f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -94,8 +94,10 @@ class Mo extends CommonObject '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'=>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,), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'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), '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,), @@ -105,12 +107,10 @@ class Mo extends CommonObject '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'=>'StatusMOProduced', '-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; @@ -121,7 +121,13 @@ class Mo extends CommonObject 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; @@ -546,21 +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('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'); + $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'); } $statusType = 'status'.$status; //if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; - return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode); } /** diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 742d94109e2..36847b71035 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -163,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++; } @@ -216,7 +216,7 @@ if ($resql) print ''; print ''.$staticmo->getNomUrl(1, 32).''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; - print ''.$staticmo->getLibStatut(5).''; + print ''.$staticmo->getLibStatut(3).''; print ''; $i++; } @@ -235,8 +235,11 @@ else print '
'; -$parameters = array('type' => $type, 'user' => $user); -$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, null); // 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/mo_agenda.php b/htdocs/mrp/mo_agenda.php index a86d062c5e4..884bc234cbf 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -54,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 0ecbefc32a7..07b6be426f3 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -88,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); diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 3732754a62f..2c4d1b36c99 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_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, 'mrp', $id); // Get parameters diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 96f19540a95..b91affe403f 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -98,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 f815dfbaef6..aeb4630168d 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -47,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 index 70de7155f39..345bfe3f8dd 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -88,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); 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/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 fa131e1df6e..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 @@ -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'); 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/product.class.php b/htdocs/product/class/product.class.php index 2ba78b32945..de14a5621a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -325,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 @@ -2087,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; @@ -4380,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"); @@ -4420,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 775ffcf3e5c..4434f82fbcf 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -396,16 +396,16 @@ class Inventory extends CommonObject // phpcs:enable global $langs; - 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('Canceled'); + $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); + 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/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 35b433c5a28..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; 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 5303fa78a6c..85f40a9d214 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -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); @@ -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; 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 fbbec95f2df..3be66f6acfe 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(); } @@ -216,7 +216,9 @@ $sql.= " p.ref as product_ref,"; $sql.= " p.label as product_label,"; $sql.= " p.tobatch"; // Add fields for extrafields -foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +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 diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 3536088cab5..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'); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 2f0714737ee..27834923a0e 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -38,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'); 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 5f74a971f87..14dccfedb8d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -100,7 +100,7 @@ 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. +//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')); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 57be29b1bb2..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 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 c16d42ae97c..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'); @@ -171,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"; @@ -243,7 +243,7 @@ if ($resql) } print ''; print '
'; - print ''; + print ''; 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 2c311de7792..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); 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 2395f5f0bd1..0bffd50ce62 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -80,7 +80,7 @@ $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; 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 3dc54cc2223..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; 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 067c371bf67..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,7 +1872,10 @@ 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'); } } 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 832fd4fc70d..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 { @@ -820,7 +820,7 @@ if ($action == 'create') print ""; // Note Private - if ($object->note_private && ! $user->societe_id) + if ($object->note_private && ! $user->socid) { print '
'; print '
'.$labelstatus.''.$labelStatus.''.price((isset($valsamount[$status])?(float) $valsamount[$status]:0), 0, '', 1, -1, -1, $conf->currency).'
'.dol_print_date($db->jdate($obj->datem), 'day').''.$projectstatic->LibStatut($obj->fk_statut, 5).''.$projectstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("NotePrivate").''; @@ -2019,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 ''; 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 1a201a4bfd0..a2d2f494fc3 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -42,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; @@ -473,7 +473,7 @@ foreach ($search_array_options as $key => $val) { $crit=$val; $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attribute_type[$tmpkey]; + $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; $mode=0; if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int 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/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 0f003f05eb6..ae1b4ffb7f7 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -71,7 +71,7 @@ foreach ($search_array_options as $key => $val) { $crit=$val; $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attribute_type[$tmpkey]; + $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; if ($val != '') { $param.='&search_options_'.$tmpkey.'='.urlencode($val); } 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 32edd342cb8..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); 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/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_edit.tpl.php b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php index 11100c79d75..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; ?> @@ -78,7 +77,7 @@ $contact = $GLOBALS['objcanvas']->control->object; control->tpl['ismodifiable_customercode']) { ?> - control->tpl['customercode']; ?> + control->tpl['customercode']; ?> @@ -99,7 +98,7 @@ $contact = $GLOBALS['objcanvas']->control->object; control->tpl['ismodifiable_suppliercode']) { ?> - control->tpl['suppliercode']; ?> + control->tpl['suppliercode']; ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 6f3628d93b7..976b00962d8 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -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']; ?> diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 0d447ebe6c3..5ba0b3b6cc9 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); @@ -2296,7 +2296,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 '
'; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 91825fa0d2b..42fae860666 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1676,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); @@ -1686,6 +1693,8 @@ class Thirdparties extends DolibarrApi unset($object->lines); unset($object->thirdparty); + unset($object->fk_delivery_address); // deprecated feature + return $object; } 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/societe.class.php b/htdocs/societe/class/societe.class.php index edea020ec3a..21213272a26 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -70,6 +70,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'; /** @@ -328,11 +331,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 @@ -407,9 +411,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 @@ -1354,9 +1365,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->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -2236,7 +2247,7 @@ class Societe extends CommonObject $linkend=''; global $user; - if (! $user->rights->societe->client->voir && $user->societe_id > 0 && $this->id != $user->societe_id) + if (! $user->rights->societe->client->voir && $user->socid > 0 && $this->id != $user->socid) { $linkstart=''; $linkend=''; @@ -2260,8 +2271,8 @@ class Societe extends CommonObject /** * Return label of status (activity, closed) * - * @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 + * @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 getLibStatut($mode = 0) { @@ -2285,15 +2296,15 @@ class Societe extends CommonObject $statusType = 'status4'; if ($status == 0) $statusType = 'status5'; - if (empty($this->labelstatus) || empty($this->labelstatusshort)) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - $this->labelstatus[0] = $langs->trans("ActivityCeased"); - $this->labelstatus[1] = $langs->trans("InActivity"); - $this->labelstatusshort[0] = $langs->trans("ActivityCeased"); - $this->labelstatusshort[1] = $langs->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"); } - return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps 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 ad793fcf63e..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')); 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 df803b180ab..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"); @@ -804,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 @@ -1615,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 '
'; @@ -1721,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 '
'; @@ -1769,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 '
'; @@ -1869,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/website.php b/htdocs/societe/website.php index 0e0c5ac2cc8..5e199722961 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 '
'; @@ -428,14 +428,6 @@ print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', print ''."\n"; -// Detect if we need a fetch on each output line -$needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) -{ - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object -} - - // Detect if we need a fetch on each output line $needToFetchEachLine=0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index a9e417aa581..f398a013fb6 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.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/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 021a9fac1f9..c30e3169ee5 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -318,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; @@ -352,9 +353,10 @@ class Stripe extends CommonObject 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"; @@ -445,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 2614c8498f3..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); 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 b953087b885..340a959d1a2 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 @@ -1572,7 +1572,7 @@ if ($action == 'create') print ''; - if ($action != 'editmode' && $object->statut == SupplierProposal::STATUS_VALIDATED) + if ($action != 'editmode' && $object->statut == $object::STATUS_VALIDATED) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . '
'; print ''; @@ -1592,7 +1592,7 @@ if ($action == 'create') print ''; - if ($action != 'editmulticurrencycode' && $object->statut == SupplierProposal::STATUS_VALIDATED) + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) print ''; print '
'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; print ''; @@ -1604,29 +1604,32 @@ if ($action == 'create') print ''; // Multicurrency rate - print ''; - print ''; - print ''; - if ($action != 'editmulticurrencyrate' && $object->statut == SupplierProposal::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; - print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if ($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } } + print ''; } - print ''; } /* Not for supplier proposals diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index be272ee2d36..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,7 +1735,7 @@ class SupplierProposal extends CommonObject $result = $this->updateOrCreatePriceFournisseur($user); } } - if ($statut == 4) + if ($status == 4) { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } @@ -2196,20 +2199,20 @@ class SupplierProposal extends CommonObject // phpcs:enable // 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("supplier_proposal"); - $this->labelstatut[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[self::STATUS_VALIDATED]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[self::STATUS_VALIDATED]=$langs->trans("Opened"); - $this->labelstatut_short[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosedShort"); + $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"); } $statusnew=''; @@ -2219,7 +2222,7 @@ class SupplierProposal extends CommonObject elseif ($status==self::STATUS_NOTSIGNED) $statusnew='status5'; elseif ($status==self::STATUS_CLOSE) $statusnew='status6'; - return dolGetStatus($this->labelstatut[$status], $this->labelstatut_short[$status], '', $statusnew, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusnew, $mode); } @@ -2258,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"); } @@ -2275,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 d60fb3c04bc..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); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 991059b9141..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); 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 ec269354af6..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); 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 447dc057979..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); 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/terminal.php b/htdocs/takepos/admin/terminal.php index b009d01659b..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; 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/takepos.php b/htdocs/takepos/takepos.php index dd65469ec05..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."'; } "; diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 975f2eb311f..27fc142d991 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -37,7 +37,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> padding: 0; border-radius: 50%; padding: 0.45em; - vertical-align: middle; + vertical-align: text-top; } a.badge:focus, a.badge:hover { diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 51fbfd6a561..59c015b6245 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -260,4 +260,23 @@ div.pagination li:first-child a.btnTitle{ .butActionRefused, .butActionNewRefused, .btnTitle.refused { display: none !important; } - + + +/* + * 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 28029def9ff..6db99927fb1 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -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; @@ -517,6 +526,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, +.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } /* Themes for badges */ @@ -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%; } 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/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 2a1b9ffd24b..11536240ee0 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -36,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 { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 04ae5d298c4..04fe7e85d77 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -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 */ @@ -2620,7 +2632,6 @@ span.tabspan { margin-top: px; } - .paddingrightonly { border-collapse: collapse; border: 0px; @@ -2633,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; @@ -2838,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 dee2168136c..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.=' : '; @@ -220,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 4289fab99dc..c95b092cf2e 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -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 65682fef2b3..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.=' : '; @@ -211,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 a80d455e43f..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.=' : '; @@ -176,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 be29b1be25e..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) { @@ -288,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 7b4341cf684..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.=' : '; 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/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 1e0a15bac06..79c5d65b246 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); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 63abb02fd2e..6702953878c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -227,6 +227,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 * @@ -279,7 +285,7 @@ class User extends CommonObject $sql.= " u.socialnetworks,"; $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,"; @@ -392,7 +398,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; @@ -972,22 +980,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; @@ -1240,7 +1248,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; @@ -1525,7 +1534,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; @@ -1581,7 +1591,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"); @@ -2485,48 +2496,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); } @@ -2710,7 +2704,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->socialnetworks = array( @@ -2957,7 +2952,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 04a0f4c3883..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); 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 ''.$langs->trans("Permissions").''; 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 ''.$perm_libelle. ''; print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index a89fe447aa0..dc990497808 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -37,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'); 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 3b334871c06..31e5c5382de 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -42,8 +42,8 @@ $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'userlist // 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 @@ -677,7 +677,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['u.statut']['checked'])) { $userstatic->statut=$obj->statut; - print ''.$userstatic->getLibStatut(3).''; + print ''.$userstatic->getLibStatut(5).''; if (! $i) $totalarray['nbfield']++; } // Action column 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 577af6c04ba..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; 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/combinations.php b/htdocs/variants/combinations.php index a87959e76fb..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 '
'; diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 6bec619269a..27f811fdafe 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -159,7 +159,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); dol_fiche_end(); } diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 904266e281b..123578fb5ab 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -198,7 +198,7 @@ if (! empty($hashp)) else { // Basic protection (against external users only) - if ($user->societe_id > 0) + if ($user->socid > 0) { if ($sqlprotectagainstexternals) { @@ -210,7 +210,7 @@ else while ($i < $num) { $obj = $db->fetch_object($resql); - if ($user->societe_id != $obj->fk_soc) + if ($user->socid != $obj->fk_soc) { $accessallowed=0; break; diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index f2fed8f1bca..b66b0db4bcd 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -518,10 +518,10 @@ function createProductOrService($authentication, $product) $newobject->ref=$product['ref']; $newobject->ref_ext=$product['ref_ext']; $newobject->type=$product['type']; - $newobject->libelle=$product['label']; // @deprecated $newobject->label=$product['label']; $newobject->description=$product['description']; - $newobject->note=$product['note']; + $newobject->note_public=$product['note_public']; + $newobject->note_private=$product['note_private']; $newobject->status=$product['status_tosell']; $newobject->status_buy=$product['status_tobuy']; $newobject->price=$product['price_net']; @@ -692,7 +692,6 @@ function updateProductOrService($authentication, $product) if (isset($product['ref'])) $newobject->ref=$product['ref']; if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext']; $newobject->type=$product['type']; - $newobject->libelle=$product['label']; // @deprecated $newobject->label=$product['label']; $newobject->description=$product['description']; $newobject->note=$product['note']; diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 1873a8a9f5c..d738bca19f3 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -290,8 +290,8 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') 'date_modification'=>dol_print_date($invoice->tms, 'dayhourrfc'), 'date_invoice'=>dol_print_date($invoice->date, 'dayhourrfc'), 'date_term'=>dol_print_date($invoice->date_echeance, 'dayhourrfc'), - 'label'=>$invoice->libelle, - 'paid'=>$invoice->paye, + 'label'=>$invoice->label, + 'paid'=>$invoice->paid, 'note_private'=>$invoice->note_private, 'note_public'=>$invoice->note_public, 'close_code'=>$invoice->close_code, @@ -422,8 +422,8 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) 'date_modification'=>dol_print_date($invoice->tms, 'dayhourrfc'), 'date_invoice'=>dol_print_date($invoice->date, 'dayhourrfc'), 'date_term'=>dol_print_date($invoice->date_echeance, 'dayhourrfc'), - 'label'=>$invoice->libelle, - 'paid'=>$invoice->paye, + 'label'=>$invoice->label, + 'paid'=>$invoice->paid, 'note_private'=>$invoice->note_private, 'note_public'=>$invoice->note_public, 'close_code'=>$invoice->close_code, diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 509115d48d6..8f06153a34e 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -359,7 +359,7 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') 'pass_indatabase_crypted' => $user->pass_indatabase_crypted, 'datec' => dol_print_date($user->datec, 'dayhourrfc'), 'datem' => dol_print_date($user->datem, 'dayhourrfc'), - 'fk_thirdparty' => $user->societe_id, + 'fk_thirdparty' => $user->socid, 'fk_contact' => $user->contact_id, 'fk_member' => $user->fk_member, 'datelastlogin' => dol_print_date($user->datelastlogin, 'dayhourrfc'), diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index bd54b93438f..d84b5232773 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -92,6 +92,17 @@ class Website extends CommonObject */ public $virtualhost; + /** + * List of containers + * + * @var array + */ + public $lines; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + /** * Constructor @@ -229,10 +240,10 @@ class Website extends CommonObject $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE t.entity IN ('.getEntity('website').')'; - if (null !== $ref) { + if (! empty($ref)) { $sql .= " AND t.ref = '" . $this->db->escape($ref) . "'"; } else { - $sql .= ' AND t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . (int) $id; } $resql = $this->db->query($sql); @@ -691,8 +702,8 @@ class Website extends CommonObject $companylink = ''; $label = '' . $langs->trans("WebSite") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Nom') . ': ' . $this->ref; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; $linkstart = 'labelStatus) || empty($this->labelStatusShort)) { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) - { - 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 ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 4) - { - 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 ($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'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); } + + $statusType = 'status5'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 870e300e650..0258198ba10 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -47,7 +47,7 @@ class WebsitePage extends CommonObject /** * @var string String with name of icon for websitepage. Must be the part after the 'object_' into object_myobject.png */ - public $picto = 'label'; + public $picto = 'file-code'; /** * @var int ID @@ -88,6 +88,11 @@ class WebsitePage extends CommonObject public $date_modification; + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + + + // BEGIN MODULEBUILDER PROPERTIES /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. @@ -480,25 +485,39 @@ class WebsitePage extends CommonObject global $menumanager; $result = ''; - $companylink = ''; $label = '' . $langs->trans("Page") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('ID') . ': ' . $this->id.'
'; + $label.= '' . $langs->trans('Title') . ': ' . $this->title; - $linkstart = '
fk_website.'&pageid='.$this->id; + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; $linkend=''; - $linkstart = $linkend = ''; + //$linkstart = $linkend = ''; + + $result .= $linkstart; + if ($withpicto) $result.=img_picto(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; - if ($withpicto) - { - $result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; - } - $result.= $linkstart . $this->ref . $linkend; return $result; } @@ -526,36 +545,20 @@ class WebsitePage extends CommonObject // phpcs:enable global $langs; - if ($mode == 0) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } - elseif ($mode == 2) - { - 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 ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } - elseif ($mode == 4) - { - 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 ($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'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); } + + $statusType = 'status5'; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 56b3a0c8cb3..e0e3378bf26 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -46,6 +46,7 @@ if (! $user->rights->website->read) accessforbidden(); $conf->dol_hide_leftmenu = 1; // Force hide of left menu. $error=0; +$websiteid=GETPOST('websiteid', 'int'); $websitekey=GETPOST('website', 'alpha'); $page=GETPOST('page', 'alpha'); $pageid=GETPOST('pageid', 'int'); @@ -101,7 +102,7 @@ $objectpage=new WebsitePage($db); $object->fetchAll(); // Init $object->records with list of websites // If website not defined, we take first found -if (empty($websitekey)) +if (! ($websiteid > 0) && empty($websitekey)) { foreach($object->records as $key => $valwebsite) { @@ -109,10 +110,12 @@ if (empty($websitekey)) break; } } -if ($websitekey) +if ($websiteid > 0 || $websitekey) { - $res = $object->fetch(0, $websitekey); + $res = $object->fetch($websiteid, $websitekey); + $websitekey = $object->ref; } + $website = $object; // Check pageid received as aprameter @@ -418,7 +421,7 @@ if ($action == 'addcontainer') $db->begin(); $objectpage->fk_website = $object->id; - if (GETPOST('fetchexternalurl', 'alpha')) + if (GETPOSTISSET('fetchexternalurl')) { $urltograb=GETPOST('externalurl', 'alpha'); $grabimages=GETPOST('grabimages', 'alpha'); @@ -426,12 +429,18 @@ if ($action == 'addcontainer') //var_dump($grabimages);exit; } - if ($urltograb) + if (GETPOSTISSET('fetchexternalurl')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - //if (! preg_match('/^http/', $urltograb) && ! preg_match('/^file/', $urltograb)) - if (! preg_match('/^http/', $urltograb)) + if (empty($urltograb)) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); + $action = 'createcontainer'; + } + elseif (! preg_match('/^http/', $urltograb)) { $error++; $langs->load("errors"); @@ -1372,6 +1381,8 @@ if ($action == 'updatemeta') $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); + $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); + $newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); if ($newdatecreation) $objectpage->date_creation = $newdatecreation; @@ -2006,6 +2017,7 @@ if (! GETPOST('hide_websitemenu')) if ($object->id > 0) { $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); + $object->lines = $array; } if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); @@ -2019,13 +2031,13 @@ if (! GETPOST('hide_websitemenu')) print ''; - if (! $atleastonepage) + if ($atleastonepage) { - print ''; + print ''; } else { - print ''; + print ''; } //print ''; @@ -2137,55 +2149,11 @@ if (! GETPOST('hide_websitemenu')) print ''; print ''; - print ''; + //print ''; if ($action != 'addcontainer') { - $out=''; - if ($atleastonepage && $action != 'editsource') - { - $out.=''; - } - if ($atleastonepage) - { - if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one - { - $firstpageid=0;$homepageid=0; - foreach($array as $key => $valpage) - { - if (empty($firstpageid)) $firstpageid=$valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; - } - $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page - } - - foreach($array as $key => $valpage) - { - $out.=''; - } - } - else $out.=''; - $out.=''; - if ($atleastonepage && $action != 'editsource') - { - $out.=ajax_combobox('pageid'); - } - else - { - $out.=''; - $out.=ajax_combobox('pageid'); - } - print $out; + print $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action); } else { @@ -2298,7 +2266,7 @@ if (! GETPOST('hide_websitemenu')) print ''."\n"; print '
'; - print '
'; + print ''; - print '
'; + print ''; @@ -2405,7 +2373,7 @@ if (! GETPOST('hide_websitemenu')) } } - print ''; // end website selection + //print ''; // end website selection print ''; @@ -2888,12 +2856,24 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''."\n"; //print '
'; + $hiddenfromfetchingafterload = ' hideobject'; + $hiddenmanuallyafterload = ' hideobject'; + if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') $hiddenfromfetchingafterload = ''; + if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; + + if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case + $hiddenfromfetchingafterload=''; + $hiddenmanuallyafterload=''; + } + if ($action == 'createcontainer') { print '
'; - print ' * '.$langs->trans("CreateByFetchingExternalPage").'

'; - print ''; + if (! empty($conf->use_javascript_ajax)) print ' '; + print '
'; + print '
'; + print '
'; 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;
'; print $langs->trans("URL"); print ''; @@ -2911,10 +2891,12 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '
'; - print ' * '.$langs->trans("OrEnterPageInfoManually").'

'; + if (! empty($conf->use_javascript_ajax)) print ' '; + print '
'; + print '
'; } - print ''; + print '
'; if ($action != 'createcontainer') { @@ -2928,16 +2910,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') print $langs->trans('InternalURLOfPage'); print ''; - /* - print ''; - */ - $type_container=$objectpage->type_container; $pageurl=$objectpage->pageurl; $pagealiasalt=$objectpage->aliasalt; @@ -2972,7 +2947,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; // Alias @@ -3023,26 +2998,14 @@ if ($action == 'editmeta' || $action == 'createcontainer') print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); print ''; + // Translation of + $translationof=0; + $translatedby=0; + print ''; - } - // Has translation pages $sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; $resql = $db->query($sql); @@ -3051,23 +3014,37 @@ if ($action == 'editmeta' || $action == 'createcontainer') $num_rows = $db->num_rows($resql); if ($num_rows > 0) { - print ''; } } else dol_print_error($db); } + if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) + { + $sourcepage=new WebsitePage($db); + $result = $sourcepage->fetch($objectpage->fk_page); + if ($result == 0) + { + // not found, we can reset value to clean database + } + elseif ($result > 0) + { + $translationof = $sourcepage->id; + print ''.$langs->trans('ThisPageIsTranslationOf').' '; + print $formwebsite->selectContainer($website, 'pageidfortranslation', $sourcepage->id, 1, $action); + } + } + print ''; print '
'; print '/public/website/index.php?website='.urlencode($websitekey).'&pageid='.urlencode($pageid); + //if ($objectpage->grabbed_from) print ' - '.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.''; print '
'; - print $langs->trans('InitiallyGrabbedFrom'); - print ''; - print $objectpage->grabbed_from; - print '
'; print $langs->trans('WEBSITE_TITLE'); print ''; - print ''; + print ''; print '
'; + print $langs->trans('TranslationLinks'); + print ''; if ($action != 'createcontainer') { - // Translation of - if ($objectpage->fk_page > 0) - { - print '
'; - print $langs->trans('ThisPageIsTranslationOf'); - print ''; - $sourcepage=new WebsitePage($db); - $result = $sourcepage->fetch($objectpage->fk_page); - if ($result == 0) // not found, we can reset value - { - } - elseif ($result > 0) - { - print $sourcepage->getNomUrl(1); - } - print '
'; - print $langs->trans('ThisPageHasTranslationPages'); - print ''; + print ''.$langs->trans('ThisPageHasTranslationPages').':
'; $i=0; while ($obj = $db->fetch_object($resql)) { $tmppage=new WebsitePage($db); $tmppage->fetch($obj->rowid); if ($i > 0) print ' - '; - print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')
'; + $translatedby++; $i++; } - print '
'; $htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc"); @@ -3127,7 +3104,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '
'; if ($action == 'createcontainer') { - print '
'; + print '
'; print ''; print ''; @@ -3155,6 +3132,20 @@ if ($action == 'editmeta' || $action == 'createcontainer') jQuery("#WEBSITE_PAGENAME").keyup(function() { disableautofillofalias = 1; }); + + jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").change(function() { + console.log("we select a method to create a new container"+jQuery("#checkboxcreatefromfetching:checked").val()) + if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') + { + jQuery(".tablecheckboxcreatefromfetching").show(); + jQuery(".tablecheckboxcreatemanually").hide(); + } + if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') + { + jQuery(".tablecheckboxcreatefromfetching").hide(); + jQuery(".tablecheckboxcreatemanually").show(); + } + }); }); '; } @@ -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 '
'.$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 '