diff --git a/.travis.yml b/.travis.yml index 8e1aa2aa10b8de06633fba03b9040b02851b4bd2..718356e8075a54a213ac4211dbfcaf8f3bdd059d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -257,7 +257,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/codesniffer/ruleset.xml --encoding=utf-8 . + phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . set +e echo diff --git a/ChangeLog b/ChangeLog index 2a952c56e6fd3c11dc5192379b2edbd619c6ee03..750e5c035ab289c771ddb466c82509ee5482c160 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,9 +26,9 @@ check you make a fetch on object before calling the delete. - The old driver of "mysql" has been removed. Dolibarr use the new one (mysqli) by default. - Remove not used function calculate_byte(). Use dol_print_size() instead. - Function pdf_getTotalQty is now deprecated. Not used by Dolibarr core. -- Method expensereport->delete(id, user) has been replaced with delete(user) to follow good practice to - make a fetch on object before deleting it. - +- Method expensereport->delete(id, user) has been replaced with ->delete(user) + Method warehouse->delete(id) has been replace with ->delete(user) + This is to follow good practice to make a fetch on object before deleting it. ***** ChangeLog for 4.0.0 compared to 3.9.* ***** diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2f7228eb9d4177e6514f291e110183d7b1e86397..63f9918488490516027d8491d5a58d2a34f3a4c2 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/admin/account.php - * \ingroup Advanced accountancy + * \ingroup Advanced accountancy * \brief List accounting account */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 057e2f0484c09227c930952c30d8097fe0dfa501..6ce8bb5fad0f6946c013f3af364f38154d6b979d 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/admin/card.php - * \ingroup Advanced accountancy + * \ingroup Advanced accountancy * \brief Card of accounting account */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index f9fb603e48326f77417035ee71853588fd6f8d3a..5b767208987c5785877b754ce8db33d8ba413e0b 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -16,12 +16,12 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear.php - * \ingroup fiscal year - * \brief Setup page to configure fiscal year + * \file htdocs/accountancy/admin/fiscalyear.php + * \ingroup Advanced accountancy + * \brief Setup page to configure fiscal year */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; @@ -45,9 +45,9 @@ $langs->load("compta"); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) - accessforbidden(); - +if (! $user->rights->mouvements->lire) // If we can read accounting records, we shoul be able to see fiscal year. + accessforbidden(); + $error = 0; // List of status @@ -65,6 +65,7 @@ $errors = array (); $object = new Fiscalyear($db); + /* * Actions */ @@ -146,7 +147,14 @@ dol_fiche_end(); // Buttons print '<div class="tabsAction">'; -print '<a class="butAction" href="fiscalyear_card.php?action=create">' . $langs->trans("NewFiscalYear") . '</a>'; +if (! empty($user->rights->accounting->fiscalyear)) +{ + print '<a class="butAction" href="fiscalyear_card.php?action=create">' . $langs->trans("NewFiscalYear") . '</a>'; +} +else +{ + print '<a class="butActionRefused" href="#">' . $langs->trans("NewFiscalYear") . '</a>'; +} print '</div>'; llxFooter(); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index ec0f19d9d07a4d177b6c96f5ebaf87ef32378034..7c5c6d08c731c46f8c71646f60bd7ef27b2b36d5 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -16,8 +16,9 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_card.php + * \ingroup Advanced accountancy + * \brief Page to show a fiscal year */ require '../../main.inc.php'; @@ -30,7 +31,7 @@ $langs->load("compta"); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) +if (empty($user->rights->accounting->fiscalyear)) accessforbidden(); $error = 0; @@ -138,9 +139,12 @@ else if ($action == 'update') { } } + + /* * View */ + $title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); $helpurl = ""; llxHeader("",$title,$helpurl); @@ -291,16 +295,19 @@ if ($action == 'create') dol_fiche_end(); - /* - * Barre d'actions - */ - print '<div class="tabsAction">'; - - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>'; - - print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>'; - - print '</div>'; + if (! empty($user->rights->accounting->fiscalyear)) + { + /* + * Barre d'actions + */ + print '<div class="tabsAction">'; + + print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>'; + + print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>'; + + print '</div>'; + } } } else { dol_print_error($db); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 612e4d7f759db7ca0819b91dacc23c3c35fe0468..3596d73d7511a939aa5713a8562564b368fc4419 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -16,11 +16,12 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show info of a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_info.php + * \ingroup Advanced accountancy + * \brief Page to show info of a fiscal year */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0d863e064d42b73b79ad68ee3f23d66430410f7d..7b8aa12dca26be6092c25f2176e69cc512de0c94 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -55,12 +55,17 @@ class BookKeeping extends CommonObject */ public $table_element = 'accounting_bookkeeping'; + + public $entity = 1; + + /** * * @var BookKeepingLine[] Lines */ public $lines = array (); + /** * * @var int ID @@ -212,7 +217,6 @@ class BookKeeping extends CommonObject } $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; - $sql .= "doc_date"; $sql .= ", doc_type"; $sql .= ", doc_ref"; @@ -229,9 +233,8 @@ class BookKeeping extends CommonObject $sql .= ", import_key"; $sql .= ", code_journal"; $sql .= ", piece_num"; - + $sql .= ', entity'; $sql .= ") VALUES ("; - $sql .= "'" . $this->doc_date . "'"; $sql .= ",'" . $this->doc_type . "'"; $sql .= ",'" . $this->doc_ref . "'"; @@ -248,7 +251,7 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->date_create . "'"; $sql .= ",'" . $this->code_journal . "'"; $sql .= "," . $this->piece_num; - + $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); @@ -391,10 +394,9 @@ class BookKeeping extends CommonObject $sql .= 'fk_user_author,'; $sql .= 'import_key,'; $sql .= 'code_journal,'; - $sql .= 'piece_num'; - + $sql .= 'piece_num,'; + $sql .= 'entity'; $sql .= ') VALUES ('; - $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ','; $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; @@ -410,8 +412,8 @@ class BookKeeping extends CommonObject $sql .= ' ' . $user->id . ','; $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; - $sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num); - + $sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num).','; + $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; $this->db->begin(); @@ -481,10 +483,14 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } $resql = $this->db->query($sql); @@ -586,13 +592,17 @@ class BookKeeping extends CommonObject } } + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } - // Affichage par compte comptable - $sql .= ' ORDER BY t.numero_compte ASC'; + // Affichage par compte comptable + $sql .= ' ORDER BY t.numero_compte ASC'; if (! empty($sortfield)) { - $sql .= ', ' . $sortfield . ' ' .$sortorder; + $sql .= ', ' . $sortfield . ' ' .$sortorder; } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); @@ -696,8 +706,12 @@ class BookKeeping extends CommonObject } } + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } if (! empty($sortfield)) { diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 9294cf7f6a8cd1e26ce617b59a25a04dfab92adc..f94ec8a2b0f7f58aad5b29d8475cea5c2b83c8f1 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -41,6 +41,9 @@ class FormVentilation extends Form $options = array(); $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= ' ORDER BY import_key DESC'; dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG); @@ -227,6 +230,9 @@ class FormVentilation extends Form // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + } $sql .= " ORDER BY code_compta"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -246,6 +252,9 @@ class FormVentilation extends Form // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + } $sql .= " ORDER BY code_compta_fournisseur"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -280,10 +289,15 @@ class FormVentilation extends Form */ function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { + global $conf; + $out_array = array(); $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= " ORDER BY date_format(doc_date,'%Y')"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -316,10 +330,15 @@ class FormVentilation extends Form */ function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html') { + global $conf; + $out_array = array(); $sql = "SELECT DISTINCT code_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= " ORDER BY code_journal"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4df2c68243a5cd45f74cd2cd1507d68dc0726743..18a18720569ebe898ce066a3376572e84764d3ea 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -171,9 +171,9 @@ print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td width="60" align="center">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; + print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; } -print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>'; +print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; @@ -220,9 +220,9 @@ print "<br>\n"; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td width="60" align="center">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; + print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; } -print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>'; +print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; for($i = 1; $i <= 12; $i ++) { @@ -264,9 +264,9 @@ if (! empty($conf->margin->enabled)) { print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td width="60" align="center">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; + print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; } - print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>'; + print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; for($i = 1; $i <= 12; $i ++) { @@ -291,9 +291,9 @@ if (! empty($conf->margin->enabled)) { print '<tr><td>' . $row[0] . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td align="right">' . price($row[$i]) . '</td>'; + print '<td align="right">' . price(price2num($row[$i])) . '</td>'; } - print '<td align="right"><b>' . price($row[13]) . '</b></td>'; + print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>'; print '</tr>'; } $db->free($resql); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c0a596891404119b37344b87cd558a00e4489c09..31e4ea7ccff0dc640e88c6884a037ca2fa3ab16c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -87,6 +87,11 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); + +/* + * Actions + */ + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { @@ -148,10 +153,6 @@ print '<script type="text/javascript"> }); </script>'; -/* - * Action - */ - /* * Customer Invoice lines */ @@ -251,7 +252,7 @@ if ($result) { print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print $formventilation->select_account($account_parent, 'account_parent', 1); - print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '"/></div>'; + print '<input type="submit" class="button" value="' . $langs->trans("Validate") . '"/></div>'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); @@ -298,7 +299,7 @@ if ($result) { // Ref Product $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; - $product_static->type = $objp->type; + $product_static->type = $objp->product_type; print '<td>'; if ($product_static->id) print $product_static->getNomUrl(1); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 0c1a4d1eb6b39d3c0764d2364ea05f67b47ba5a9..7d2326b05e5936475456f643c79671891a0957fe 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -103,9 +103,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_vat = ''; } + + /* * View */ + llxHeader('', $langs->trans("Ventilation")); print '<script type="text/javascript"> diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 9dd5bd1e1d74b6472c2211abc37e5a49a2a3f1ea..674edd94e8674437b6eaceec4226b88b8d7ec524 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -155,9 +155,9 @@ print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="200" align="left">' . $langs->trans("Account") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td width="60" align="center">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; + print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; } -print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>'; +print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; @@ -205,9 +205,9 @@ print "<br>\n"; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>'; for($i = 1; $i <= 12; $i ++) { - print '<td width="60" align="center">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; + print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; } -print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>'; +print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; for($i = 1; $i <= 12; $i ++) { @@ -247,4 +247,4 @@ if ($resql) { print "</table>\n"; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index a0b2365350f676e73c8309633dedf585bffdf78d..18b1c4b6b74bbf1a2f4d986d081b6721c8e77c82 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -85,6 +85,11 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); + +/* + * Actions + */ + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { @@ -121,6 +126,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { } } + /* * View */ @@ -198,7 +204,7 @@ if ($result) { print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); - print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '" /></div>'; + print '<input type="submit" class="button" value="' . $langs->trans("Validate") . '" /></div>'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 346c80ee9936b572d219cdd9d3e602f4d4678b50..c46c1ee09042422c1a63462202c4cf4727bfa261 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -93,6 +93,7 @@ $sql.= " b.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql.= " WHERE d.rowid = c.fk_adherent"; +$sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; if (isset($date_select) && $date_select != '') { $sql.= " AND c.dateadh LIKE '".$date_select."%'"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index eae25599075358d275a68957605f8d2e064a0a2c..9713983d45a588bb6d96265d987269c9944d8246 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -80,7 +80,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0); // Name of SQL tables of dictionaries $tabname=array(); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 113d12570cb284ca35182e7069d80e7adb532d38..85e46b32333ca44c7a738034746e109250767ac7 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -75,10 +75,28 @@ if ($search_version) $param.='&search_version='.urlencode($search_version); * Actions */ + +if (GETPOST('buttonreset')) +{ + $search_keyword=''; + $search_status=''; + $search_nature=''; + $search_version=''; +} + if ($action == 'set' && $user->admin) { - $result=activateModule($value); - if ($result) setEventMessages($result, null, 'errors'); + $resarray = activateModule($value); + if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); + else + { + //var_dump($resarray);exit; + if ($resarray['nbperms'] > 0) + { + $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); + setEventMessages($msg, null, 'warnings'); + } + } header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -91,14 +109,6 @@ if ($action == 'reset' && $user->admin) exit; } -if (GETPOST('buttonreset')) -{ - $search_keyword=''; - $search_status=''; - $search_nature=''; - $search_version=''; -} - /* @@ -494,8 +504,8 @@ if ($mode != 'marketplace') // Help print '<td align="center" valign="top" class="nowrap" style="width: 82px;">'; $text=''; - if ($objMod->getDescLong()) $text.=$objMod->getDesc().'<br>'.$objMod->getDescLong().'<br>'; - else $text.=$objMod->getDesc().'<br>'; + if ($objMod->getDescLong()) $text.='<div class="titre">'.$objMod->getDesc().'</div><br>'.$objMod->getDescLong().'<br>'; + else $text.='<div class="titre">'.$objMod->getDesc().'</div><br>'; $textexternal=''; if ($objMod->isCoreOrExternalModule() == 'external') @@ -605,7 +615,7 @@ if ($mode != 'marketplace') else $text.=$langs->trans("No"); $text.='<br><strong>'.$langs->trans("AddMenus").':</strong> '; - if (isset($objMod->menu) && is_array($objMod->menu) && ! empty($objMod->menu)) + if (isset($objMod->menu) && ! empty($objMod->menu)) // objMod can be an array or just an int 1 { $text.=$langs->trans("Yes"); } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 6fa692f47fce5291ac108e8c5ef89e3fcc5f32ca..540cd4a4b984e253963bae4fdb8f0b731129afa0 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -136,19 +136,23 @@ else if ($action == 'del') // Set default model else if ($action == 'setdoc') { - if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; - } + if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} +else if ($action == 'unsetdoc') +{ + dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); } if ($action == 'setmod') @@ -366,7 +370,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle))!==false) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); @@ -383,7 +387,7 @@ foreach ($dirmodels as $reldir) require_once $dir.$file; $module = new $classname($db,$specimenthirdparty); if (method_exists($module,'info')) print $module->info($langs); - else print $module->description; + else print $module->description; print "</td>\n"; @@ -391,16 +395,17 @@ foreach ($dirmodels as $reldir) if (in_array($name, $def)) { print '<td align="center">'."\n"; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") - { + //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; print img_picto($langs->trans("Enabled"),'switch_on'); print '</a>'; - } + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); - } + }*/ print "</td>"; } else @@ -414,7 +419,9 @@ foreach ($dirmodels as $reldir) print '<td align="center">'; if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") { - print img_picto($langs->trans("Default"),'on'); + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"),'on').'</a>'; } else { diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 6c13b61432ab51a666c25ff7b24b727a0fb93ebd..428c3fde2d8868a39db8f3ab378204cd3d14e7b0 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -82,13 +82,13 @@ $enableremotecheck = False; print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">'; print $langs->trans("MakeIntegrityAnalysisFrom").':<br>'; -if (file_exists($xmlfile)) +if (dol_is_file($xmlfile)) { print '<input type="checkbox" name="local" checked> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>'; } else { - print '<input type="checkbox" name="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("NotAvailable").')</span><br>'; + print '<input type="checkbox" name="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>'; } if ($enableremotecheck) { @@ -98,13 +98,13 @@ else { print '<input type="checkbox" name="remote" disabled> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureNotYetAvailable").')</span><br>'; } -print '<input type="submit" name="check" class="button" value="'.$langs->trans("Check").'">'; +print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>'; print '</form>'; print '<br>'; if (GETPOST('local')) { - if (file_exists($xmlfile)) + if (dol_is_file($xmlfile)) { $xml = simplexml_load_file($xmlfile); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 30a6d839ba8a36e51f19c24b07b9fde8e5981723..67a671a4bf9cdf43e0385914f8a67809a3239d1e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -183,7 +183,7 @@ if (empty($reshook)) // Remove a product line else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { - $result = $object->deleteline($lineid); + $result = $object->deleteline($user, $lineid); if ($result > 0) { // Define output language @@ -1919,9 +1919,9 @@ if ($action == 'create' && $user->rights->commande->creer) // Order card - + $linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; - + $morehtmlref='<div class="refidno">'; // Ref customer @@ -1962,17 +1962,17 @@ if ($action == 'create' && $user->rights->commande->creer) } } $morehtmlref.='</div>'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '<div class="fichecenter">'; print '<div class="fichehalfleft">'; print '<div class="underbanner clearboth"></div>'; - + print '<table class="border" width="100%">'; - + // Ref /* print '<tr><td class="titlefield">' . $langs->trans('Ref') . '</td>'; @@ -2309,7 +2309,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '</td></tr>'; } */ - + // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -2358,14 +2358,14 @@ if ($action == 'create' && $user->rights->commande->creer) include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '</table>'; - + print '</div>'; print '<div class="fichehalfright">'; print '<div class="ficheaddleft">'; print '<div class="underbanner clearboth"></div>'; - + print '<table class="border centpercent">'; - + // Total HT print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>'; print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>'; @@ -2408,19 +2408,19 @@ if ($action == 'create' && $user->rights->commande->creer) // Statut //print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>'; - + print '</table>'; - + // Margin Infos if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } - + print '</div>'; print '</div>'; print '</div>'; - + print '<div class="clearboth"></div><br>'; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { @@ -2634,7 +2634,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; diff --git a/htdocs/commande/class/api_deprecated_commande.class.php b/htdocs/commande/class/api_deprecated_commande.class.php index bc04ec5fe77bfa12b0bafbd7a8f9875a647b907b..06da6fa874a2e84622bbf7317d976f2d555e360e 100644 --- a/htdocs/commande/class/api_deprecated_commande.class.php +++ b/htdocs/commande/class/api_deprecated_commande.class.php @@ -23,19 +23,19 @@ * API class for commande object * * @smart-auto-routing false - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} - * + * * @category Api * @package Api - * + * * @deprecated Use Orders instead (defined in api_orders.class.php) */ class CommandeApi extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'socid' @@ -50,7 +50,7 @@ class CommandeApi extends DolibarrApi * Constructor <b>Warning: Deprecated</b> * * @url GET order/ - * + * */ function __construct() { @@ -63,40 +63,40 @@ class CommandeApi extends DolibarrApi * Get properties of a commande object <b>Warning: Deprecated</b> * * Return an array with commande informations - * + * * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object * @param string $ref_int Internal reference of other object * @return array|mixed data without useless information * - * @url GET order/{id} + * @url GET order/{id} * @throws RestException */ function get($id='',$ref='', $ref_ext='', $ref_int='') - { + { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $this->commande->fetchObjectLinked(); return $this->_cleanObjectDatas($this->commande); } /** * List orders <b>Warning: Deprecated</b> - * + * * Get a list of orders - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -109,20 +109,20 @@ class CommandeApi extends DolibarrApi */ function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $societe = 0) { global $db, $conf; - + $obj_ret = array(); // case of external user, $societe param is ignored and replaced by user's socid $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; - + // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT s.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."commande as s"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - + // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; @@ -131,13 +131,13 @@ class CommandeApi extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - + // Insert sale filter if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -157,7 +157,7 @@ class CommandeApi extends DolibarrApi } $result = $db->query($sql); - + if ($result) { $i=0; @@ -183,9 +183,9 @@ class CommandeApi extends DolibarrApi /** * List orders for specific thirdparty <b>Warning: Deprecated</b> - * + * * Get a list of orders - * + * * @param int $socid Id of customer * * @url GET /customer/{socid}/order/list @@ -196,14 +196,14 @@ class CommandeApi extends DolibarrApi return getList(0,"s.rowid","ASC",0,0,$socid); } - + /** * Create order object <b>Warning: Deprecated</b> * * @param array $request_data Request datas - * + * * @url POST order/ - * + * * @return int ID of commande */ function post($request_data = NULL) @@ -227,7 +227,7 @@ class CommandeApi extends DolibarrApi if(! $this->commande->create(DolibarrApiAccess::$user) ) { throw new RestException(500, "Error while creating order"); } - + return $this->commande->id; } /** @@ -235,21 +235,21 @@ class CommandeApi extends DolibarrApi * * * @param int $id Id of order - * + * * @url GET order/{id}/line/list - * - * @return int + * + * @return int */ function getLines($id) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -265,22 +265,22 @@ class CommandeApi extends DolibarrApi * * * @param int $id Id of commande to update - * @param array $request_data Orderline data - * + * @param array $request_data Orderline data + * * @url POST order/{id}/line - * - * @return int + * + * @return int */ function postLine($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -325,22 +325,22 @@ class CommandeApi extends DolibarrApi * * @param int $id Id of commande to update * @param int $lineid Id of line to update - * @param array $request_data Orderline data - * + * @param array $request_data Orderline data + * * @url PUT order/{id}/line/{lineid} - * - * @return object + * + * @return object */ function putLine($id, $lineid, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -382,26 +382,26 @@ class CommandeApi extends DolibarrApi * * @param int $id Id of commande to update * @param int $lineid Id of line to delete - * + * * @url DELETE order/{id}/line/{lineid} - * - * @return int + * + * @return int */ function delLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; - $updateRes = $this->commande->deleteline($lineid); + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid); if ($updateRes == 1) { return $this->get($id); } @@ -412,42 +412,42 @@ class CommandeApi extends DolibarrApi * Update order general fields (won't touch lines of order) <b>Warning: Deprecated</b> * * @param int $id Id of commande to update - * @param array $request_data Datas - * + * @param array $request_data Datas + * * @url PUT order/{id} - * - * @return int + * + * @return int */ function put($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { $this->commande->$field = $value; } - + if($this->commande->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); - + return false; } - + /** * Delete order <b>Warning: Deprecated</b> * * @param int $id Order ID - * + * * @url DELETE order/{id} - * + * * @return array */ function delete($id) @@ -459,35 +459,35 @@ class CommandeApi extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( ! $this->commande->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete order : '.$this->commande->error); } - + return array( 'success' => array( 'code' => 200, 'message' => 'Order deleted' ) ); - + } - + /** * Validate an order <b>Warning: Deprecated</b> - * + * * @param int $id Order ID * @param int $idwarehouse Warehouse ID - * + * * @url GET order/{id}/validate * @url POST order/{id}/validate - * + * * @return array - * + * */ function validOrder($id, $idwarehouse=0) { @@ -498,15 +498,15 @@ class CommandeApi extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( ! $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) { throw new RestException(500, 'Error when validate order'); } - + return array( 'success' => array( 'code' => 200, @@ -514,12 +514,12 @@ class CommandeApi extends DolibarrApi ) ); } - + /** * Validate fields before create or update object - * + * * @param array $data Array with data to verify - * @return array + * @return array * @throws RestException */ function _validate($data) @@ -529,7 +529,7 @@ class CommandeApi extends DolibarrApi if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $commande[$field] = $data[$field]; - + } return $commande; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 5e000165bed1f5884872996b2a9dd1d507ebde56..6ba66a7801372d352107e2bcd9028265806b2cc3 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -23,14 +23,14 @@ /** * API class for orders * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Orders extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'socid' @@ -55,36 +55,36 @@ class Orders extends DolibarrApi * Get properties of a commande object * * Return an array with commande informations - * + * * @param int $id ID of order * @return array|mixed data without useless information * * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $this->commande->fetchObjectLinked(); return $this->_cleanObjectDatas($this->commande); } /** * List orders - * + * * Get a list of orders - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -95,31 +95,31 @@ class Orders extends DolibarrApi */ function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '') { global $db, $conf; - + $obj_ret = array(); // case of external user, $thirdpartyid param is ignored and replaced by user's socid $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; - + // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT s.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."commande as s"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE s.entity IN ('.getEntity('commande', 1).')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ($socids) $sql.= " AND s.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - + // Insert sale filter if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -139,7 +139,7 @@ class Orders extends DolibarrApi } $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -190,7 +190,7 @@ class Orders extends DolibarrApi $errormsg = $this->commande->error; throw new RestException(500, $errormsg ? $errormsg : "Error while creating order"); } - + return $this->commande->id; } @@ -198,21 +198,21 @@ class Orders extends DolibarrApi * Get lines of an order * * @param int $id Id of order - * + * * @url GET {id}/lines - * - * @return int + * + * @return int */ function getLines($id) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -228,22 +228,22 @@ class Orders extends DolibarrApi * Add a line to given order * * @param int $id Id of commande to update - * @param array $request_data Orderline data - * + * @param array $request_data Orderline data + * * @url POST {id}/lines - * - * @return int + * + * @return int */ function postLine($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -288,22 +288,22 @@ class Orders extends DolibarrApi * * @param int $id Id of commande to update * @param int $lineid Id of line to update - * @param array $request_data Orderline data - * + * @param array $request_data Orderline data + * * @url PUT {id}/lines/{lineid} - * - * @return object + * + * @return object */ function putLine($id, $lineid, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -346,26 +346,26 @@ class Orders extends DolibarrApi * * @param int $id Id of commande to update * @param int $lineid Id of line to delete - * + * * @url DELETE {id}/lines/{lineid} - * - * @return int + * + * @return int */ function delLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; - $updateRes = $this->commande->deleteline($lineid); + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid); if ($updateRes == 1) { return $this->get($id); } @@ -376,38 +376,38 @@ class Orders extends DolibarrApi * Update order general fields (won't touch lines of order) * * @param int $id Id of commande to update - * @param array $request_data Datas - * - * @return int + * @param array $request_data Datas + * + * @return int */ function put($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - + $result = $this->commande->fetch($id); if( ! $result ) { throw new RestException(404, 'Commande not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { $this->commande->$field = $value; } - + if($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) return $this->get($id); - + return false; } - + /** * Delete order * * @param int $id Order ID - * + * * @return array */ function delete($id) @@ -419,33 +419,33 @@ class Orders extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( ! $this->commande->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete order : '.$this->commande->error); } - + return array( 'success' => array( 'code' => 200, 'message' => 'Order deleted' ) ); - + } - + /** * Validate an order - * + * * @param int $id Order ID * @param int $idwarehouse Warehouse ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * * @url POST {id}/validate - * + * * @return array * FIXME An error 403 is returned if the request has an empty body. * Error message: "Forbidden: Content type `text/plain` is not supported." @@ -464,11 +464,11 @@ class Orders extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Order not found'); } - + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); if ($result == 0) { throw new RestException(500, 'Error nothing done. May be object is already validated'); @@ -476,7 +476,7 @@ class Orders extends DolibarrApi if ($result < 0) { throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } - + return array( 'success' => array( 'code' => 200, @@ -484,12 +484,12 @@ class Orders extends DolibarrApi ) ); } - + /** * Validate fields before create or update object - * + * * @param array $data Array with data to verify - * @return array + * @return array * @throws RestException */ function _validate($data) @@ -499,7 +499,7 @@ class Orders extends DolibarrApi if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $commande[$field] = $data[$field]; - + } return $commande; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 894f58f930efdc046593cbf8d23a78ca8aecb2cc..224fa892a87a5231634111efce0fe33f934ec589 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -48,7 +48,7 @@ class Commande extends CommonOrder public $fk_element = 'fk_commande'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'order'; - + /** * {@inheritdoc} */ @@ -810,11 +810,11 @@ class Commande extends CommonOrder for ($i=0;$i<$num;$i++) { $line = $this->lines[$i]; - + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; - + // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; @@ -906,10 +906,10 @@ class Commande extends CommonOrder } } } - + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; - + $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { @@ -1220,7 +1220,7 @@ class Commande extends CommonOrder */ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) { - global $mysoc, $conf, $langs; + global $mysoc, $conf, $langs, $user; dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG); @@ -1373,7 +1373,7 @@ class Commande extends CommonOrder $this->line->array_options=$array_options; } - $result=$this->line->insert(); + $result=$this->line->insert($user); if ($result > 0) { // Reorder if child line @@ -1972,10 +1972,11 @@ class Commande extends CommonOrder /** * Delete an order line * + * @param User $user User object * @param int $lineid Id of line to delete * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - function deleteline($lineid) + function deleteline($user=null, $lineid=0) { if ($this->statut == self::STATUS_DRAFT) @@ -2002,7 +2003,7 @@ class Commande extends CommonOrder // For triggers $line->fetch($lineid); - if ($line->delete() > 0) + if ($line->delete($user) > 0) { $result=$this->update_price(1); @@ -2387,7 +2388,7 @@ class Commande extends CommonOrder function availability($availability_id, $notrigger=0) { global $user; - + dol_syslog('Commande::availability('.$availability_id.')'); if ($this->statut >= self::STATUS_DRAFT) { @@ -2457,7 +2458,7 @@ class Commande extends CommonOrder function demand_reason($demand_reason_id, $notrigger=0) { global $user; - + dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); if ($this->statut >= self::STATUS_DRAFT) { @@ -2740,7 +2741,7 @@ class Commande extends CommonOrder */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null) { - global $conf, $mysoc, $langs; + global $conf, $mysoc, $langs, $user; dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2885,7 +2886,7 @@ class Commande extends CommonOrder $this->line->array_options=$array_options; } - $result=$this->line->update(); + $result=$this->line->update($user); if ($result > 0) { // Reorder if child line @@ -3805,9 +3806,11 @@ class OrderLine extends CommonOrderLine /** * Delete line in database * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 si ko, >0 si ok */ - function delete() + function delete($user=null, $notrigger=0) { global $conf, $user, $langs; @@ -3833,10 +3836,13 @@ class OrderLine extends CommonOrderLine } } - // Call trigger - $result=$this->call_trigger('LINEORDER_DELETE',$user); - if ($result < 0) $error++; - // End call triggers + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEORDER_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } if (!$error) { $this->db->commit(); @@ -3861,12 +3867,13 @@ class OrderLine extends CommonOrderLine /** * Insert line into database * + * @param User $user User that modify * @param int $notrigger 1 = disable triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger=0) + function insert($user=null, $notrigger=0) { - global $langs, $conf, $user; + global $langs, $conf; $error=0; @@ -4004,12 +4011,13 @@ class OrderLine extends CommonOrderLine /** * Update the line object into db * + * @param User $user User that modify * @param int $notrigger 1 = disable triggers * @return int <0 si ko, >0 si ok */ - function update($notrigger=0) + function update($user=null, $notrigger=0) { - global $conf,$langs,$user; + global $conf,$langs; $error=0; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 9fe184d99baf1da097b8e92996e4920819cf6f80..0c0eed067833080a66661fd2cd82b760380033d3 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2884,8 +2884,7 @@ else if ($id > 0 || ! empty($ref)) // Invoice content $linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; - - + $morehtmlref='<div class="refidno">'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index ab797571c70dced9dcaaf640bc712eb6ef58787d..007c8040d0d205975cf4898b09d108d23280748a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -440,14 +440,14 @@ class FactureRec extends CommonInvoice /** * Delete template invoice * - * @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice + * @param User $user User that delete. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete($rowid=0, $notrigger=0, $idwarehouse=-1) + function delete($user, $notrigger=0, $idwarehouse=-1) { - if (empty($rowid)) $rowid=$this->id; + $rowid=$this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 8ed4f7241ef00a24e0da01c546a33544a5d6acbc..fd9f9e0fc13e898c2c966170841945093a772d5d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> + * Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr> * * 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 @@ -185,19 +186,19 @@ if ($action == 'add') // Get first contract linked to invoice used to generate template if ($id > 0) { - $srcObject = new Facture($db); - $srcObject->fetch(GETPOST('facid','int')); - - $srcObject->fetchObjectLinked(); - - if (! empty($srcObject->linkedObjectsIds['contrat'])) - { - $contractidid = reset($srcObject->linkedObjectsIds['contrat']); - - $object->origin = 'contrat'; - $object->origin_id = $contractidid; - $object->linked_objects[$object->origin] = $object->origin_id; - } + $srcObject = new Facture($db); + $srcObject->fetch(GETPOST('facid','int')); + + $srcObject->fetchObjectLinked(); + + if (! empty($srcObject->linkedObjectsIds['contrat'])) + { + $contractidid = reset($srcObject->linkedObjectsIds['contrat']); + + $object->origin = 'contrat'; + $object->origin_id = $contractidid; + $object->linked_objects[$object->origin] = $object->origin_id; + } } $db->begin(); @@ -211,16 +212,16 @@ if ($action == 'add') $result=$oldinvoice->delete($user, 1); if ($result < 0) { - $error++; - setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); + $action = "create"; } } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } if (! $error) @@ -232,9 +233,9 @@ if ($action == 'add') } else { - $db->rollback(); - - $error++; + $db->rollback(); + + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; } @@ -242,9 +243,9 @@ if ($action == 'add') } // Delete -if ($action == 'delete' && $user->rights->facture->supprimer) +if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { - $object->delete($user); + $object->delete(); header("Location: " . $_SERVER['PHP_SELF'] ); exit; } @@ -280,7 +281,7 @@ elseif ($action == 'setref' && $user->rights->facture->creer) // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) @@ -307,344 +308,362 @@ elseif ($action == 'setauto_validate' && $user->rights->facture->creer) // Delete line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $db->begin(); - - $line=new FactureLigneRec($db); - - // For triggers - $line->id = $lineid; - - if ($line->delete() > 0) - { - $result=$object->update_price(1); - - if ($result > 0) - { - $db->commit(); - $object->fetch($object->id); // Reload lines - } - else - { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - } - else - { - $db->rollback(); - setEventMessages($line->error, $line->errors, 'errors'); - } + $db->begin(); + + $line=new FactureLigneRec($db); + + // For triggers + $line->id = $lineid; + + if ($line->delete() > 0) + { + $result=$object->update_price(1); + + if ($result > 0) + { + $db->commit(); + $object->fetch($object->id); // Reload lines + } + else + { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + } + else + { + $db->rollback(); + setEventMessages($line->error, $line->errors, 'errors'); + } } // Add a new line if ($action == 'addline' && $user->rights->facture->creer) { - $langs->load('errors'); - $error = 0; - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); - } - } + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); - $error ++; - } - if ($qty < 0) { - $langs->load("errors"); - setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; - } + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key . $predef]); + } + } + + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); + $error ++; + } + if ($qty < 0) { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); + $error ++; + } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); - if ($ret < 0) { - dol_print_error($db, $object->error); - exit(); - } - $ret = $object->fetch_thirdparty(); + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) + { + $ret = $object->fetch($id); + if ($ret < 0) { + dol_print_error($db, $object->error); + exit(); + } + $ret = $object->fetch_thirdparty(); + + // Clean parameters + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + // Define special_code for special lines + $special_code = 0; + // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + // Replaces $fk_unit with the product's + if (! empty($idprod)) + { + $prod = new Product($db); + $prod->fetch($idprod); - // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - // Define special_code for special lines - $special_code = 0; - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - // Replaces $fk_unit with the product's - if (! empty($idprod)) - { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; - - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - - // We define price for product - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) - { - $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; - $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; - if (empty($tva_tx)) $tva_npr=0; - } - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - } - } - } + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); + if (empty($tva_tx)) $tva_npr=0; - // if price ht was forced (ie: from gui when calculated by margin rate and cost price) - if (! empty($price_ht)) - { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } + // We define price for product + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + { + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (empty($tva_tx)) $tva_npr=0; + } + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } + $prodcustprice = new Productcustomerprice($db); - $type = $prod->type; - $fk_unit = $prod->fk_unit; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); - } - - // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - if ($result > 0) - { - /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - }*/ - $object->fetch($object->id); // Reload lines - - unset($_POST['prod_entry_mode']); - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprod']); - unset($_POST['units']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - - unset($_POST['situations']); - unset($_POST['progress']); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + } + } + } - $action = ''; - } + // if price ht was forced (ie: from gui when calculated by margin rate and cost price) + if (! empty($price_ht)) + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) + { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + + } + + $type = $prod->type; + $fk_unit = $prod->fk_unit; + + } + else + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + if (empty($tva_tx)) $tva_npr=0; + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + $fk_unit= GETPOST('units', 'alpha'); + } + + // Margin + $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) + { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessages($mesg, null, 'errors'); + } + else + { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + + if ($result > 0) + { + /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + }*/ + $object->fetch($object->id); // Reload lines + + unset($_POST['prod_entry_mode']); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + unset($_POST['units']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + + unset($_POST['situations']); + unset($_POST['progress']); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + + $action = ''; + } } } elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { - if (! $object->fetch($id) > 0) dol_print_error($db); - $object->fetch_thirdparty(); - - // Clean parameters - $date_start = ''; - $date_end = ''; - //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); - $pu_ht = GETPOST('price_ht'); - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - $qty = GETPOST('qty'); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) + if (! $object->fetch($id) > 0) dol_print_error($db); + $object->fetch_thirdparty(); + + // Clean parameters + $date_start = ''; + $date_end = ''; + //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $qty = GETPOST('qty'); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; // Define vat_rate @@ -661,10 +680,12 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield - if (is_array($extralabelsline)) { + if (is_array($extralabelsline)) + { // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_" . $key]); } } @@ -688,13 +709,13 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $productid = GETPOST('productid', 'int'); if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); + $product = new Product($db); + $product->fetch($productid); - $type = $product->type; + $type = $product->type; - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); @@ -721,12 +742,29 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' } // Update line - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, - $vat_rate, GETPOST('productid'), GETPOST('remise_percent'), 'HT', $info_bits, 0, 0, $type, - 0, $special_code, $label, GETPOST('units')); - - if ($result >= 0) { + if (! $error) + { + $result = $object->updateline( + GETPOST('lineid'), + $description, + $pu_ht, + $qty, + $vat_rate, + GETPOST('productid'), + GETPOST('remise_percent'), + 'HT', + $info_bits, + 0, + 0, + $type, + 0, + $special_code, + $label, + GETPOST('units') + ); + + if ($result >= 0) + { /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -744,47 +782,49 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ - $object->fetch($object->id); // Reload lines - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - - unset($_POST['dp_desc']); - unset($_POST['idprod']); - unset($_POST['units']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - - unset($_POST['situations']); - unset($_POST['progress']); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $object->fetch($object->id); // Reload lines + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + + unset($_POST['dp_desc']); + unset($_POST['idprod']); + unset($_POST['units']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + + unset($_POST['situations']); + unset($_POST['progress']); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Do we click on purge search criteria ? @@ -837,7 +877,7 @@ if ($action == 'create') { $result = $object->getLinesArray(); - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="facid" value="'.$object->id.'">'; @@ -885,15 +925,15 @@ if ($action == 'create') print "</td></tr>"; // Project - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) - { - $projectid = $object->fk_project; - $langs->load('projects'); - print '<tr><td>' . $langs->trans('Project') . '</td><td>'; - $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>'; - print '</td></tr>'; - } + if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) + { + $projectid = $object->fk_project; + $langs->load('projects'); + print '<tr><td>' . $langs->trans('Project') . '</td><td>'; + $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); + print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>'; + print '</td></tr>'; + } // Bank account if ($object->fk_account > 0) @@ -932,8 +972,8 @@ if ($action == 'create') // Auto validate the invoice print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>"; - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); - print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); + $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); + print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print "</td></tr>"; print "</table>"; @@ -999,11 +1039,16 @@ else $object->fetch_thirdparty(); // Confirmation de la suppression d'une ligne produit - if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); - } + if ($action == 'ask_deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); + } + + // Confirm delete of repeatable invoice + if ($action == 'ask_deleteinvoice') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + } - print $formconfirm; + print $formconfirm; $author = new User($db); $author->fetch($object->user_author); @@ -1056,9 +1101,12 @@ else print '</td><td colspan="3">'; if ($object->type != Facture::TYPE_CREDIT_NOTE) { - if ($action == 'editconditions') { + if ($action == 'editconditions') + { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } else { + } + else + { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); } } else { @@ -1102,7 +1150,8 @@ else print '</tr>'; // Project - if (! empty($conf->projet->enabled)) { + if (! empty($conf->projet->enabled)) + { $langs->load('projects'); print '<tr>'; print '<td>'; @@ -1171,25 +1220,25 @@ else if ($action == 'editfrequency') { print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">'; - print '<input type="hidden" name="action" value="setfrequency">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; - print '<tr><td>'; - print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); - print '</td>'; - print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; - print '</tr></table></form>'; + print '<input type="hidden" name="action" value="setfrequency">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; + print '<tr><td>'; + print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); + print '</td>'; + print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; + print '</tr></table></form>'; } else { - if ($object->frequency > 0) - { - print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); - } - else - { - print $langs->trans("NotARecurringInvoiceTemplate"); - } + if ($object->frequency > 0) + { + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); + } + else + { + print $langs->trans("NotARecurringInvoiceTemplate"); + } } print '</td></tr>'; @@ -1240,7 +1289,7 @@ else else print $langs->trans("StatusOfGeneratedInvoices"); print '</td><td colspan="5">'; - $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) { print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); @@ -1253,12 +1302,12 @@ else print '<br>'; // Frequencry/Recurring section - if ($object->frequency > 0) + if ($object->frequency > 0) + { + if (empty($conf->cron->enabled)) { - if (empty($conf->cron->enabled)) - { - print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); - } + print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); + } print '<table class="border" width="100%">'; @@ -1332,34 +1381,34 @@ else //if ($object->statut == Facture::STATUS_DRAFT) // there is no draft status on templates. //{ - if ($user->rights->facture->creer) - { - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) - { - print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; - } - else - { - if (empty($object->frequency) || $object->date_when <= $today) - { - print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>'; - } - else - { - print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>'; - } - } - } - else - { - print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateBill").'</a></div>'; - } + if ($user->rights->facture->creer) + { + if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) + { + print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; + } + else + { + if (empty($object->frequency) || $object->date_when <= $today) + { + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>'; + } + else + { + print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>'; + } + } + } + else + { + print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateBill").'</a></div>'; + } //} //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) if ($user->rights->facture->supprimer) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>'; } print '</div>'; @@ -1375,7 +1424,7 @@ else $somethingshown = $form->showLinkedObjectBlock($object, ''); - print '</div></div>'; + print '</div></div>'; } else @@ -1416,8 +1465,8 @@ else $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'"; else if ($year_date_when > 0 && ! empty($day_date_when)) $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'"; - else - $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; + else + $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; } else if ($year_date_when > 0) { @@ -1425,14 +1474,14 @@ else } $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); + $sql.= $db->order($sortfield, $sortorder); + $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); if ($resql) @@ -1440,7 +1489,7 @@ else $num = $db->num_rows($resql); $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 83da8f68e75b8ef406eb20dfb05a6e7515eaeafb..70e4cc03974380ae5dd1abb8eff671f6507a7b84 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -70,6 +70,7 @@ $userid=GETPOST('userid','int'); $search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_refcustomer=GETPOST('search_refcustomer','alpha'); +$search_type=GETPOST('search_type','int'); $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_montant_vat=GETPOST('search_montant_vat','alpha'); @@ -142,6 +143,7 @@ $checkedtypetiers=0; $arrayfields=array( 'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), + 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0), 'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1), 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -191,6 +193,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS $search_product_category=''; $search_ref=''; $search_refcustomer=''; + $search_type=''; $search_project=''; $search_societe=''; $search_montant_ht=''; @@ -295,6 +298,15 @@ if ($filtre) } if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref); if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); +if ($search_type != '' && $search_type >= 0) +{ + if ($search_type == '0') $sql.=" AND f.type = 0"; // standard + if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement + if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note + if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit + if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma + if ($search_type == '5') $sql.=" AND f.type = 5"; // situation +} if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_town) $sql.= natural_search('s.town', $search_town); @@ -310,7 +322,7 @@ if ($search_status != '' && $search_status >= 0) { if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed - if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some correupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) + if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; @@ -400,7 +412,7 @@ if ($resql) $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - + if ($socid) { $soc = new Societe($db); @@ -419,6 +431,7 @@ if ($resql) if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer); + if ($search_type != '') $param.='&search_type='.urlencode($search_type); if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); @@ -438,7 +451,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + $arrayofmassactions=array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge") @@ -457,7 +470,7 @@ if ($resql) } if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + $i = 0; print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -467,7 +480,7 @@ if ($resql) print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; - + print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); if ($massaction == 'presend') @@ -496,7 +509,7 @@ if ($resql) print '<input type="hidden" name="massaction" value="confirm_presend">'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + $formmail = new FormMail($db); dol_fiche_head(null, '', ''); @@ -615,12 +628,13 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; - + print '<tr class="liste_titre">'; if (! empty($arrayfields['f.facnumber']['checked'])) print_liste_field_titre($arrayfields['f.facnumber']['label'],$_SERVER['PHP_SELF'],'f.facnumber','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'],$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'],$_SERVER["PHP_SELF"],'f.type','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'],$_SERVER['PHP_SELF'],'f.datef','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder); @@ -673,6 +687,20 @@ if ($resql) print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">'; print '</td>'; } + // Type + if (! empty($arrayfields['f.type']['checked'])) + { + print '<td class="liste_titre maxwidthonsmartphone">'; + $listtype=array( + Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + ); + //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. + print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); + print '</td>'; + } // Date invoice if (! empty($arrayfields['f.date']['checked'])) { @@ -719,7 +747,7 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); print '</td>'; } // Payment mode @@ -830,6 +858,7 @@ if ($resql) $facturestatic->type=$obj->type; $facturestatic->statut=$obj->fk_statut; $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); + $facturestatic->type=$obj->type; print '<tr '.$bc[$var].'>'; if (! empty($arrayfields['f.facnumber']['checked'])) @@ -865,7 +894,7 @@ if ($resql) print "</td>\n"; if (! $i) $totalarray['nbfield']++; } - + // Customer ref if (! empty($arrayfields['f.ref_client']['checked'])) { @@ -874,7 +903,16 @@ if ($resql) print '</td>'; if (! $i) $totalarray['nbfield']++; } - + + // Type + if (! empty($arrayfields['f.type']['checked'])) + { + print '<td class="nowrap">'; + print $facturestatic->getLibType(); + print "</td>"; + if (! $i) $totalarray['nbfield']++; + } + // Date if (! empty($arrayfields['f.date']['checked'])) { @@ -883,7 +921,7 @@ if ($resql) print '</td>'; if (! $i) $totalarray['nbfield']++; } - + // Date limit if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { @@ -895,7 +933,7 @@ if ($resql) print '</td>'; if (! $i) $totalarray['nbfield']++; } - + // Third party if (! empty($arrayfields['s.nom']['checked'])) { @@ -949,7 +987,7 @@ if ($resql) print '</td>'; if (! $i) $totalarray['nbfield']++; } - + // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { @@ -958,7 +996,7 @@ if ($resql) print '</td>'; if (! $i) $totalarray['nbfield']++; } - + // Amount HT if (! empty($arrayfields['f.total_ht']['checked'])) { @@ -999,7 +1037,7 @@ if ($resql) if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; $totalarray['totalrtp'] += $remaintopay; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 08eb5c001defd05d01ec48942a1d2573c0c7c705..d00525796c08d991f5d43f26edb1dbf3dc9959dc 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -27,8 +27,10 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; @@ -63,6 +65,10 @@ if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accountin // Date range $year=GETPOST("year"); $month=GETPOST("month"); +$search_societe = GETPOST("search_societe"); +$search_zip = GETPOST("search_zip"); +$search_town = GETPOST("search_town"); +$search_country = GETPOST("search_country"); $date_startyear = GETPOST("date_startyear"); $date_startmonth = GETPOST("date_startmonth"); $date_startday = GETPOST("date_startday"); @@ -130,6 +136,10 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; +$tableparams['search_societe'] = $search_societe; +$tableparams['search_zip'] = $search_zip; +$tableparams['search_town'] = $search_town; +$tableparams['search_country'] = $search_country; $tableparams['subcat'] = ($subcat === true)?'yes':''; // Adding common parameters @@ -182,7 +192,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl // Show Array $catotal=0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,"; + $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,"; $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) // Without any category @@ -218,7 +228,7 @@ if ($modecompta == 'CREANCES-DETTES') { * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ - $sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc"; + $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -248,9 +258,13 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } } +if(!empty($search_societe)) $sql.= ' AND s.nom LIKE "%'.$search_societe.'%"'; +if(!empty($search_zip)) $sql.= ' AND s.zip LIKE "%'.$search_zip.'%"'; +if(!empty($search_town)) $sql.= ' AND s.town LIKE "%'.$search_town.'%"'; +if($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.''; $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; -$sql.= " GROUP BY s.rowid, s.nom"; +$sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; $sql.= " ORDER BY s.rowid"; //echo $sql; @@ -264,6 +278,9 @@ if ($result) { $amount_ht[$obj->socid] = $obj->amount; $amount[$obj->socid] = $obj->amount_ttc; $name[$obj->socid] = $obj->name.' '.$obj->firstname; + $address_zip[$obj->socid] = $obj->zip; + $address_town[$obj->socid] = $obj->town; + $address_pays[$obj->socid] = getCountry($obj->fk_pays); $catotal_ht+=$obj->amount; $catotal+=$obj->amount_ttc; $i++; @@ -296,6 +313,9 @@ if ($modecompta != 'CREANCES-DETTES') { $obj = $db->fetch_object($result); $amount[$obj->rowid] += $obj->amount_ttc; $name[$obj->rowid] = $obj->name; + $address_zip[$obj->rowid] = $obj->zip; + $address_town[$obj->rowid] = $obj->town; + $address_pays[$obj->rowid] = getCountry($obj->fk_pays); $catotal+=$obj->amount_ttc; $i++; } @@ -325,7 +345,7 @@ if ($subcat) { print ' checked'; } print'></td>'; -print '<td colspan="4" align="right">'; +print '<td colspan="7" align="right">'; print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '</td>'; print '</tr>'; @@ -340,6 +360,33 @@ print_liste_field_titre( "", $sortfield,$sortorder ); +print_liste_field_titre( + $langs->trans("Zip"), + $_SERVER["PHP_SELF"], + "zip", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Town"), + $_SERVER["PHP_SELF"], + "town", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Country"), + $_SERVER["PHP_SELF"], + "country", + "", + $paramslink, + "", + $sortfield,$sortorder + ); if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre( $langs->trans('AmountHT'), @@ -383,6 +430,27 @@ print_liste_field_titre( 'align="center" width="20%"' ); print "</tr>\n"; + +print '<tr class="liste_titre">'; +print '<td class="liste_titre" align="left">'; +print '<input class="flat" size="6" type="text" name="search_societe" value="'.$search_societe.'">'; +print '</td>'; +print '<td class="liste_titre" align="left">'; +print '<input class="flat" size="6" type="text" name="search_zip" value="'.$search_zip.'">'; +print '</td>'; +print '<td class="liste_titre" align="left">'; +print '<input class="flat" size="6" type="text" name="search_town" value="'.$search_town.'">'; +print '</td>'; +print '<td class="liste_titre" align="left">'; +print $form->select_country($search_country, 'search_country'); +//print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">'; +print '</td>'; +print '<td> </td>'; +print '<td> </td>'; +print '<td> </td>'; +print '<td> </td>'; +print '</tr>'; + $var=true; if (count($amount)) { @@ -412,6 +480,30 @@ if (count($amount)) { arsort($amount); $arrayforsort=$amount; } + if ($sortfield == 'zip' && $sortorder == 'asc') { + asort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'zip' && $sortorder == 'desc') { + arsort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'town' && $sortorder == 'asc') { + asort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'town' && $sortorder == 'desc') { + arsort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'asc') { + asort($address_pays); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'desc') { + arsort($address_pays); + $arrayforsort=$address_town; + } foreach($arrayforsort as $key=>$value) { $var=!$var; @@ -429,6 +521,18 @@ if (count($amount)) { } print "<td>".$linkname."</td>\n"; + print '<td>'; + print $address_zip[$key]; + print '</td>'; + + print '<td>'; + print $address_town[$key]; + print '</td>'; + + print '<td>'; + print $address_pays[$key]; + print '</td>'; + // Amount w/o VAT print '<td align="right">'; if ($modecompta != 'CREANCES-DETTES') { @@ -488,6 +592,9 @@ if (count($amount)) { // Total print '<tr class="liste_total">'; print '<td>'.$langs->trans("Total").'</td>'; + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; if ($modecompta != 'CREANCES-DETTES') { print '<td colspan="1"></td>'; } else { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7c68a5ff978303a42cb84d6c72f94869768d42a8..c08d645cf534fcdb85f434cdd7a5b27519038c17 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -198,9 +198,9 @@ abstract class CommonInvoice extends CommonObject } /** - * Retourne le libelle du type de facture + * Return label of type of invoice * - * @return string Libelle + * @return string Label of type of invoice */ function getLibType() { @@ -209,7 +209,7 @@ abstract class CommonInvoice extends CommonObject if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); + if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 4bcd34baa8a889fbcb1453acf895c0a4063002b4..134de6018a537cda3e75fe40a2a75895af3d6717 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -708,7 +708,7 @@ function purgeSessions($mysessionid) * * @param string $value Name of module to activate * @param int $withdeps Activate/Disable also all dependencies - * @return string Error message or ''; + * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); */ function activateModule($value,$withdeps=1) { @@ -717,7 +717,7 @@ function activateModule($value,$withdeps=1) // Check parameters if (empty($value)) return 'ErrorBadParameter'; - $ret=''; + $ret=array('nbmodules'=>0, 'errors'=>array(), 'nbperms'=>0); $modName = $value; $modFile = $modName . ".class.php"; @@ -761,50 +761,67 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); - if ($result <= 0) $ret=$objMod->error; - - if (! $ret && $withdeps) + if ($result <= 0) + { + $ret['errors'][]=$objMod->error; + } + else { - if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends)) + if ($withdeps) { - // Activation des modules dont le module depend - $TError=array(); - $num = count($objMod->depends); - for ($i = 0; $i < $num; $i++) + if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends)) { - $activate = false; - foreach ($modulesdir as $dir) - { - if (file_exists($dir.$objMod->depends[$i].".class.php")) - { - activateModule($objMod->depends[$i]); - $activate = true; - } - } - - if (!$activate) $TError[] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]); + // Activation des modules dont le module depend + $num = count($objMod->depends); + for ($i = 0; $i < $num; $i++) + { + $activate = false; + foreach ($modulesdir as $dir) + { + if (file_exists($dir.$objMod->depends[$i].".class.php")) + { + $resarray = activateModule($objMod->depends[$i]); + if (empty($resarray['errors'])) $activate = true; + break; + } + } + + if ($activate) + { + $ret['nbmodules']+=$resarray['nbmodules']; + $ret['nbperms']+=$resarray['nbperms']; + } + else + { + $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]); + } + } } - - setEventMessages('', $TError, 'errors'); - } - - if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) - { - // Desactivation des modules qui entrent en conflit - $num = count($objMod->conflictwith); - for ($i = 0; $i < $num; $i++) + + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { - foreach ($modulesdir as $dir) - { - if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) - { - unActivateModule($objMod->conflictwith[$i],0); - } - } + // Desactivation des modules qui entrent en conflit + $num = count($objMod->conflictwith); + for ($i = 0; $i < $num; $i++) + { + foreach ($modulesdir as $dir) + { + if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) + { + unActivateModule($objMod->conflictwith[$i],0); + } + } + } } } } + if (! count($ret['errors'])) + { + $ret['nbmodules']++; + $ret['nbperms']+=count($objMod->rights); + } + return $ret; } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 26a7455bf62d2983bba7c45d78219e1715908dfb..2e9a9d582bd5c928f163ac91b338795c3524235c 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -62,7 +62,7 @@ function user_prepare_head($object) if ($canreadperms) { $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; - $head[$h][1] = $langs->trans("UserRights"); + $head[$h][1] = $langs->trans("UserRights"). ' <span class="badge">'.($object->nb_rights).'</span>'; $head[$h][2] = 'rights'; $h++; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 7e1c378279ed7ebb4c4a3eb29ac53c13ec46b39a..495064f02dc5ed4a91febed1fb447f572648876c 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -44,7 +44,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 201__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/dolibarr.php?leftmenu=admintools', 'InfoDolibarr', 1, 'admin', '', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 202__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/system/modules.php?leftmenu=admintools', 'Modules', 2, 'admin', '', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 203__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/triggers.php?leftmenu=admintools', 'Triggers', 2, 'admin', '', '', 2, 3, __ENTITY__); ---insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 204__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/system/filecheck.php?leftmenu=admintools', 'FileCheck', 2, 'admin', '', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 204__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/system/filecheck.php?leftmenu=admintools', 'FileCheck', 2, 'admin', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 205__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/browser.php?leftmenu=admintools', 'InfoBrowser', 1, 'admin', '', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 206__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/os.php?leftmenu=admintools', 'InfoOS', 1, 'admin', '', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 207__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/web.php?leftmenu=admintools', 'InfoWebServer', 1, 'admin', '', '', 2, 3, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f16c2a1da7231d8407726c4feef84d2d5c207ad3..5fa1f56eb38bac044f4f063f094669ecfd08e86e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -551,7 +551,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1); if (empty($leftmenu) || $leftmenu=='admintools_info') $newmenu->add('/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2); if (empty($leftmenu) || $leftmenu=='admintools_info') $newmenu->add('/admin/triggers.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2); - //if (empty($leftmenu) || $leftmenu=='admintools_info') $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2); + if (empty($leftmenu) || $leftmenu=='admintools_info') $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2); $newmenu->add('/admin/system/browser.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1); $newmenu->add('/admin/system/os.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoOS'), 1); $newmenu->add('/admin/system/web.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoWebServer'), 1); @@ -941,14 +941,14 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Dispatch if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_customer'); - if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?leftmenu=accountancy_dispatch_customer",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); - if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/lines.php?leftmenu=accountancy_dispatch_customer",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); + if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); + if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); if (! empty($conf->supplier_invoice->enabled)) { if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy",$langs->trans("SuppliersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_supplier'); - if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/list.php?leftmenu=accountancy_dispatch_supplier",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); - if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/lines.php?leftmenu=accountancy_dispatch_supplier",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); + if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); + if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); } // Journals @@ -972,7 +972,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu while ($i < $numr) { $objp = $db->fetch_object($resql); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/bankjournal.php?left_menu=accountancy_journal&id_account='.$objp->rowid,$langs->trans("Journal").' - '.dol_trunc($objp->label,10),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/bankjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_account='.$objp->rowid,$langs->trans("Journal").' - '.dol_trunc($objp->label,10),2,$user->rights->accounting->comptarapport->lire); $i++; } } @@ -980,15 +980,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $db->free($resql); // Add other journal - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); } // General Ledger - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire); // Balance - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); // Reports $langs->load("compta"); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 6d6856ff36be8c0113238f04162b3f4847907f50..b8b194e5be60eacaadba61eb589d8ef1ed7a3df4 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1552,12 +1552,14 @@ class DolibarrModules // Can not be abstract, because we need to insta /** * Adds menu entries * - * @return int Error count (0 if OK) + * @return int Error count (0 if OK) */ function insert_menus() { global $user; + if (! is_array($this->menu) || empty($this->menu)) return 0; + require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; $err=0; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 2d61e76d524584dc52bfb1c030808feb21372e8c..7420e3474827d93dbef80b2c09f3a7672a832085 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -892,14 +892,12 @@ class pdf_rouget extends ModelePdfExpedition $Yoff=25; // Add list of linked orders - // TODO possibility to use with other document (business module,...) - //$object->load_object_linked(); $origin = $object->origin; $origin_id = $object->origin_id; // TODO move to external function - if (! empty($conf->$origin->enabled)) + if (! empty($conf->$origin->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); @@ -908,6 +906,8 @@ class pdf_rouget extends ModelePdfExpedition $result=$linkedobject->fetch($origin_id); if ($result >= 0) { + //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects + $pdf->SetFont('','', $default_font_size - 2); $text=$linkedobject->ref; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 60d99438f4f48fdc255bbefed07ed4b3599f0721..af081130db4fef93e4344f0754f1de14936c5647 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -284,8 +284,10 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = ''; $r++; - // Main menu entries - $this->menus = array(); - $r = 0; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } } diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index bcf7c32b74efd9e614ffd0fc21f63f6f0da984fc..6b52490d3509dac533241ed2a218620992df2b4e 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -209,7 +209,7 @@ class modAdherent extends DolibarrModules $this->rights[$r][0] = 71; $this->rights[$r][1] = 'Read members\' card'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -244,7 +244,7 @@ class modAdherent extends DolibarrModules $this->rights[$r][0] = 78; $this->rights[$r][1] = 'Read subscriptions'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'cotisation'; $this->rights[$r][5] = 'lire'; @@ -256,6 +256,12 @@ class modAdherent extends DolibarrModules $this->rights[$r][4] = 'cotisation'; $this->rights[$r][5] = 'creer'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index a8775fd9b2d0be04907a0696c7c75362bb8d86c6..47e6fb43d5c493217a9e2dfb684cc7d51cf07fd8 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -118,7 +118,7 @@ class modAgenda extends DolibarrModules $this->rights[$r][0] = 2401; $this->rights[$r][1] = 'Read actions/tasks linked to his account'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'myactions'; $this->rights[$r][5] = 'read'; $r++; diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 8008590cce7fb38345b061bce8ea80a107f11b31..fc1821fde5398a40f008809b6913a204a1149fca 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -155,7 +155,7 @@ class modApi extends DolibarrModules // Example: // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $r++; diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 86c772fe4c8bc962893be036d7b223445fef2774..33ca523d00bfa6fcafb992d927a69e95adeaeb16 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -89,7 +89,7 @@ class modBanque extends DolibarrModules $this->rights[$r][0] = 111; // id de la permission $this->rights[$r][1] = 'Lire les comptes bancaires'; // libelle de la permission $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -135,7 +135,11 @@ class modBanque extends DolibarrModules $this->rights[$r][4] = 'cheque'; - + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 5614ceb53abc0f2887b9a34297323b1710ad74f6..8924be16ba4729e85ce6e44a2584691cb4c82a8c 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -81,22 +81,27 @@ class modBookmark extends DolibarrModules $this->rights[$r][0] = 331; // id de la permission $this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 332; // id de la permission $this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; $r++; $this->rights[$r][0] = 333; // id de la permission $this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par d�faut + $this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut $this->rights[$r][4] = 'supprimer'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } } diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 93c0f3016ed7ae5bb1981782401e212f821be843..ec8764c9017056fc0fe46290d36def3559840176 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -86,7 +86,7 @@ class modCashDesk extends DolibarrModules $this->rights[$r][0] = 50101; $this->rights[$r][1] = 'Use point of sale'; $this->rights[$r][2] = 'a'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'use'; // Main menu entries diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index fcc931a9ed265ab209205e38e1049a2a522821f5..edda1043d7151ce9c30a3c3fb196158a138b5704 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> * Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2012-2016 Juanjo Menent <jmenent@2byte.es> * * 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 @@ -89,7 +89,7 @@ class modCategorie extends DolibarrModules $this->rights[$r][0] = 241; // id de la permission $this->rights[$r][1] = 'Lire les categories'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecated) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -107,6 +107,12 @@ class modCategorie extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; @@ -136,11 +142,53 @@ class modCategorie extends DolibarrModules $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','s.fk_stcomm'=>'List:c_stcomm:libelle:code'); $this->export_entities_array[$r]=array('s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company",'s.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company'); // We define here only fields that use another picto $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object '; $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')'; $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories + // Add extra fields + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + case 'select': + $typeFilter="Select:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='company'; + } + } + // End add axtra fields + + + + + $r++; $this->export_code[$r]='category_'.$r; $this->export_label[$r]='CatProdList'; @@ -303,6 +351,7 @@ class modCategorie extends DolibarrModules $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')'; $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 2d3080f892a67b09e158fd7cec3ab757e9962922..ce792b683fe2fbd1fd30525a3dfc6ce0272dee1e 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -114,7 +114,7 @@ class modCommande extends DolibarrModules $this->rights[$r][0] = 81; $this->rights[$r][1] = 'Lire les commandes clients'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -170,6 +170,12 @@ class modCommande extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'export'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index ca49ab12f7dc3edc755f448c2235f237e9d54c4b..c07318fb36b1156cdc0f51b0c3a556f576260f1d 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -91,9 +91,15 @@ class modComptabilite extends DolibarrModules $this->rights[$r][0] = 95; $this->rights[$r][1] = 'Lire CA, bilans, resultats'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'resultat'; $this->rights[$r][5] = 'lire'; + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index d298c5aa182fc28592431edad973171fc41d6991..c4c8cd500fbb0e6e2c18151ea03c2d525ead5441 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -91,7 +91,7 @@ class modContrat extends DolibarrModules $this->rights[$r][0] = 161; $this->rights[$r][1] = 'Lire les contrats'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -130,6 +130,11 @@ class modContrat extends DolibarrModules $this->rights[$r][4] = 'export'; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $langs->load("contracts"); diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 49a857b3562f2bc1348bbe33a6a3209db0ee4fbe..282b835be66c2d199fb601cd358a9c5cc3803b58 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -108,7 +108,7 @@ class modCron extends DolibarrModules $this->rights[$r][0] = 23001; $this->rights[$r][1] = 'Read cron jobs'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $r++; diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 7a0760a603d0bf29aba468dfba294c6dce7fe4cd..ab4e7a0095f24f794c8f7ffda5dba49f1891d939 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -108,6 +108,12 @@ class modDeplacement extends DolibarrModules $this->rights[5][3] = 0; $this->rights[5][4] = 'export'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports $r=0; diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 909f1d5f5e88928dae8602aada826d657b757867..ec40c8b6dc52ff5e22ee4c45491f027f44cd8f4a 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -84,7 +84,7 @@ class modDocumentGeneration extends DolibarrModules $this->rights[$r][0] = 1521; $this->rights[$r][1] = 'Lire les documents'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index c62b46db06b58c9120921bd06a98f103e8ac450f..063c3b75b55f1d2e5af8ee1c0ba2c4f230c52b37 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -135,7 +135,12 @@ class modDon extends DolibarrModules $this->rights[3][2] = 'd'; $this->rights[3][3] = 0; $this->rights[3][4] = 'supprimer'; - + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 4e5cd3a3f623bc6839babd0f900816ea8bbf1bca..cb6544f4d295c0a7e0cc26d417c21f0afd98c00e 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -83,5 +83,6 @@ class modDynamicPrices extends DolibarrModules $this->rights = array(); $this->rights_class = 'dynamicprices'; $r=0; + } } diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 1aa5008032d8eeaa45d930d42b919801d43f408e..b263b16e29eb6b5729f0922f9ee0c2ef16bca904 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -101,21 +101,21 @@ class modECM extends DolibarrModules $this->rights[$r][0] = 2501; $this->rights[$r][1] = 'Consulter/Télécharger les documents'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $r++; $this->rights[$r][0] = 2503; $this->rights[$r][1] = 'Soumettre ou supprimer des documents'; $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'upload'; $r++; $this->rights[$r][0] = 2515; $this->rights[$r][1] = 'Administrer les rubriques de documents'; $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'setup'; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 8116186219dad45223aab124e1a0e6d468a406e0..d408d5e4375c3e6d4719e1774f9f0558989d0220 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -145,7 +145,7 @@ class modExpedition extends DolibarrModules $this->rights[$r][0] = 101; $this->rights[$r][1] = 'Lire les expeditions'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -190,7 +190,7 @@ class modExpedition extends DolibarrModules $this->rights[$r][0] = 1101; $this->rights[$r][1] = 'Lire les bons de livraison'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison'; $this->rights[$r][5] = 'lire'; @@ -218,6 +218,12 @@ class modExpedition extends DolibarrModules $this->rights[$r][4] = 'livraison'; $this->rights[$r][5] = 'supprimer'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 01110a66bf3a073a1e18f8165b5db1775bc8e132..36c921fc0d6e6a5714c2584c8b9afe6055a588af 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -193,6 +193,12 @@ class modExpenseReport extends DolibarrModules $this->rights[5][3] = 0; $this->rights[5][4] = 'export'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports $r=0; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index e8a6baa850983e508b20a6709a9e1c98bde79fcf..cc0090c2fc8a142ba6ebdbab6aed47f6299a05b7 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -81,7 +81,7 @@ class modExport extends DolibarrModules $this->rights[$r][0] = 1201; $this->rights[$r][1] = 'Lire les exports'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -90,5 +90,11 @@ class modExport extends DolibarrModules $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } } diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index e7388faaedf55a0bc3357da5a4b2f4eaa59039d4..f22d402b9795d601ff125483ac04e1776b5bca6a 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -97,7 +97,7 @@ class modFTP extends DolibarrModules $this->rights[$r][0] = 2801; $this->rights[$r][1] = 'Use FTP client in read mode (browse and download only)'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $r++; @@ -107,12 +107,9 @@ class modFTP extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; + // Menus - //------ - $this->menus = array(); // List of menus to add - $r=0; - - // Top menu + //------- $this->menu[$r]=array('fk_menu'=>0, 'type'=>'top', 'titre'=>'FTP', diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index d15215a4f99003c472213e180d669e0648b5a065..d1a90fbad17412ce5afa0312222cc90dbf03f013 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -126,7 +126,7 @@ class modFacture extends DolibarrModules $this->rights[$r][0] = 11; $this->rights[$r][1] = 'Lire les factures'; $this->rights[$r][2] = 'a'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -184,6 +184,11 @@ class modFacture extends DolibarrModules $this->rights[$r][5] = 'export'; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=1; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 4c4fcbcc6d85723feac46fc9ca534df9312b4d39..6a8441592308c792ced4dc772acdf030b6870ca3 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -99,7 +99,7 @@ class modFicheinter extends DolibarrModules $this->rights[$r][0] = 61; $this->rights[$r][1] = 'Lire les fiches d\'intervention'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; @@ -147,6 +147,12 @@ class modFicheinter extends DolibarrModules $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'unvalidate'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + //Exports //-------- $r=1; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 7d5d675228162dcb3c47b339963e008b027db127..29378667b6398b2bba40c0c52214da3cbce0d43e 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -129,14 +129,14 @@ class modFournisseur extends DolibarrModules $this->rights[$r][0] = 1181; $this->rights[$r][1] = 'Consulter les fournisseurs'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 1182; $this->rights[$r][1] = 'Consulter les commandes fournisseur'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'lire'; @@ -209,7 +209,7 @@ class modFournisseur extends DolibarrModules $this->rights[$r][0] = 1231; $this->rights[$r][1] = 'Consulter les factures fournisseur'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'facture'; $this->rights[$r][5] = 'lire'; @@ -272,7 +272,12 @@ class modFournisseur extends DolibarrModules $this->rights[$r][5] = 'approve2'; } - + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 241cca18dbbcead04aec9703bfc561a5b3e119dd..237778309c23ef5a8b393048684e51e1c83b4e04 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -114,7 +114,7 @@ class modGravatar extends DolibarrModules // Example: // $this->rights[$r][0] = 2000; // Permission id (must not be already used) // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $r++; diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index f370c78b25ecfe9b23648bc4a9497c779c51d0ca..5cbb282424a5544541246f1de36e089fceb55a39 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -99,21 +99,21 @@ class modHRM extends DolibarrModules $this->rights[$r][0] = 4001; $this->rights[$r][1] = 'See employees'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'read'; $r ++; $this->rights[$r][0] = 4002; $this->rights[$r][1] = 'Create employees'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'write'; $r ++; $this->rights[$r][0] = 4003; $this->rights[$r][1] = 'Delete employees'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'delete'; $r ++; @@ -125,9 +125,11 @@ class modHRM extends DolibarrModules $this->rights[$r][5] = 'export'; $r ++; - // Main menu entries - $this->menus = array (); // List of menus to add - $r = 0; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } /** diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 73b316ec1643cec585f427c5d29eabdd39eb6ac4..0dc44a36e22d75b3baf49349ebaaddd1442b64cb 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -133,14 +133,14 @@ class modHoliday extends DolibarrModules $this->rights[$r][0] = 20001; // Permission id (must not be already used) $this->rights[$r][1] = 'Read your own holidays'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20002; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; @@ -173,10 +173,11 @@ class modHoliday extends DolibarrModules $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; - // Main menu entries - $this->menus = array(); // List of menus to add - $r=0; - + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Exports $r=1; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 8f3faad9bd196d6cd1959d70569035caafa90a3d..2efebb58d800d8d38eb8de4c9c11bd83a8013ae2 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -85,5 +85,11 @@ class modImport extends DolibarrModules $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; + + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } } diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index b7e7f822bbc23ace1b483f4d2acc9a0bca5e2963..7e445a3dbce7f0e5895236f3c20c7edc72570e13 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -99,7 +99,7 @@ class modLoan extends DolibarrModules $this->rights[$r][0] = 520; $this->rights[$r][1] = 'Read loans'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $this->rights[$r][5] = ''; @@ -135,7 +135,12 @@ class modLoan extends DolibarrModules $this->rights[$r][4] = 'export'; $this->rights[$r][5] = ''; - + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 00ece509285c81f22ee161faec83da4b02d9faa6..45d2685abe44569a36e4f2a8540504f6814d5266 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -79,7 +79,7 @@ class modMailing extends DolibarrModules $this->rights[$r][0] = 221; // id de la permission $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -127,6 +127,10 @@ class modMailing extends DolibarrModules $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'delete'; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 2ebff38ef08fff6599694d2ce4f063e76f3ab4ef..3900c0549b94cdfa5d0eee22d8c993654d4f5173 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -76,5 +76,10 @@ class modMailmanSpip extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'clicktodial'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } } diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 300911c78777aaec10d54f54582ef63e91d0776b..a04c9ac567a0f017fc068ef557d600175de6e3f8 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -126,7 +126,7 @@ class modMargin extends DolibarrModules $this->rights[$r][0] = 59001; // id de la permission $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'liretous'; $r++; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 7ae613edd49388e80f57031013b77a982bb05b83..a4875dc16e2cff4314d3a41cef1332f0face06af 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -189,7 +189,7 @@ class modMultiCurrency extends DolibarrModules // Example: // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $r++; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index fe444960b531db8e9faeef31986dc7906bf498a0..4be01e561fe2fdfcde25e68a8eac168dc83432b0 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -97,7 +97,7 @@ class modOauth extends DolibarrModules $this->rights[$r][0] = 66000; $this->rights[$r][1] = 'OauthAccess'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read';*/ // Main menu entries diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index 02cf9138a1f26b18978bd357f09220a924a2d48c..ea10750ad7ccc043a6bf86adabaeccb908658bdc 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -119,23 +119,9 @@ class modOpenSurvey extends DolibarrModules $r++; - // Main menu entries - $this->menus = array(); // List of menus to add - $r=0; - /* - $this->menu[$r]=array( 'fk_menu'=>0, // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', - 'titre'=>'Surveys', - 'mainmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php', - 'langs'=>'opensurvey', - 'position'=>200, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++;*/ - + // Menus + //------- + $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', 'titre'=>'Survey', diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index d77d2dfc3f4dc3132c82ba9db2a3203e3659f16f..6cbdd5e2127906bb00b8c1c9822fb78153ca85df 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -106,7 +106,7 @@ class modPayBox extends DolibarrModules // Example: // $this->rights[$r][0] = 2000; // Permission id (must not be already used) // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][3] = 0; // Permission by default for new user (0/1) // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) // $r++; diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 75e8410e19e2734626bf312db6d342fff261f5ac..982cb95d208ff5a213ce23a08abb26c5dc2651d6 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -94,7 +94,7 @@ class modPrelevement extends DolibarrModules $this->rights[$r][0] = 151; $this->rights[$r][1] = 'Read withdrawals'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'bons'; $this->rights[$r][5] = 'lire'; @@ -129,6 +129,11 @@ class modPrelevement extends DolibarrModules $this->rights[2][4] = 'bons'; $this->rights[2][5] = 'configurer'; */ + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 4a228488947cecfca1546bc89c83292e210fd181..2ea807781b19578e442992d8b901558b160174ca 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -97,7 +97,7 @@ class modPrinting extends DolibarrModules $this->rights[$r][0] = 64001; $this->rights[$r][1] = 'DirectPrint'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; // Main menu entries diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 154639f848dd151c288310a6d78660eea08cf0c9..4ff68ae8d6bf03ea25c38e81ed7615150ba5ea83 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -99,7 +99,7 @@ class modProduct extends DolibarrModules $this->rights[$r][0] = 31; // id de la permission $this->rights[$r][1] = 'Lire les produits'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -124,6 +124,10 @@ class modProduct extends DolibarrModules $this->rights[$r][4] = 'export'; $r++; + // Menus + //------- + + $this->menu = 1; // This module add menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index ca0e282981937bf043947caa30e87930c62e7f57..9dbc8eb0212b1aaa1d946c0f1fd25aefdf6ef212 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -95,10 +95,12 @@ class modProductBatch extends DolibarrModules $this->rights = array(); // Permission array used by this module $r=0; - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; - + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports $r=0; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 2d71eaba5a1a22f4575dc7dec2622b35be2b284d..f26265c33faaf53f4306449e1e6bd2a7aa2f35cd 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -154,7 +154,7 @@ class modProjet extends DolibarrModules $this->rights[$r][0] = 41; // id de la permission $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)"; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -203,6 +203,11 @@ class modProjet extends DolibarrModules $this->rights[$r][5] = 'supprimer'; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + //Exports //-------- $r=1; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index e9fe448baf719c7567750b65ec24c71f13578d07..2ecf7d6960ccf57cc59ab65943011675002cceef 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -116,7 +116,7 @@ class modPropale extends DolibarrModules $this->rights[$r][0] = 21; // id de la permission $this->rights[$r][1] = 'Lire les propositions commerciales'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -163,6 +163,12 @@ class modPropale extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'export'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 121722125f2e9347c5f110913518716af26b66d4..f1520cf698f3c0ced3925abd5eaa8432c0b430f9 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -97,7 +97,7 @@ class modReceiptPrinter extends DolibarrModules $this->rights[$r][0] = 67000; $this->rights[$r][1] = 'ReceiptPrinter'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; // Main menu entries diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 83476270bc506ba7380a5fcf8d839c7f4766a96b..ee6162569b1008463d942477f9348245d15ba5b9 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -196,6 +196,11 @@ class modResource extends DolibarrModules $r++; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Add here list of permission defined by // an id, a label, a boolean and two constant strings. // Example: @@ -204,7 +209,7 @@ class modResource extends DolibarrModules //// Permission label //$this->rights[$r][1] = 'Permision label'; //// Permission by default for new user (0/1) - //$this->rights[$r][3] = 1; + //$this->rights[$r][3] = 0; //// In php code, permission will be checked by test //// if ($user->rights->permkey->level1->level2) //$this->rights[$r][4] = 'level1'; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index c9f460124435740cbeba9be0c5387a1fa829af7d..a1f4753b12da529369865fff5450a9c64b1b32f2 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -54,7 +54,7 @@ class modSalaries extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Employees salaries management"; + $this->description = "Employees contracts and salaries management"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; @@ -97,8 +97,8 @@ class modSalaries extends DolibarrModules $r=0; $r++; - $this->rights[$r][0] = 510; - $this->rights[$r][1] = 'Read salaries'; + $this->rights[$r][0] = 511; + $this->rights[$r][1] = 'Read employee contracts/salaries'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; @@ -106,15 +106,23 @@ class modSalaries extends DolibarrModules $r++; $this->rights[$r][0] = 512; - $this->rights[$r][1] = 'Create/modify salaries'; + $this->rights[$r][1] = 'Create/modify employee contracts/salaries'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $this->rights[$r][5] = ''; - + + $r++; + $this->rights[$r][0] = 513; + $this->rights[$r][1] = 'Create/modify payment of salaries'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $this->rights[$r][5] = ''; + $r++; $this->rights[$r][0] = 514; - $this->rights[$r][1] = 'Delete salaries'; + $this->rights[$r][1] = 'Delete contracts/salaries'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; @@ -122,13 +130,18 @@ class modSalaries extends DolibarrModules $r++; $this->rights[$r][0] = 517; - $this->rights[$r][1] = 'Export salaries'; + $this->rights[$r][1] = 'Export employee contracts and salaries payments'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; $this->rights[$r][5] = ''; + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 5ea2cfde96419f4186f5753781a9784f6791337e..7a5db7fcffdfd9eb4b93ba1257246e77eafee7ac 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -88,7 +88,7 @@ class modService extends DolibarrModules $this->rights[$r][0] = 531; // id de la permission $this->rights[$r][1] = 'Lire les services'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; @@ -130,7 +130,12 @@ class modService extends DolibarrModules */ - // Exports + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 4eac3c84c8ab6d76f51f4308cafc92838926f5f6..33e59acf4a2af9b3bb86bb52194bcb08241d4974 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -143,7 +143,7 @@ class modSociete extends DolibarrModules $this->rights[$r][0] = 121; // id de la permission $this->rights[$r][1] = 'Lire les societes'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; /* $r++; @@ -206,7 +206,7 @@ class modSociete extends DolibarrModules $this->rights[$r][0] = 262; $this->rights[$r][1] = 'Consulter tous les tiers par utilisateurs internes (sinon uniquement si contact commercial). Non effectif pour utilisateurs externes (tjs limités à eux-meme).'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'client'; $this->rights[$r][5] = 'voir'; @@ -214,7 +214,7 @@ class modSociete extends DolibarrModules $this->rights[$r][0] = 281; // id de la permission $this->rights[$r][1] = 'Lire les contacts'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'contact'; $this->rights[$r][5] = 'lire'; @@ -242,7 +242,12 @@ class modSociete extends DolibarrModules $this->rights[$r][4] = 'contact'; $this->rights[$r][5] = 'export'; - + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 778eb39e82706b2bd67f4289663d4a6fb853b7b7..b2c2f806bd707479b964753b59f83f1711f824f7 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -117,6 +117,12 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 842146597a39ec55a258788cb511b52b8fb3f4a5..f17b27415dac7dda7562acc81bc69c52d12f0871 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -102,13 +102,13 @@ class modSupplierProposal extends DolibarrModules $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; $r++; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index 293384b49a841abdf48ffbb542750c9f577341bf..bb8f31e466dd9fbf7cc9054af0c14a4eea244891 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -88,7 +88,7 @@ class modTax extends DolibarrModules $this->rights[$r][0] = 91; $this->rights[$r][1] = 'Lire les charges'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'charges'; $this->rights[$r][5] = 'lire'; @@ -117,6 +117,12 @@ class modTax extends DolibarrModules $this->rights[$r][5] = 'export'; + // Menus + //------- + + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 759b68555b79b2600028e9ed423dc26f540e029b..f481cdffb8e9cbc58495cb6beadcd7b5918d7771 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -134,7 +134,7 @@ class modUser extends DolibarrModules $this->rights[$r][0] = 341; $this->rights[$r][1] = 'Consulter ses propres permissions'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'readperms'; @@ -142,7 +142,7 @@ class modUser extends DolibarrModules $this->rights[$r][0] = 342; $this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur'; $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'self'; $this->rights[$r][5] = 'creer'; @@ -150,7 +150,7 @@ class modUser extends DolibarrModules $this->rights[$r][0] = 343; $this->rights[$r][1] = 'Modifier son propre mot de passe'; $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'self'; $this->rights[$r][5] = 'password'; @@ -158,7 +158,7 @@ class modUser extends DolibarrModules $this->rights[$r][0] = 344; $this->rights[$r][1] = 'Modifier ses propres permissions'; $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'writeperms'; @@ -202,6 +202,13 @@ class modUser extends DolibarrModules $this->rights[$r][4] = 'user'; $this->rights[$r][5] = 'export'; + + // Menus + //------- + + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index a510e569b60062e803fd47375ccb1ccf6ddb1076..97dfbd6dd120a1d3eed85be4de1f110aee151b07 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -92,7 +92,7 @@ class modWebsites extends DolibarrModules $this->rights[$r][0] = 10001; $this->rights[$r][1] = 'Read website content'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $r++; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index e793d21e03ce41317839391776e9fdc97bd64f19..5c348cdf77f9b6d018034a11f541ed212d6fc514 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -94,7 +94,7 @@ class modWorkflow extends DolibarrModules $this->rights[$r][0] = 6001; // id de la permission $this->rights[$r][1] = "Lire les workflow"; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'read'; */ diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index e8578e21bc00fd66f71380bb810f2c6db0f548e4..34b6a6e20b9f5e564e68e7ba997ff4bdfd7ecada 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -722,7 +722,7 @@ class Expedition extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $error++; $this->errors[]=$mouvS->error; @@ -1917,7 +1917,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2082,7 +2082,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 792e6e106aaf474f690f094cfcf3bc0159aee892..b94564d953be39bebbaa910f2b2f54fb10ddbb34 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -379,7 +379,7 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.tva,"; $sql.= " t.localtax1,"; $sql.= " t.localtax2,"; - $sql.= " t.total,"; + //$sql.= " t.total,"; $sql.= " t.total_ht,"; $sql.= " t.total_tva,"; $sql.= " t.total_ttc,"; @@ -440,7 +440,7 @@ class FactureFournisseur extends CommonInvoice $this->tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; - $this->total = $obj->total; + //$this->total = $obj->total; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_ttc = $obj->total_ttc; @@ -1908,7 +1908,7 @@ class FactureFournisseur extends CommonInvoice * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @return int 0 if KO, 1 if OK + * @return int <0 if KO, 0 if nothing done, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { @@ -1917,7 +1917,7 @@ class FactureFournisseur extends CommonInvoice $langs->load("suppliers"); // Set the model on the model name to use - if (! dol_strlen($modele)) + if (empty($modele)) { if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { @@ -1925,13 +1925,20 @@ class FactureFournisseur extends CommonInvoice } else { - $modele = 'canelle'; + $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation } } + + if (empty($modele)) + { + return 0; + } + else + { + $modelpath = "core/modules/supplier_invoice/pdf/"; - $modelpath = "core/modules/supplier_invoice/pdf/"; - - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } /** diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b3fc59950316aa62470fff416d4fce0fb1384d54..2e0ef64f96fbf489bf5f81db1361db7ee133b542 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -254,6 +254,24 @@ if (empty($reshook)) if ($object->update($user) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } + else + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } } // payments conditions @@ -559,7 +577,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { dol_print_error($db,$object->error,$object->errors); exit; @@ -969,7 +987,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action=''; @@ -2325,7 +2343,7 @@ else if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { dol_print_error($db,$object->error,$object->errors); exit; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 374abf6a659de35d287f5f06724958d09e09288a..b8e90dbce10bc5f8195a29d9c424accd02b1baca 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -291,7 +291,7 @@ if ($search_ref) else $sql .= natural_search('f.ref', $search_ref); } if ($search_ref) $sql .= natural_search('f.ref', $search_ref); -if ($search_ref_supplier) $sql .= natural_search('f.ref_supplier', $search_ref_supplier); +if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_town) $sql.= natural_search('s.town', $search_town); @@ -300,7 +300,7 @@ if ($search_state) $sql.= natural_search("state.nom",$search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); +if ($search_montant_ht != '') $sql.= natural_search('f.total_ht', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.total_tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); @@ -405,7 +405,7 @@ if ($resql) if ($month_lim) $param.='&month_lim='.urlencode($month_lim); if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refsupplier) $param.='&search_refsupplier'.urlencode($search_refsupplier); + if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); if ($search_label) $param.='&search_label='.urlencode($search_label); if ($search_company) $param.='&search_company='.urlencode($search_company); if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 5bde4ff06ef9fb5fa3ce58d6111fd4f3942b3eba..508e64b33cbe5c6d899237b9e440e592c2e840a8 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -33,6 +33,7 @@ DELETE FROM llx_menu where module='expensereport'; ALTER TABLE llx_user DROP COLUMN phenix_login; ALTER TABLE llx_user DROP COLUMN phenix_pass; +ALTER TABLE llx_user ADD COLUMN dateemployment datetime; ALTER TABLE llx_societe ADD COLUMN fk_account integer; @@ -114,3 +115,6 @@ create table llx_product_warehouse_properties desiredstock integer DEFAULT '0', import_key varchar(14) -- Import key )ENGINE=innodb; + +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN entity integer DEFAULT 1 NOT NULL; + diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 0f0c3d4ebf97dc5725a7370737136e3819a4ad3a..94761416a47f3893d15a88076187f484722c2b65 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_accounting_bookkeeping ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id doc_date date NOT NULL, doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur doc_ref varchar(300) NOT NULL, -- facture_client/reglement_client/... reference number diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index d314cae372712d5ebea185af63e9ecfa17b3a8a5..42f83e165002f1043bd46e3b33711d33d2968ff1 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -54,7 +54,8 @@ create table llx_facturedet buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - fk_code_ventilation integer DEFAULT 0 NOT NULL, + fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line + special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- position of line fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines diff --git a/htdocs/install/mysql/tables/llx_user.key.sql b/htdocs/install/mysql/tables/llx_user.key.sql index 49916b68cb886ce4031a1c5316994fdb17bfda47..82d5f28ef06c8abb8642b2db873e32a29f0f43b9 100644 --- a/htdocs/install/mysql/tables/llx_user.key.sql +++ b/htdocs/install/mysql/tables/llx_user.key.sql @@ -21,8 +21,8 @@ ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); -ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); +ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member); -ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); +ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 6b3c5b83f6dbc7d7ad9463af23a47bed3e813b07..15461072b4abe40ee0732acc1d25e33435411414 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -78,7 +78,9 @@ create table llx_user nb_holiday integer DEFAULT 0, thm double(24,8), tjm double(24,8), - salary double(24,8), - salaryextra double(24,8), - weeklyhours double(16,8) + + salary double(24,8), -- denormalized value coming from llx_user_employment + salaryextra double(24,8), -- denormalized value coming from llx_user_employment + dateemployment date, -- denormalized value coming from llx_user_employment + weeklyhours double(16,8) -- denormalized value coming from llx_user_employment )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_user_employment.key.sql b/htdocs/install/mysql/tables/llx_user_employment.key.sql new file mode 100644 index 0000000000000000000000000000000000000000..fd0aa62567cff9f1bff4adc328a9a517d5360660 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.key.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> +-- +-- 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 <http://www.gnu.org/licenses/>. +-- +-- =========================================================================== + +ALTER TABLE llx_user_employment ADD UNIQUE INDEX uk_user_employment (ref,entity); + +ALTER TABLE llx_user_employment ADD CONSTRAINT fk_user_employment_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); diff --git a/htdocs/install/mysql/tables/llx_user_employment.sql b/htdocs/install/mysql/tables/llx_user_employment.sql new file mode 100644 index 0000000000000000000000000000000000000000..5c6d65a02c220db6ac27a5ab1fffbd0873b29b14 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.sql @@ -0,0 +1,39 @@ +-- ============================================================================ +-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> +-- +-- 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 <http://www.gnu.org/licenses/>. +-- +-- This table can be used to store employee working contracts +-- =========================================================================== + +create table llx_user_employment +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + ref varchar(50), -- reference + ref_ext varchar(50), -- reference into an external system (not used by dolibarr) + fk_user integer, + datec datetime, + tms timestamp, + fk_user_creat integer, + fk_user_modif integer, + job varchar(128), -- job position. may be a dictionnary + status integer NOT NULL, -- draft, active, closed + salary double(24,8), -- last and current value stored into llx_user + salaryextra double(24,8), -- last and current value stored into llx_user + weeklyhours double(16,8) -- last and current value stored into llx_user + dateemployment date, -- last and current value stored into llx_user + dateemploymentend date, -- last and current value stored into llx_user +)ENGINE=innodb; + diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 4b45dfae3e31cd803d3813e31e5e3b484aace0f9..96cc1c4fdcf7601ea52b33cf42e8474d6aac471c 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -249,7 +249,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $res=dol_include_once("/core/modules/".$file); $res=activateModule($modtoactivatenew,1); - if (! $result) print 'ERROR in activating module file='.$file; + if (! empty($res['errors'])) print 'ERROR in activating module file='.$file; } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 3c8a431fbb652be1c6a1c32bf4c88110aae3260d..79f20e2bf404d56ab48cc89e81d2b40f4ec6c2a1 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -54,10 +54,10 @@ ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the breakdown pages " ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services description in listings (Best = 50) ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50) -ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts -ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounts +ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounting accounts +ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounting accounts ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function "length of the accounts". -BANK_DISABLE_DIRECT_INPUT=Disable free input of bank transactions. Enable by default with this module. +BANK_DISABLE_DIRECT_INPUT=Disable free input of bank transactions (Enabled by default with this module). ACCOUNTING_SELL_JOURNAL=Sell journal ACCOUNTING_PURCHASE_JOURNAL=Purchase journal diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 042911e355ac22e1dcda19c3fa231a3d513fffdb..54cda62d35bf6d9c85335af903de544480805f99 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -8,15 +8,16 @@ VersionExperimental=Experimental VersionDevelopment=Development VersionUnknown=Unknown VersionRecommanded=Recommended -FileCheck=Files Integrity +FileCheck=Files integrity checker FileCheckDesc=This tool allows you to check the integrity of files of your application, comparing each files with the official ones. You can use this tool to detect if some files were modified by a hacker for example. MakeIntegrityAnalysisFrom=Make integrity analysis of application files from LocalSignature=Embedded local signature (less reliable) RemoteSignature=Remote distant signature (more reliable) FilesMissing=Missing Files FilesUpdated=Updated Files -FileCheckDolibarr=Check Dolibarr Files Integrity -XmlNotFound=Xml File of Dolibarr Integrity Not Found +FileCheckDolibarr=Check integrity of application files +AvailableOnlyOnPackagedVersions=The local file for integrity checking is only available when application is installed from a certified package +XmlNotFound=Xml Integrity File of application not found SessionId=Session ID SessionSaveHandler=Handler to save sessions SessionSavePath=Storage session localization @@ -474,8 +475,8 @@ Module410Name=Webcalendar Module410Desc=Webcalendar integration Module500Name=Special expenses Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends) -Module510Name=Salaries -Module510Desc=Management of employees salaries and payments +Module510Name=Employee contracts and salaries +Module510Desc=Management of employees contracts, salaries and payments Module520Name=Loan Module520Desc=Management of loans Module600Name=Notifications @@ -1624,3 +1625,5 @@ activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is miss CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter <strong>$dolibarr_main_restrict_os_commands</strong> into <strong>conf.php</strong> file. LandingPage=Landing page SamePriceAlsoForSharedCompanies=If you use the multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments +ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users manually if necessary. +UserHasNoPermissions=This user has no permission defined diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a4d4e6f99f59b585babe8fa79405842cefcde55d..ac27ef018fdce817cf3019e1aff7be37b31e9c1e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -142,7 +142,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t BillFrom=From BillTo=To ActionsOnBill=Actions on invoice -RecurringInvoiceTemplate=Recurring invoice +RecurringInvoiceTemplate=Template/Recurring invoice NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation. FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation. NotARecurringInvoiceTemplate=Not a recurring template invoice @@ -479,4 +479,6 @@ updatePriceNextInvoiceErrorUpdateline=Error : update price on invoice line : %s ToCreateARecurringInvoice=To create a recurring invoice for this contract, first create this draft invoice, then convert it into an invoice template and define the frequency for generation of future invoices. ToCreateARecurringInvoiceGene=To generate future invoices regularly and manually, just go on menu <strong>%s - %s - %s</strong>. ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated automatically, ask you administrator to enable and setup module <strong>%s</strong>. Note that both method (manual and automatic) can be used together with no risk of duplication. +DeleteRepeatableInvoice=Delete template invoice +ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice ? diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index a723053fa43978d42e909f16f2ca1ce04517f245..b0b1d129c25e58e9db5378e96f7a0bce41e9819d 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -101,4 +101,5 @@ ColorUser=Color of the user DisabledInMonoUserMode=Disabled in maintenance mode UserAccountancyCode=User accountancy code UserLogoff=User logout -UserLogged=User logged \ No newline at end of file +UserLogged=User logged +DateEmployment=Date of Employment \ No newline at end of file diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index 5e549f607a46e456771f5376ff76f8595e381ddf..1000fd233d416694045fdc7855be99fc69b3c325 100644 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -100,3 +100,4 @@ WeeklyHours=Heures de travail hebdomadaires ColorUser=Couleur de l'utilisateur DisabledInMonoUserMode=Désactivé en mode maintenance UserAccountancyCode=Code comptable utilisateur +DateEmployment=Date d'embauche diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 0cd8243f7a839d0334586817dade2170095859c6..14a5219d31c4240d35514be55194b978784b0ce2 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -86,29 +86,34 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; + +dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); + print '<table class="border" width="100%">'; -print '<tr><td width="20%">'.$langs->trans('SalesRepresentative').'</td>'; +print '<tr><td class="titlefield">'.$langs->trans('SalesRepresentative').'</td>'; print '<td colspan="4">'; print $form->select_dolusers($agentid, 'agentid', 1, '', $user->rights->margins->read->all ? 0 : 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '</td></tr>'; // Start date print '<td>'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>'; -print '<td width="20%">'; +print '<td>'; $form->select_date($startdate,'startdate','','',1,"sel",1,1); print '</td>'; -print '<td width="20%">'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>'; -print '<td width="20%">'; +print '<td>'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>'; +print '<td>'; $form->select_date($enddate,'enddate','','',1,"sel",1,1); print '</td>'; print '<td style="text-align: center;">'; print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Refresh')).'" />'; print '</td></tr>'; print "</table>"; + +dol_fiche_end(); + print '</form>'; $sql = "SELECT"; @@ -242,17 +247,14 @@ else } $db->free($result); - -llxFooter(); -$db->close(); - -?> - -<script type="text/javascript"> +print "\n".'<script type="text/javascript"> $(document).ready(function() { - $("#agentid").change(function() { $("div.fiche form").submit(); }); }); -</script> +</script>'."\n"; + +llxFooter(); +$db->close(); + diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5daa387dc76f6621ef8577b9671f20ac03b5d8ed..66ade35e09e89520be7764c839b1a99e8be0f6ec 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -118,18 +118,20 @@ llxHeader('', $title); // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; -dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto); print '<form method="post" name="sel" action="' . $_SERVER['PHP_SELF'] . '">'; + +dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto); + print '<table class="border" width="100%">'; // Start date -print '<td>' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')</td>'; -print '<td width="20%">'; +print '<td class="titlefield">' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')</td>'; +print '<td>'; $form->select_date($startdate, 'startdate', '', '', 1, "sel", 1, 1); print '</td>'; -print '<td width="20%">' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')</td>'; -print '<td width="20%">'; +print '<td>' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')</td>'; +print '<td>'; $form->select_date($enddate, 'enddate', '', '', 1, "sel", 1, 1); print '</td>'; print '<td style="text-align: center;">'; @@ -137,6 +139,9 @@ print '<input type="submit" class="button" value="' . dol_escape_htmltag($langs- print '</td></tr>'; print "</table>"; +dol_fiche_end(); + + $sql = "SELECT"; $sql .= " f.facnumber, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; $sql .= " ,d.fk_product"; @@ -243,11 +248,11 @@ if ($result) { dol_print_error($db); } -dol_fiche_end(); print '<div class="tabsAction">' . "\n"; print '<div class="inline-block divButAction"><input type="submit" name="button_updatemagins" id="button_updatemagins" class="butAction" value="' . $langs->trans("Update") . '" /></div>'; print '</div>'; + print '</form>'; $db->free($result); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index b038f083ba145a4c788d7e14013afc133bcbf726..54b83aca42c4ab51c1aedb871ef589da159d7517 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -73,9 +73,12 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); + print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; + +dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); + print '<table class="border" width="100%">'; $client = false; @@ -161,6 +164,9 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { } print "</table>"; + +dol_fiche_end(); + print '</form>'; $sql = "SELECT"; @@ -319,22 +325,19 @@ else } $db->free($result); - -llxFooter(); -$db->close(); - -?> - -<script type="text/javascript"> +print '<script type="text/javascript"> $(document).ready(function() { /* $("#socid").change(function() { $("div.fiche form").submit(); });*/ - $("#totalMargin").html("<?php echo price($totalMargin, null, null, null, null, $rounding); ?>"); - $("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%"); ?>"); - $("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%"); ?>"); - + $("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'"); + $("#marginRate").html("'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%").'"); + $("#markRate").html("'.(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%").'"); }); </script> +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index b460963344723444ac6635380ec7e014be2b9d7d..7a2ac98a5f8c8687cf1b4137f94f0f36493caf8a 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -95,26 +95,28 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">'; + +dol_fiche_head($head, 'productMargins', $titre, 0, $picto); + print '<table class="border" width="100%">'; if ($id > 0) { - print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>'; + print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>'; print '<td colspan="4">'; print $form->select_produits($id,'id','',20,0,1,2,'',1); print '</td></tr>'; - print '<tr><td width="20%">'.$langs->trans('AllProducts').'</td>'; + print '<tr><td>'.$langs->trans('AllProducts').'</td>'; print '<td colspan="4"><input type="checkbox" id="all" /></td></tr>'; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; } else { - print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>'; + print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>'; print '<td colspan="4">'; print $form->select_produits('','id','',20,0,1,2,'',1); print '</td></tr>'; @@ -122,12 +124,13 @@ else { } // Start date -print '<td>'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>'; -print '<td width="20%">'; +print '<tr>'; +print '<td class="titlefield">'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>'; +print '<td>'; $form->select_date($startdate,'startdate','','',1,"sel",1,1); print '</td>'; -print '<td width="20%">'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>'; -print '<td width="20%">'; +print '<td>'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>'; +print '<td>'; $form->select_date($enddate,'enddate','','',1,"sel",1,1); print '</td>'; print '<td style="text-align: center;">'; @@ -141,25 +144,28 @@ print '<br>'; print '<table class="border" width="100%">'; // Total Margin -print '<tr><td width="20%">'.$langs->trans("TotalMargin").'</td><td colspan="4">'; +print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">'; print '<span id="totalMargin"></span>'; // set by jquery (see below) print '</td></tr>'; // Margin Rate if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - print '<tr><td width="20%">'.$langs->trans("MarginRate").'</td><td colspan="4">'; + print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">'; print '<span id="marginRate"></span>'; // set by jquery (see below) print '</td></tr>'; } // Mark Rate if (! empty($conf->global->DISPLAY_MARK_RATES)) { - print '<tr><td width="20%">'.$langs->trans("MarkRate").'</td><td colspan="4">'; + print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">'; print '<span id="markRate"></span>'; // set by jquery (see below) print '</td></tr>'; } print "</table>"; + +dol_fiche_end(); + print '</form>'; $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; @@ -329,25 +335,25 @@ else $db->free($result); -llxFooter(); -$db->close(); - -?> - +print ' <script type="text/javascript"> $(document).ready(function() { $("#all").change(function() { - $("#id").val('').change(); + $("#id").val(\'\').change(); }); $("#id").change(function() { $("div.fiche form").submit(); }); - $("#totalMargin").html("<?php echo price($totalMargin, null, null, null, null, $rounding); ?>"); - $("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%"); ?>"); - $("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%"); ?>"); + $("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'"); + $("#marginRate").html("'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%").'"); + $("#markRate").html("'.(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%").'"); }); </script> +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 4edcbd8728d2be4044766c560794720d10678113..60f7938de06e0fd7d0a0f7302c76ca967d4a0786 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -111,6 +111,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su $result=$object->delete($user); if ($result > 0) { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); exit; } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index acbde6a8b07122533a36dbb3a4e8ed93241f8dc5..aee38a67ccf13995657620514e6cda584a8e9e83 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -214,13 +214,22 @@ class Entrepot extends CommonObject /** * Delete a warehouse * - * @param User $user Object user that made deletion - * @return int <0 if KO, >0 if OK + * @param User $user Object user that made deletion + * @param int $notrigger 1=No trigger + * @return int <0 if KO, >0 if OK */ - function delete($user) + function delete($user, $notrigger=0) { $this->db->begin(); + if (! $error && empty($notrigger)) + { + // Call trigger + $result=$this->call_trigger('WAREHOUSE_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + $elements = array('stock_mouvement','product_stock','product_warehouse_properties'); foreach($elements as $table) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 0a72a7ffca7e4f4f14ac1a58f660c4b56a246b07..1532f62aa22257b24fc5000a2d94175257a4e84d 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -560,7 +560,9 @@ class MouvementStock extends CommonObject */ function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='', $id_product_batch=0) { - $skip_batch = empty($conf->productbatch->enabled); + global $conf; + + $skip_batch = empty($conf->productbatch->enabled); return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 61629e63838b1824088b2d77a09ea8ebc1495a93..774976c3a4a6f2e2e08e604e7a2634c5dd9bf732 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -110,6 +110,9 @@ class CompanyBankAccount extends Account { $this->create(); } + + if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); + if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; $sql.= " bank = '" .$this->db->escape($this->bank)."'"; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 810984a4a408312c1cf374cd809a1b04eac81651..e4eb0ef705359e37ad78962cc0d48ef62fea0a99 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -541,7 +541,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">'; - print '<textarea name="domiciliation" rows="4" cols="40">'; + print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">'; print $account->domiciliation; print "</textarea></td></tr>"; @@ -550,7 +550,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print "</td></tr>\n"; print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">'; - print "<textarea name=\"owner_address\" rows=\"4\" cols=\"40\">"; + print "<textarea name=\"owner_address\" rows=\"4\" cols=\"40\" maxlength=\"255\">"; print $account->owner_address; print "</textarea></td></tr>"; @@ -644,7 +644,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>'; print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">'; - print '<textarea name="domiciliation" rows="4" cols="40">'; + print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">'; print GETPOST('domiciliation'); print "</textarea></td></tr>"; @@ -653,7 +653,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print "</td></tr>\n"; print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">'; - print '<textarea name="owner_address" rows="4" cols="40">'; + print '<textarea name="owner_address" rows="4" cols="40" maxlength="255">'; print GETPOST('owner_address'); print "</textarea></td></tr>"; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dd46ef79e59761fc298d5686f65d8e3c94a6f173..fb3ad2fe3f00816021a105610a44d9d6afea8539 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -216,6 +216,8 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); + $object->dateemployment = $dateemployment; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -357,6 +359,8 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); + $object->dateemployment = $dateemployment; if (! empty($conf->multicompany->enabled)) { @@ -1057,6 +1061,13 @@ if (($action == 'create') || ($action == 'adduserldap')) print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">'; print '</td>'; print "</tr>\n"; + + // Date employment + print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; + print '<td>'; + echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '</td>'; + print "</tr>\n"; // Accountancy code if ($conf->accounting->enabled) @@ -1128,6 +1139,10 @@ else $object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); + + // Check if user has rights + $object->getrights(); + if(empty($object->nb_rights)) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon @@ -1412,6 +1427,13 @@ else print '<td>'.$object->accountancy_code.'</td>'; } + // Date employment + print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; + print '<td>'; + print dol_print_date($object->dateemployment); + print '</td>'; + print "</tr>\n"; + print '</table>'; print '</div>'; @@ -2186,6 +2208,13 @@ else print '</td>'; print "</tr>\n"; + // Date employment + print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; + print '<td>'; + echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '</td>'; + print "</tr>\n"; + // Accountancy code if ($conf->accounting->enabled) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 840d5835fd40c858a90156f9c5ca11090a90af4a..37832f20ea6988fa23335ac0d24700f527f65c14 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -107,6 +107,7 @@ class User extends CommonObject var $rights; // Array of permissions user->rights->permx var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ private $_tab_loaded=array(); // Array of cache of already loaded permissions + var $nb_rights; // Number of rights granted to the user var $conf; // To store personal config var $oldcopy; // To contains a clone of this when we need to save old properties of object @@ -115,13 +116,17 @@ class User extends CommonObject var $parentof; // To store an array of all parents for all ids. var $accountancy_code; // Accountancy code in prevision of the complete accountancy module - var $thm; // Average cost of employee + + var $thm; // Average cost of employee - Used for valuation of time spent var $tjm; // Average cost of employee - var $salary; // Monthly salary - var $salaryextra; // Monthly salary extra - var $weeklyhours; // Weekly hours + + var $salary; // Monthly salary - Denormalized value from llx_user_employment + var $salaryextra; // Monthly salary extra - Denormalized value from llx_user_employment + var $weeklyhours; // Weekly hours - Denormalized value from llx_user_employment var $color; // Define background color for user in agenda + + var $dateemployment; // Define date of employment by company /** * Constructor de la classe @@ -138,6 +143,7 @@ class User extends CommonObject // For cache usage $this->all_permissions_are_loaded = 0; + $this->nb_rights = 0; // Force some default values $this->admin = 0; @@ -187,6 +193,7 @@ class User extends CommonObject $sql.= " u.salaryextra,"; $sql.= " u.weeklyhours,"; $sql.= " u.color,"; + $sql.= " u.dateemployment,"; $sql.= " u.ref_int, u.ref_ext,"; $sql.= " c.code as country_code, c.label as country,"; $sql.= " d.code_departement as state_code, d.nom as state"; @@ -286,6 +293,7 @@ class User extends CommonObject $this->salaryextra = $obj->salaryextra; $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; + $this->dateemployment = $this->db->jdate($obj->dateemployment); $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); @@ -629,10 +637,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; } @@ -679,10 +689,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; } @@ -1260,6 +1272,7 @@ class User extends CommonObject $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); $this->color = empty($this->color)?'':$this->color; + $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; // Check parameters if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -1300,6 +1313,7 @@ class User extends CommonObject $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; $sql.= ", color = '".$this->db->escape($this->color)."'"; + $sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null'); $sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); @@ -1311,7 +1325,7 @@ class User extends CommonObject $sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null"); $sql.= ", entity = '".$this->db->escape($this->entity)."'"; $sql.= " WHERE rowid = ".$this->id; - + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index d3d7c300308d73a223455edb995f273e4a960a49..e695bff34a307602dc9125549bce4bba746c654c 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -233,7 +233,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase $localobject=new Entrepot($this->savdb); $result=$localobject->fetch($id); - $result=$localobject->delete($id); + $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0);