diff --git a/.travis.yml b/.travis.yml index 8e1aa2aa10b..718356e8075 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 2a952c56e6f..750e5c035ab 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 2f7228eb9d4..63f99184884 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 057e2f0484c..6ce8bb5fad0 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 f9fb603e483..5b767208987 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 '
'; -print '' . $langs->trans("NewFiscalYear") . ''; +if (! empty($user->rights->accounting->fiscalyear)) +{ + print '' . $langs->trans("NewFiscalYear") . ''; +} +else +{ + print '' . $langs->trans("NewFiscalYear") . ''; +} print '
'; llxFooter(); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index ec0f19d9d07..7c5c6d08c73 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 '
'; + if (! empty($user->rights->accounting->fiscalyear)) + { + /* + * Barre d'actions + */ + print '
'; - print '' . $langs->trans('Modify') . ''; - - print '' . $langs->trans('Delete') . ''; - - print '
'; + print '' . $langs->trans('Modify') . ''; + + print '' . $langs->trans('Delete') . ''; + + print '
'; + } } } else { dol_print_error($db); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 612e4d7f759..3596d73d751 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 0d863e064d4..7b8aa12dca2 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 } } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; } - // Affichage par compte comptable - $sql .= ' ORDER BY t.numero_compte ASC'; + if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + // 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 9294cf7f6a8..f94ec8a2b0f 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 4df2c68243a..18a18720569 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -171,9 +171,9 @@ print ''; print ''; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } -print ''; +print ''; $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 "
\n"; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
'; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } -print ''; +print ''; $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; for($i = 1; $i <= 12; $i ++) { @@ -264,9 +264,9 @@ if (! empty($conf->margin->enabled)) { print '
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
'; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } - print ''; + print ''; $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; for($i = 1; $i <= 12; $i ++) { @@ -291,9 +291,9 @@ if (! empty($conf->margin->enabled)) { print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c0a59689140..31e4ea7ccff 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 ''; -/* - * Action - */ - /* * Customer Invoice lines */ @@ -251,7 +252,7 @@ if ($result) { print '
' . $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account($account_parent, 'account_parent', 1); - print '
'; + print ''; print ''; 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 '
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price(price2num($row[$i])) . '' . price($row[13]) . '' . price(price2num($row[13])) . '
'; if ($product_static->id) print $product_static->getNomUrl(1); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 0c1a4d1eb6b..7d2326b05e5 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 ' +'."\n"; + +llxFooter(); +$db->close(); + diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5daa387dc76..66ade35e09e 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 '
'; + +dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto); + print ''; // Start date -print ''; -print ''; +print ''; -print ''; -print ''; +print ''; print ''; print "\n"; + // Date employment + print ''; + print ''; + print "\n"; + // Accountancy code if ($conf->accounting->enabled) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 840d5835fd4..37832f20ea6 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 d3d7c300308..e695bff34a3 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);
' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')'; +print '' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')'; $form->select_date($startdate, 'startdate', '', '', 1, "sel", 1, 1); print '' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')'; +print '' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')'; $form->select_date($enddate, 'enddate', '', '', 1, "sel", 1, 1); print ''; @@ -137,6 +139,9 @@ print '"; +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 '
' . "\n"; print '
'; print '
'; + print ''; $db->free($result); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index b038f083ba1..54b83aca42c 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 '
'; + +dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); + print ''; $client = false; @@ -161,6 +164,9 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { } print "
"; + +dol_fiche_end(); + print '
'; $sql = "SELECT"; @@ -319,22 +325,19 @@ else } $db->free($result); - -llxFooter(); -$db->close(); - -?> - - +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index b4609633447..7a2ac98a5f8 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 '
'; + +dol_fiche_head($head, 'productMargins', $titre, 0, $picto); + print ''; if ($id > 0) { - print ''; + print ''; print ''; - print ''; + print ''; print ''; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; } else { - print ''; + print ''; print ''; @@ -122,12 +124,13 @@ else { } // Start date -print ''; -print ''; +print ''; +print ''; -print ''; -print ''; +print ''; print '"; @@ -550,7 +550,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print "\n"; print '"; @@ -644,7 +644,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print ''; print '"; @@ -653,7 +653,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print "\n"; print '"; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dd46ef79e59..fb3ad2fe3f0 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 ''; print ''; print "\n"; + + // Date employment + print ''; + print ''; + print "\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 ''; } + // Date employment + print ''; + print ''; + print "\n"; + print '
'.$langs->trans('ChooseProduct/Service').'
'.$langs->trans('ChooseProduct/Service').''; print $form->select_produits($id,'id','',20,0,1,2,'',1); print '
'.$langs->trans('AllProducts').'
'.$langs->trans('AllProducts').'
'.$langs->trans('ChooseProduct/Service').'
'.$langs->trans('ChooseProduct/Service').''; print $form->select_produits('','id','',20,0,1,2,'',1); print '
'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')'; +print '
'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')'; $form->select_date($startdate,'startdate','','',1,"sel",1,1); print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; +print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; $form->select_date($enddate,'enddate','','',1,"sel",1,1); print ''; @@ -141,25 +144,28 @@ print '
'; print ''; // Total Margin -print ''; // Margin Rate if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; } // Mark Rate if (! empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; } print "
'.$langs->trans("TotalMargin").''; +print '
'.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarginRate").''; + print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; + print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; + +dol_fiche_end(); + print ''; $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 ' +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 4edcbd8728d..60f7938de06 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 acbde6a8b07..aee38a67ccf 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 0a72a7ffca7..1532f62aa22 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 61629e63838..774976c3a4a 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 810984a4a40..e4eb0ef7053 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -541,7 +541,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } print '
'.$langs->trans("BankAccountDomiciliation").''; - print '
'.$langs->trans("BankAccountOwnerAddress").''; - print "
'.$langs->trans("BankAccountDomiciliation").''; - print '
'.$langs->trans("BankAccountOwnerAddress").''; - print '
'.$langs->trans("DateEmployment").''; + echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '
'.$object->accountancy_code.'
'.$langs->trans("DateEmployment").''; + print dol_print_date($object->dateemployment); + print '
'; print ''; @@ -2186,6 +2208,13 @@ else print '
'.$langs->trans("DateEmployment").''; + echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '