diff --git a/ChangeLog b/ChangeLog index 7a5e1c7c5da..c94ceefcb5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -226,6 +226,7 @@ Dolibarr better: - Fix: [ bug #1827 ] Tax reports gives incorrect amounts when using external modules that create lines with special codes - Fix: [ bug #1822 ] SQL error in clientfourn.php report with PostgreSQL - Fix: [ bug #1832 ] SQL error when adding a product with no price defined to an object +- Fix: [ bug #1833 ] user permissions in contact/note.php not working - Fix: [ bug #1826 ] Supplier payment types are not translated into fourn/facture/paiement.php - Fix: [ bug #1830 ] Salaries payment only allows checking accounts - Fix: [ bug #1825 ] External agenda: hide/show checkbox doesn't work diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 71c45be9eff..431b7bd14b6 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Cedric GROSS + * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -347,7 +348,6 @@ if (! empty($conf->use_javascript_ajax)) $s=''; $s.='' . "\n"; + foreach ($showextcals as $val) { $htmlname = md5($val['name']); - $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s.='
' . $val['name'] . '  
'; } } $s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b2ec0de3ad5..e977712ab39 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1294,7 +1294,7 @@ class BonPrelevement extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum); $this->total = $this->total + $obj->somme; $i++; } @@ -1496,6 +1496,20 @@ class BonPrelevement extends CommonObject } + /** + * Build RUM number for a customer bank account + * + * @param string $row_code_client Customer code (soc.code_client) + * @param int $row_datec Creation date of bank account (rib.datec) + * @param string $row_drum Id of customer bank account (rib.rowid) + * @return string RUM number + */ + static function buildRumNumber($row_code_client, $row_datec, $row_drum) + { + $pre = ($row_datec > 1359673200) ? 'Rum' : '++R'; + return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); + } + /** * Write recipient of request (customer) * @@ -1514,7 +1528,7 @@ class BonPrelevement extends CommonObject * @param string $row_iban rib.iban_prefix AS iban, * @param string $row_bic rib.bic AS bic, * @param string $row_datec rib.datec, - * @param string $row_drum rib.rowid AS drum + * @param string $row_drum rib.rowid used to generate rum * @return string Return string with SEPA part DrctDbtTxInf */ function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) @@ -1524,10 +1538,11 @@ class BonPrelevement extends CommonObject // Define value for RUM // Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId) - $Date_Rum = strtotime($row_datec); + $Rum = $this->buildRumNumber($row_code_client, $row_datec, $row_drum); + + // Define date of RUM signature $DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d'); - $pre = ($date_Rum > 1359673200) ? 'Rum' : '++R'; - $Rum = $pre.$row_code_client.$row_drum.'-0'.date('U', $Date_Rum); + $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 3bd93659b5e..43e53140d35 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -373,7 +373,7 @@ if ($id) print "
\n"; if ($salpayment->rappro == 0) { - if (! empty($user->rights->tax->charges->supprimer)) + if (! empty($user->rights->salaries->delete)) { print ''.$langs->trans("Delete").''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d6be5f4c0f4..82563549675 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -73,7 +73,7 @@ $object = new Contrat($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || ! empty($ref) && $action!='add') { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -207,6 +207,13 @@ if ($action == 'add' && $user->rights->contrat->creer) $error++; } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + $action = 'create'; + } + if (! $error) { $object->socid = $socid; @@ -356,11 +363,6 @@ if ($action == 'add' && $user->rights->contrat->creer) } else { - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) $error++; - $result = $object->create($user); if ($result > 0) { @@ -726,20 +728,19 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) $error++; + if ($ret < 0) + $error ++; - if (! $error) - { - $result = $object->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - else if ($reshook < 0) $error++; + if (! $error) { - if ($error) - { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + + if ($error) { $action = 'edit_extras'; setEventMessage($object->error,'errors'); } diff --git a/htdocs/contrat/class/index.html b/htdocs/contrat/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index c400dc151d3..5451d7457ce 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -65,7 +65,7 @@ class DolGraph var $bgcolorgrid=array(255,255,255); // array(R,G,B) var $datacolor; // array(array(R,G,B),...) - private $_stringtoshow; // To store string to output graph into HTML page + protected $_stringtoshow; // To store string to output graph into HTML page /** diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 2c567cf10d1..c7177475a34 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -275,8 +275,7 @@ abstract class DoliDB implements Database */ function jdate($string, $gm=false) { - if($string==0 || $string=="0000-00-00 00:00:00") - return NULL; + if ($string==0 || $string=="0000-00-00 00:00:00") return ''; $string=preg_replace('/([^0-9])/i','',$string); $tmp=$string.'000000'; $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index ce3762202e4..3c95d9f73f7 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -505,7 +505,7 @@ class DoliDBSqlite3 extends DoliDB //return $resultset->fetch(PDO::FETCH_OBJ); $ret = $resultset->fetchArray(SQLITE3_ASSOC); if ($ret) { - return (object)$ret; + return (object) $ret; } } @@ -523,7 +523,7 @@ class DoliDBSqlite3 extends DoliDB //return $resultset->fetch(PDO::FETCH_ASSOC); $ret = $resultset->fetchArray(SQLITE3_ASSOC); if ($ret) { - return (array)$ret; + return (array) $ret; } } @@ -1248,19 +1248,23 @@ class DoliDBSqlite3 extends DoliDB /** * Permet le chargement d'une fonction personnalisee dans le moteur de base de donnees. - * Note: le nom de la fonction personnalisee est prefixee par 'db_'. La fonction doit être + * Note: le nom de la fonction personnalisee est prefixee par 'db'. La fonction doit être * statique et publique. Le nombre de parametres est determine automatiquement. - * @param string $name Le nom de la fonction a definir dans Sqlite + * + * @param string $name Le nom de la fonction a definir dans Sqlite + * @param int $arg_count Arg count + * @return void */ private function addCustomFunction($name, $arg_count = -1) { if ($this->db) { - $localname = __CLASS__ . '::' . 'db_' . $name; + $localname = __CLASS__ . '::' . 'db' . $name; $reflectClass = new ReflectionClass(__CLASS__); - $reflectFunction = $reflectClass->getMethod('db_' . $name); + $reflectFunction = $reflectClass->getMethod('db' . $name); if ($arg_count < 0) { $arg_count = $reflectFunction->getNumberOfParameters(); } - if (!$this->db->createFunction($name, $localname , $arg_count)) { + if (!$this->db->createFunction($name, $localname, $arg_count)) + { $this->error = "unable to create custom function '$name'"; } } @@ -1268,34 +1272,54 @@ class DoliDBSqlite3 extends DoliDB /** * Cette fonction est l'equivalent de la fonction MONTH de MySql. - * @param string $date - * @return integer + * + * @param string $date Date + * @return integer */ - public static function db_MONTH($date) { + public static function dbMONTH($date) + { return date('n', strtotime($date)); } /** * calcule du numéro de semaine * - * @param string date - * @param int mode + * @param string $date Date + * @param int $mode Mode + * @return string */ - public static function db_WEEK($date, $mode = 0) { + public static function dbWEEK($date, $mode = 0) + { $arr = date_parse($date); $calc_year = 0; return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year); } - public static function db_CURDATE() { + /** + * db_CURDATE + * + * @return string + */ + public static function dbCURDATE() { return date('Y-m-d'); } - public static function db_CURTIME() { + /** + * db_CURTIME + * + * @return string + */ + public static function dbCURTIME() { return date('H:i:s'); } - public static function db_WEEKDAY($date) { + /** + * dbWEEKDAY + * + * @param int $date Date + * @return string + */ + public static function dbWEEKDAY($date) { $arr = date_parse($date); return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0); @@ -1304,11 +1328,13 @@ class DoliDBSqlite3 extends DoliDB /** * Cette fonction est l'equivelent de la fonction date_format de MySQL. * @staticvar string $mysql_replacement Les symboles formatage a remplacer - * @param string $date la date dans un format ISO - * @param string $format la chaine de formatage - * @return string La date formatee. + * + * @param string $date la date dans un format ISO + * @param string $format la chaine de formatage + * @return string La date formatee. */ - public static function db_date_format($date, $format) { + public static function dbdate_format($date, $format) + { static $mysql_replacement; if (! isset($mysql_replacement)) { $mysql_replacement = array( @@ -1345,9 +1371,9 @@ class DoliDBSqlite3 extends DoliDB $state = 0; $timestamp = strtotime($date); $yday = date('z', $timestamp); - $month = (integer)date("n", $timestamp); - $year = (integer)date("Y", $timestamp); - $day = (integer)date("d", $timestamp); + $month = (integer) date("n", $timestamp); + $year = (integer) date("Y", $timestamp); + $day = (integer) date("d", $timestamp); for($idx = 0; $idx < $lg; ++$idx) { $char = $format[$idx]; if ($state == 0) { @@ -1395,19 +1421,15 @@ class DoliDBSqlite3 extends DoliDB return date($fmt, strtotime($date)); } - /** - * Equivalent de la fonction MySQL IF - * @param boolean $test Le resultat du test - * @param mixed $true_part Partie a retourner si vrai - * @param mixed $false_part Partie a retourner si faux - * @return mixed Partie selectionnee en fonction du test - */ - public static function db_IF($test, $true_part, $false_part) { - return ( $test ) ? $true_part : $false_part; - } - // Adapté de mytime.c des sources de mariadb - // fonction calc_daynr + /** + * calc_daynr + * + * @param string $year Year + * @param string $month Month + * @param string $day Day + * @return string La date formatee. + */ private static function calc_daynr($year, $month, $day) { $y = $year; if ($y == 0 && $month == 0) return 0; @@ -1421,16 +1443,34 @@ class DoliDBSqlite3 extends DoliDB return $num + floor($y / 4) - $temp; } + /** + * calc_weekday + * + * @param string $daynr ??? + * @param string $sunday_first_day_of_week ??? + */ private static function calc_weekday($daynr, $sunday_first_day_of_week) { $ret = floor(($daynr + 5 + ($sunday_first_day_of_week ? 1 : 0)) % 7); return $ret; } + /** + * calc_days_in_year + * + * @param string $year Year + * @return int Nb of days in year + */ private static function calc_days_in_year($year) { return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365); } + /** + * week_mode + * + * @param string $mode Mode + * @return string Week format + */ private static function week_mode($mode) { $week_format= ($mode & 7); if (!($week_format & self::WEEK_MONDAY_FIRST)) { @@ -1439,7 +1479,16 @@ class DoliDBSqlite3 extends DoliDB return $week_format; } - + /** + * calc_week + * + * @param string $year Year + * @param string $month Month + * @param string $day Day + * @param string $week_behaviour Week behaviour + * @param string $calc_year ??? + * @return string ??? + */ private static function calc_week($year, $month, $day, $week_behaviour, &$calc_year) { $daynr=self::calc_daynr($year,$month,$day); $first_daynr=self::calc_daynr($year,1,1); diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 79652c9c5c4..1fd86ed871d 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -52,7 +52,7 @@ if (empty($usemargins)) $usemargins=0; global->MAIN_VIEW_LINE_NUMBER)) { ?> -
+
info_bits & 2) == 2) { ?> info_bits & 2) == 2) { ?> - id.'#'.$line->id; ?>"> + id.'#line_'.$line->id; ?>"> diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 85e8406d708..3075d128066 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -553,11 +553,11 @@ foreach ($listofreferent as $key => $value) { if ($key == 'order_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->creer) { - print ''.$langs->trans("AddSupplierInvoice").''; + print ''.$langs->trans("AddSupplierOrder").''; } if ($key == 'invoice_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->creer) { - print ''.$langs->trans("AddSupplierOrder").''; + print ''.$langs->trans("AddSupplierInvoice").''; } } } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 37e646d6b88..255ab6a05a6 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -49,6 +49,10 @@ class CompanyBankAccount extends Account var $owner_address; var $default_rib; + var $datec; + var $datem; + + /** * Constructor * @@ -174,7 +178,7 @@ class CompanyBankAccount extends Account { if (empty($id) && empty($socid)) return -1; - $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, owner_address, default_rib, label"; + $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, owner_address, default_rib, label, datec, tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) $sql.= " WHERE rowid = ".$id; if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1"; @@ -200,6 +204,8 @@ class CompanyBankAccount extends Account $this->owner_address = $obj->owner_address; $this->label = $obj->label; $this->default_rib = $obj->default_rib; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); } $this->db->free($resql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ea08019853e..ee81df97889 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -968,7 +968,7 @@ class Societe extends CommonObject * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) - * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof. + * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='') { @@ -1025,7 +1025,7 @@ class Societe extends CommonObject { $this->error='Fetch several records found for ref='.$ref; dol_syslog($this->error, LOG_ERR); - $result = -1; + $result = -2; } if ($num) { @@ -1150,17 +1150,15 @@ class Societe extends CommonObject $this->fetch_optionals($this->id,$extralabels); } else - { - $this->error='Fetch no third party found for id='.$rowid; - dol_syslog($this->error, LOG_ERR); - $result = -2; + { + $result = 0; } $this->db->free($resql); } else - { - $this->error=$this->db->error(); + { + $this->error=$this->db->lasterror(); $result = -3; } @@ -1180,12 +1178,21 @@ class Societe extends CommonObject * @param boolean $case Case sensitive (true/false) * @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database. * @param string $clause Clause for filters - * @return array Array of thirdparties object + * @return array|int <0 if KO, array of thirdparties object if OK */ function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND') { $thirdparties = array(); + dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact); + + // Check parameter + if (empty($name)) + { + $this->errors[]='ErrorBadValueForParameter'; + return -1; + } + // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE entity IN (".getEntity('category',1).")"; @@ -1264,7 +1271,7 @@ class Societe extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error=$this->db->lasterror(); return -1; } } diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 2a21f6cdc87..dd2e0e4d21b 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $langs->load("companies"); $langs->load("commercial"); @@ -191,6 +192,7 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') */ $form = new Form($db); +$prelevement = new BonPrelevement($db); llxHeader(); @@ -336,11 +338,11 @@ if ($socid && $action != 'edit' && $action != "create") print "
"; - + /* * List of bank accounts */ - + print_titre($langs->trans("AllRIB")); $rib_list = $soc->get_all_rib(); @@ -355,6 +357,10 @@ if ($socid && $action != 'edit' && $action != "create") print_liste_field_titre($langs->trans("RIB")); print_liste_field_titre($langs->trans("IBAN")); print_liste_field_titre($langs->trans("BIC")); + if (! empty($conf->prelevement->enabled)) + { + print 'RUM'; + } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); print ''; print ''; @@ -372,6 +378,12 @@ if ($socid && $action != 'edit' && $action != "create") print ''.$rib->iban.''; // BIC print ''.$rib->bic.''; + + if (! empty($conf->prelevement->enabled)) + { + print ''.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).''; + } + // Default print ''; if (!$rib->default_rib) {