diff --git a/.travis.yml b/.travis.yml index ca2574bc846..5bc5f49b2e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -128,7 +128,7 @@ script: - php upgrade.php 3.6.0 3.7.0 ignoredbversion > upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 ignoredbversion > upgrade360370-2.log - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log - - cat upgrade370380.log +# - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log # - cat upgrade370380-2.log - cd ../.. diff --git a/ChangeLog b/ChangeLog index 68d6b1848f1..eb82166af8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,16 +41,40 @@ Dolibarr better: - Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook development rules. They are "addreplace" hooks, so you must return content with "->resprints='mycontent'" and not with "return 'mycontent'" - All fields "fk_societe" were renamed into "fk_soc". +- Method select_PriceBaseType and load_PriceBaseType were merged into selectPriceBaseType + + +***** ChangeLog for 3.7.2 compared to 3.7.1 ***** +FIX [ bug #2855 ] Wrong translation key in localtax report page +FIX [ bug #1852 ] JS error when editing a customer order line +FIX [ bug #2900 ] Courtesy title is not stored in create thirdparty form ***** ChangeLog for 3.7.1 compared to 3.7.* ***** -- Fix: Bug in the new photo system -- Fix: Error management -- Fix: [ Bug #2714 ] Members -> Memberxy-> Agenda -> technical Error -- Fix: [ Bug #2713 ] 3.7.0 mailing-unsubscribe.php not unsubscribe +FIX Bug in the new photo system +FIX Error management +FIX [ Bug #2714 ] Members -> Memberxy-> Agenda -> technical Error +FIX [ Bug #2713 ] 3.7.0 mailing-unsubscribe.php not unsubscribe +FIX #2901 +FIX when we create an agenda event with "Not applicable" status, it is automatically saved with "To do" status +FIX check the user status during authentication +FIX top links menu have target attribute with wrong value +FIX extrafields required on thirdparty +FIX create contact with extrafield is null when it is require +FIX width multiselect +FIX "script" tag with wrong syntax +Fix bug debian 786479 +FIX update usergroup name +Fix facturestats was not filtering on invoice type +FIX #2856 : Wrong table design +FIX button create payment hide if tax amount is less than 1 +FIX event for restricted user was restricted if company null +FIX send mail, copy sendto don't read the list of contact +FIX Properly escape untrusted data to prevent HTML injection. +FIX send mail, copy sendto don't read the list of contact -- Path to save photos of products was moved in 3.7.0 to match path of other attached files. If you had loose - your photo on the photo tab of products, you can set the constant "PRODUCT_USE_OLD_PATH_FOR_PHOTO" to - restore old path. +Path to save photos of products was moved in 3.7.0 to match path of other attached files. If you had loose +your photo on the photo tab of products, you can set the constant "PRODUCT_USE_OLD_PATH_FOR_PHOTO" to +restore old path. WARNING: @@ -236,8 +260,8 @@ Dolibarr better: - Table llx_c_pays were renamed into llx_c_country. - Triggers *_BUILDDOC are removed. Building a doc is not a business event. For action after creation of a pdf or odt, hook "afterPDFCreation" or "afterODTCreation" must be used instead. -- A lot of pages called fiche.php were renamed into card.php -- A lot of pages called liste.php were renamed into list.php +- A lot of pages named fiche.php were renamed into card.php +- A lot of pages named liste.php were renamed into list.php - If you used warehouse/stock module, recheck setup of stock increase/decrease rules of the warehouse module and your Point Of Sale module setup if you use one. - Replaced USER_UPDATE_SESSION trigger with an updateSession hook may break modules using it. @@ -279,6 +303,7 @@ Dolibarr better: - Fix: [ bug #2545 ] Missing object_margin.png in Amarok theme - Fix: [ bug #2542 ] Contracts store localtax preferences - Fix: Bad permission assignments for stock movements actions +- Fix: [ bug #2891 ] Category hooks do not work ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. @@ -453,6 +478,10 @@ Fix: [ bug #2577 ] Incorrect invoice status in "Linked objects" page of a projec Fix: [ bug #2576 ] Unable to edit a dictionary entry that has # in its ref Fix: [ bug #2758 ] Product::update sets product note to "null" when $prod->note is null Fix: [ bug #2757 ] Deleting product category photo gives "Forbidden access" error +Fix: [ bug #2976 ] "Report" tab is the current tab but it is not marked as selected by the UI +Fix: [ bug #2861 ] Undefined variable $res when migrating +Fix: [ bug #2837 ] Product list table column header does not match column body +Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c667754d4ab..bdfc9d8972a 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -455,8 +455,9 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/documents`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/document`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; - # Removed known external modules to avoir any error when packaging on test env + # Removed known external modules to avoid any error when packaging from env where external modules are tested $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/calling*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/bootstrap*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom*`; @@ -981,10 +982,10 @@ if ($nboftargetok) { mkdir($DESTI.'/package_windows'); if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } - print "Remove target $FILENAMEEXEDOLIWAMP.exe...\n"; + print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n"; unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"; - print "Check that in your Wine setup, you create a Z: drive that point to your /tmp directory.\n"; + print "Check that in your Wine setup, you create a Z: drive that point to your / directory.\n"; $SOURCEBACK=$SOURCE; $SOURCEBACK =~ s/\//\\/g; diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 7f814a826df..2cc29a14a9a 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -8,7 +8,7 @@ This files describe steps made by Dolibarr packaging team to make a beta version of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base x.y origin/develop`..x.y --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'" +- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base (x.y)-1 origin/develop`..x.y(.z) --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'" - Update version number with x.y.z-w in htdocs/filefunc.inc.php - Update version number with x.y.z-w in build/debian/changelog - Commit all changes. @@ -29,7 +29,7 @@ This files describe steps made by Dolibarr packaging team to make a complete release of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base x.y origin/develop`..x.y --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'" +- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base (x.y)-1 origin/develop`..x.y(.z) --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'" - Update version number with x.y.z in htdocs/filefunc.inc.php - Update version number with x.y.z in build/debian/changelog - Commit all changes. diff --git a/dev/ansible/README.md b/dev/ansible/README.md index aeed9fc6983..e498ebc3340 100644 --- a/dev/ansible/README.md +++ b/dev/ansible/README.md @@ -3,7 +3,7 @@ This is a quick tutorial: * Install ansible: -> apt-get install +> apt-get install ansible * Add ip of server to manage into /etc/ansible/hosts diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 7f16ad02a76..9b5c0931650 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -350,6 +350,11 @@ + + + 0 + + diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 7ba04331454..814badf95a7 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -65,6 +65,10 @@ $object = new Categorie($db); $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + + /* * Actions */ diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 155593b5efd..5edede7417e 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -208,7 +208,7 @@ if (empty($reshook)) } else { - setEventMessages($cat->error,$this->errors,'errors'); + setEventMessages( $cat->error, $cat->errors, 'errors' ); } } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 167a256a990..190f58d9388 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,6 +48,67 @@ class Categorie extends CommonObject const TYPE_MEMBER = 3; const TYPE_CONTACT = 4; + /** + * @var array ID mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + private $MAP_ID = array( + 'product' => 0, + 'supplier' => 1, + 'customer' => 2, + 'member' => 3, + 'contact' => 4, + ); + /** + * @var array Foreign keys mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + private $MAP_CAT_FK = array( + 'product' => 'product', + 'customer' => 'soc', + 'supplier' => 'soc', + 'member' => 'member', + 'contact' => 'socpeople', + ); + /** + * @var array Category tables mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + private $MAP_CAT_TABLE = array( + 'product' => 'product', + 'customer' => 'societe', + 'supplier' => 'fournisseur', + 'member' => 'member', + 'contact' => 'contact', + ); + /** + * @var array Object class mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + private $MAP_OBJ_CLASS = array( + 'product' => 'Product', + 'customer' => 'Societe', + 'supplier' => 'Fournisseur', + 'member' => 'Adherent', + 'contact' => 'Contact', + ); + /** + * @var array Object table mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + private $MAP_OBJ_TABLE = array( + 'product' => 'product', + 'customer' => 'societe', + 'supplier' => 'societe', + 'member' => 'adherent', + 'contact' => 'socpeople', + ); + public $element='category'; public $table_element='categories'; @@ -56,13 +117,21 @@ class Categorie extends CommonObject var $label; var $description; var $socid; - var $type; // 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member, 4=Contact + /** + * @var int Category type + * + * @see Categorie::TYPE_PRODUCT + * @see Categorie::TYPE_SUPPLIER + * @see Categorie::TYPE_CUSTOMER + * @see Categorie::TYPE_MEMBER + * @see Categorie::TYPE_CONTACT + */ + var $type; var $import_key; var $cats=array(); // Tableau en memoire des categories var $motherof=array(); - /** * Constructor * @@ -477,11 +546,12 @@ class Categorie extends CommonObject } /** - * Link an object to the category + * Link an object to the category * - * @param Object $obj Object to link to category - * @param string $type Type of category ('societe', 'member', 'product', 'contact', 'fournisseur) - * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked + * @param CommonObject $obj Object to link to category + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') + * + * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) { @@ -492,28 +562,21 @@ class Categorie extends CommonObject if ($this->id == -1) return -2; // For backward compatibility - if ($type == 'company') $type='societe'; - elseif ($type == 'customer') $type='societe'; - elseif ($type == 'supplier') $type='fournisseur'; - - /** - * llx_categorie_contact => fk_socpeople - * llx_categorie_fournisseur, llx_categorie_societe => fk_soc - * llx_categorie_member => fk_member - * llx_categorie_product => fk_product - */ - if ($type == 'contact') { - $column_name = 'socpeople'; - } elseif ($type == 'fournisseur' || ($type == 'societe')) { - $column_name = 'soc'; - } else { - $column_name = $type; + if ($type == 'societe') { + $type = 'customer'; + dol_syslog( get_class( $this ) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead", + LOG_WARNING ); + } elseif ($type == 'fournisseur') { + $type = 'supplier'; + dol_syslog( get_class( $this ) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", + LOG_WARNING ); } $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$column_name.")"; - $sql .= " VALUES (".$this->id.", ".$obj->id.")"; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; + $sql .= " (fk_categorie, fk_" . $this->MAP_CAT_FK[$type] . ")"; + $sql .= " VALUES (" . $this->id . ", " . $obj->id . ")"; dol_syslog(get_class($this).'::add_type', LOG_DEBUG); if ($this->db->query($sql)) @@ -596,9 +659,10 @@ class Categorie extends CommonObject /** * Delete object from category * - * @param Object $obj Object - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @return int 1 if OK, -1 if KO + * @param CommonObject $obj Object + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') + * + * @return int 1 if OK, -1 if KO */ function del_type($obj,$type) { @@ -607,19 +671,21 @@ class Categorie extends CommonObject $error=0; // For backward compatibility - if ($type == 'company') $type='societe'; - if ($type == 'customer') $type='societe'; - if ($type == 'supplier') $type='fournisseur'; - - $column_name=$type; - if ($type=='contact') $column_name='socpeople'; - if ($type=='fournisseur') $column_name='societe'; + if ($type == 'societe') { + $type = 'customer'; + dol_syslog( get_class( $this ) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead", + LOG_WARNING ); + } elseif ($type == 'fournisseur') { + $type = 'supplier'; + dol_syslog( get_class( $this ) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", + LOG_WARNING ); + } $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type; - $sql .= " WHERE fk_categorie = ".$this->id; - $sql .= " AND fk_".$column_name." = ".$obj->id; + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; + $sql .= " WHERE fk_categorie = " . $this->id; + $sql .= " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) @@ -652,41 +718,32 @@ class Categorie extends CommonObject } /** - * Return list of fetched instance of elements having this category + * Return list of fetched instance of elements having this category * - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @return mixed -1 if KO, array of instance of object if OK + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') + * + * @return mixed -1 if KO, array of instance of object if OK */ function getObjectsInCateg($type) { - $field=''; $classname=''; $category_table=''; $object_table=''; - if ($type=='product') { $field='product'; $classname='Product'; } - if ($type=='customer') { $field='soc'; $classname='Societe'; $category_table='societe'; $object_table='societe'; } - if ($type=='supplier') { $field='soc'; $classname='Fournisseur'; $category_table='fournisseur'; $object_table='societe'; } - if ($type=='member') { $field='member'; $classname='Adherent'; $category_table=''; $object_table='adherent'; } - if ($type=='contact') { $field='socpeople'; $classname='Contact'; $category_table='contact'; $object_table='socpeople'; } - $objs = array(); - // Clean parameters - if (empty($category_table)) $category_table=$field; - if (empty($object_table)) $object_table=$field; + $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); - $sql = "SELECT c.fk_".$field; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$category_table." as c"; - $sql.= ", ".MAIN_DB_PREFIX.$object_table." as o"; - $sql.= " WHERE o.entity IN (".getEntity($field, 1).")"; + $sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type]; + $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c"; + $sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o"; + $sql .= " WHERE o.entity IN (" . getEntity( $obj->element, 1).")"; $sql.= " AND c.fk_categorie = ".$this->id; - $sql.= " AND c.fk_".$field." = o.rowid"; + $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ($rec = $this->db->fetch_array($resql)) - { - $obj = new $classname($this->db); - $obj->fetch($rec['fk_'.$field]); + while ($rec = $this->db->fetch_array($resql)) { + $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); + $obj->fetch( $rec['fk_' . $this->MAP_CAT_FK[$type]]); $objs[] = $obj; } return $objs; @@ -699,40 +756,17 @@ class Categorie extends CommonObject } /** - * check for the presence of an object in a category + * Check for the presence of an object in a category * - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param int $object_id id of the object to search - * @return int number of occurrences + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') + * @param int $object_id id of the object to search + * + * @return int number of occurrences */ - function containsObject($type, $object_id) + function containsObject($type, $object_id ) { - $field = ''; - $category_table = ''; - - if ($type == 'product') { - $field = 'product'; - } - if ($type == 'customer') { - $field = 'societe'; - } - if ($type == 'supplier') { - $field = 'societe'; - $category_table = 'fournisseur'; - } - if ($type == 'member') { - $field = 'member'; - $category_table = ''; - } - if ($type == 'contact') { - $field = 'socpeople'; - $category_table = 'contact'; - } - if (empty($category_table)) { - $category_table = $field; - } - $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $category_table; - $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $field . " = " . $object_id; + $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; + $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id; dol_syslog(get_class($this)."::containsObject", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -772,7 +806,6 @@ class Categorie extends CommonObject } } - /** * Load this->motherof that is array(id_son=>id_parent, ...) * @@ -808,23 +841,34 @@ class Categorie extends CommonObject } /** - * Reconstruit l'arborescence des categories sous la forme d'un tableau - * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: - * id = id de la categorie - * id_mere = id de la categorie mere - * id_children = tableau des id enfant - * label = nom de la categorie - * fulllabel = nom avec chemin complet de la categorie - * fullpath = chemin complet compose des id + * Reconstruit l'arborescence des categories sous la forme d'un tableau + * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: + * id = id de la categorie + * id_mere = id de la categorie mere + * id_children = tableau des id enfant + * label = nom de la categorie + * fulllabel = nom avec chemin complet de la categorie + * fullpath = chemin complet compose des id * - * @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) - * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. - * @return array Array of categories. this->cats and this->motherof are set. + * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member'). Old + * mode (0, 1, 2, ...) is deprecated. + * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. + * + * @return array Array of categories. this->cats and this->motherof are set. */ function get_full_arbo($type,$markafterid=0) { global $conf, $langs; + // For backward compatibility + if (is_numeric( $type )) { + // We want to reverse lookup + $map_type = array_flip( $this->MAP_ID ); + $type = $map_type[$type]; + dol_syslog( get_class( $this ) . "::get_full_arbo(): numeric types are deprecated, please use string instead", + LOG_WARNING ); + } + $this->cats = array(); // Init this->motherof that is array(id_son=>id_parent, ...) @@ -836,8 +880,8 @@ class Categorie extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'"; - $sql.= " WHERE c.entity IN (".getEntity('category',1).")"; - $sql.= " AND c.type = ".$type; + $sql .= " WHERE c.entity IN (" . getEntity( 'category', 1 ) . ")"; + $sql .= " AND c.type = " . $this->MAP_ID[$type]; dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1171,37 +1215,35 @@ class Categorie extends CommonObject } /** - * Return list of categories (id or instances) linked to element of id $id and type $type - * Should be named getListOfCategForObject + * Return list of categories (object instances or labels) linked to element of id $id and type $type + * Should be named getListOfCategForObject * - * @param int $id Id of element - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. - * @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category labels - * @return mixed Array of category objects or < 0 if KO + * @param int $id Id of element + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode + * (0, 1, 2, ...) is deprecated. + * @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category + * labels + * + * @return mixed Array of category objects or < 0 if KO */ function containing($id,$type,$mode='object') { $cats = array(); - $typeid=-1; $table=''; - if ($type == '0' || $type == 'product') { - $typeid=self::TYPE_PRODUCT; $table='product'; $type='product'; - } else if ($type == '1' || $type == 'supplier') { - $typeid=self::TYPE_SUPPLIER; $table='soc'; $type='fournisseur'; - } else if ($type == '2' || $type == 'customer') { - $typeid=self::TYPE_CUSTOMER; $table='soc'; $type='societe'; - } else if ($type == '3' || $type == 'member') { - $typeid=self::TYPE_MEMBER; $table='member'; $type='member'; - } else if ($type == '4' || $type == 'contact') { - $typeid=self::TYPE_CONTACT; $table='socpeople'; $type='contact'; + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + // We want to reverse lookup + $map_type = array_flip($this->MAP_ID); + $type = $map_type[$type]; } $sql = "SELECT ct.fk_categorie, c.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c"; - $sql.= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".$table." = ".$id." AND c.type = ".$typeid; - $sql.= " AND c.entity IN (".getEntity('category',1).")"; + $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c"; + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . $id . " AND c.type = " . $this->MAP_ID[$type]; + $sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")"; - dol_syslog(get_class($this).'::containing', LOG_DEBUG); $res = $this->db->query($sql); if ($res) { @@ -1241,19 +1283,26 @@ class Categorie extends CommonObject */ function rechercher($id, $nom, $type, $exact = false, $case = false) { + // Deprecation warning + if (is_numeric($type)) { + dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING); + } + $cats = array(); - $typeid=-1; - if ($type == 0 || $type == 'product') { $typeid=self::TYPE_PRODUCT; } - else if ($type == 1 || $type == 'supplier') { $typeid=self::TYPE_SUPPLIER; } - else if ($type == 2 || $type == 'customer') { $typeid=self::TYPE_CUSTOMER; } - else if ($type == 3 || $type == 'member') { $typeid=self::TYPE_MEMBER; } - else if ($type == 4 || $type == 'contact') { $typeid=self::TYPE_CONTACT; } + // For backward compatibility + if (is_numeric( $type )) { + // We want to reverse lookup + $map_type = array_flip( $this->MAP_ID ); + $type = $map_type; + dol_syslog( get_class( $this ) . "::rechercher(): numeric types are deprecated, please use string instead", + LOG_WARNING ); + } // Generation requete recherche - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type = ".$typeid; - $sql.= " AND entity IN (".getEntity('category',1).")"; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; + $sql .= " WHERE type = " . $this->MAP_ID[$type]; + $sql .= " AND entity IN (" . getEntity( 'category', 1 ) . ")"; if ($nom) { if (! $exact) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index c3acb807e01..a10823e6098 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -56,6 +56,9 @@ $object = new Categorie($db); $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + /* * Actions */ diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 36e6f53ecc3..87d6dc57d63 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -64,6 +64,9 @@ $type=$object->type; $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + /* * Actions */ diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index aa34c83523c..044cf9908ea 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent @@ -96,7 +96,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') { $idtoremove=GETPOST('removedassigned'); - if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1); + if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=json_decode($_SESSION['assignedtouser'],1); else $tmpassigneduserids=array(); foreach ($tmpassigneduserids as $key => $val) @@ -104,7 +104,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); } //var_dump($_POST['removedassigned']);exit; - $_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids); + $_SESSION['assignedtouser']=json_encode($tmpassigneduserids); $donotclearsession=1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; @@ -119,10 +119,10 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) $assignedtouser=array(); if (! empty($_SESSION['assignedtouser'])) { - $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); + $assignedtouser=json_decode($_SESSION['assignedtouser'], true); } $assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'),'mandatory'=>1); - $_SESSION['assignedtouser']=dol_json_encode($assignedtouser); + $_SESSION['assignedtouser']=json_encode($assignedtouser); } $donotclearsession=1; if ($action == 'add') $action = 'create'; @@ -151,7 +151,7 @@ if ($action == 'add') exit; } - $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):GETPOST("percentage"); // If status is -1 or 100, percentage is not defined and we must use status + $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters $datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); @@ -215,7 +215,7 @@ if ($action == 'add') $object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60; $listofuserid=array(); - if (! empty($_SESSION['assignedtouser'])) $listofuserid=dol_json_decode($_SESSION['assignedtouser']); + if (! empty($_SESSION['assignedtouser'])) $listofuserid=json_decode($_SESSION['assignedtouser'], true); $i=0; foreach($listofuserid as $key => $value) { @@ -387,7 +387,7 @@ if ($action == 'update') if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users { // Restore array with key with same value than param 'id' - $tmplist1=dol_json_decode($_SESSION['assignedtouser'], true); $tmplist2=array(); + $tmplist1=json_decode($_SESSION['assignedtouser'], true); $tmplist2=array(); foreach($tmplist1 as $key => $val) { if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val; @@ -671,19 +671,19 @@ if ($action == 'create') } // Assigned to - print ''.$langs->trans("ActionAffectedTo").''; + print ''.$langs->trans("ActionAffectedTo").''; $listofuserid=array(); if (empty($donotclearsession)) { $assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first - $_SESSION['assignedtouser']=dol_json_encode($listofuserid); + $_SESSION['assignedtouser']=json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=dol_json_decode($_SESSION['assignedtouser'], true); + $listofuserid=json_decode($_SESSION['assignedtouser'], true); } } print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0'); @@ -727,7 +727,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("ActionOnContact").''; - $form->select_contacts(GETPOST('socid','int'),GETPOST('contactid'),'contactid',1); + $form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200'); print ''; @@ -739,7 +739,7 @@ if ($action == 'create') // Projet associe $langs->load("projects"); - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid'); if ($numproject==0) @@ -768,7 +768,7 @@ if ($action == 'create') print ''; // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_6,90); $doleditor->Create(); @@ -915,7 +915,7 @@ if ($id > 0) } // Assigned to - print ''.$langs->trans("ActionAssignedTo").''; + print ''.$langs->trans("ActionAssignedTo").''; $listofuserid=array(); if (empty($donotclearsession)) { @@ -929,13 +929,13 @@ if ($id > 0) if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; } } - $_SESSION['assignedtouser']=dol_json_encode($listofuserid); + $_SESSION['assignedtouser']=json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=dol_json_decode($_SESSION['assignedtouser'], true); + $listofuserid=json_decode($_SESSION['assignedtouser'], true); } } print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0'); @@ -968,7 +968,7 @@ if ($id > 0) // Contact print ''.$langs->trans("Contact").''; - $form->select_contacts($object->socid, $object->contactid,'contactid',1); + $form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200'); print ''; } @@ -981,7 +981,7 @@ if ($id > 0) // Projet associe $langs->load("project"); - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; $numprojet=$formproject->select_projects($object->socid,$object->fk_project,'projectid'); if ($numprojet==0) { @@ -1004,7 +1004,7 @@ if ($id > 0) } // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,90); @@ -1101,13 +1101,13 @@ if ($id > 0) if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; } } - $_SESSION['assignedtouser']=dol_json_encode($listofuserid); + $_SESSION['assignedtouser']=json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=dol_json_decode($_SESSION['assignedtouser'], true); + $listofuserid=json_decode($_SESSION['assignedtouser'], true); } } print $form->select_dolusers_forevent('view','assignedtouser',1); @@ -1168,7 +1168,7 @@ if ($id > 0) // Project if (! empty($conf->projet->enabled)) { - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; if ($object->fk_project) { $project=new Project($db); @@ -1192,7 +1192,7 @@ if ($id > 0) } // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; print dol_htmlentitiesbr($object->note); print ''; @@ -1267,7 +1267,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' '; print ''."\n"; print '
'; print ''; @@ -1276,7 +1276,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -1285,7 +1285,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -1294,7 +1294,7 @@ if ($id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fb4c6f45d84..530083fb30a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -61,6 +61,7 @@ class ActionComm extends CommonObject /** * @var string * @deprecated Use $label + * @see label */ public $libelle; @@ -71,6 +72,7 @@ class ActionComm extends CommonObject * Object user that create action * @var User * @deprecated + * @see authorid */ var $author; @@ -78,6 +80,7 @@ class ActionComm extends CommonObject * Object user that modified action * @var User * @deprecated + * @see usermodid */ var $usermod; var $authorid; // Id user that create action @@ -114,6 +117,7 @@ class ActionComm extends CommonObject * Object user of owner * @var User * @deprecated + * @see userownerid */ var $usertodo; @@ -121,6 +125,7 @@ class ActionComm extends CommonObject * Object user that did action * @var User * @deprecated + * @see userdoneid */ var $userdone; @@ -130,12 +135,16 @@ class ActionComm extends CommonObject /** * Company linked to action (optional) * @var Societe|null + * @deprecated + * @see socid */ var $societe; /** * Contact linked to action (optional) * @var Contact|null + * @deprecated + * @see contactid */ var $contact; @@ -468,7 +477,7 @@ class ActionComm extends CommonObject $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; - $this->punctual = $obj->punctual; + $this->punctual = $obj->punctual; // deprecated $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->contactid = $obj->fk_contact; // To have fetch_contact method working diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 82d88089684..d45a18e3e8c 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Simon TOSSER @@ -143,7 +143,7 @@ if ($object->id > 0) print ''.$langs->trans("Title").''.$object->label.''; // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent).''; + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; // Date start print ''.$langs->trans("DateActionStart").''; @@ -186,13 +186,13 @@ if ($object->id > 0) if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; } } - $_SESSION['assignedtouser']=dol_json_encode($listofuserid); + $_SESSION['assignedtouser']=json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=dol_json_decode($_SESSION['assignedtouser'], true); + $listofuserid=json_decode($_SESSION['assignedtouser'], true); } } print $form->select_dolusers_forevent('view','assignedtouser',1); @@ -235,7 +235,7 @@ if ($object->id > 0) // Project if (! empty($conf->projet->enabled)) { - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; if ($object->fk_project) { $project=new Project($db); @@ -274,7 +274,7 @@ if ($object->id > 0) } - print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; print ''; @@ -294,7 +294,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' '; print ''."\n"; print '
'; print ''; @@ -303,7 +303,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -312,7 +312,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print '
'; print ''; @@ -321,7 +321,7 @@ if ($object->id > 0) print ''; print ''; //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' '; + print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' '; print '
'."\n"; print ''; diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php index c49881ba542..bfbcc9d4273 100644 --- a/htdocs/comm/askpricesupplier/card.php +++ b/htdocs/comm/askpricesupplier/card.php @@ -1709,10 +1709,12 @@ if ($action == 'create') $somethingshown = $formfile->show_documents('askpricesupplier', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - /* - * Linked object block - */ - $somethingshown = $object->showLinkedObjectBlock(); + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object); + //if ($linktoelem) print '
'.$linktoelem; print '
'; @@ -1736,8 +1738,8 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; // Define output language $outputlangs = $langs; @@ -1762,8 +1764,8 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } print '
'; diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index 2e39d8592cf..2854a0a0d4b 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -59,14 +59,42 @@ class AskPriceSupplier extends CommonObject var $client; // Objet societe client (a charger par fetch_client) var $fk_project; + /** + * @deprecated + * @see user_author_id + */ var $author; var $ref; var $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed) - var $datec; // Date of creation var $date; // Date of proposal var $date_livraison; + /** + * @deprecated + * @see date_creation + */ + var $datec; + + /** + * Creation date + * @var int + */ + public $date_creation; + + /** + * @deprecated + * @see date_validation + */ + var $datev; + + /** + * Validation date + * @var int + */ + public $date_validation; + + var $user_author_id; var $user_valid_id; var $user_close_id; @@ -76,9 +104,22 @@ class AskPriceSupplier extends CommonObject var $total_localtax1; // Total Local Taxes 1 var $total_localtax2; // Total Local Taxes 2 var $total_ttc; // Total with tax - var $price; // deprecated (for compatibility) - var $tva; // deprecated (for compatibility) - var $total; // deprecated (for compatibility) + + /** + * @deprecated + * @see price_ht + */ + var $price; + /** + * @deprecated + * @see total_tva + */ + var $tva; + /** + * @deprecated + * @see total_ttc + */ + var $total; var $cond_reglement_id; var $cond_reglement_code; @@ -88,7 +129,11 @@ class AskPriceSupplier extends CommonObject var $remise; var $remise_percent; var $remise_absolue; - var $note; // deprecated (for compatibility) + /** + * @deprecated + * @see note_public, note_private + */ + var $note; var $note_private; var $note_public; var $shipping_method_id; @@ -1031,7 +1076,7 @@ class AskPriceSupplier extends CommonObject $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO obsolete + $this->total = $obj->total; // TODO deprecated $this->total_ht = $obj->total_ht; $this->total_tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; @@ -1040,14 +1085,14 @@ class AskPriceSupplier extends CommonObject $this->socid = $obj->fk_soc; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; - $this->note = $obj->note_private; // TODO obsolete + $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->statut = $obj->fk_statut; $this->statut_libelle = $obj->statut_label; - $this->datec = $this->db->jdate($obj->datec); // TODO obsolete - $this->datev = $this->db->jdate($obj->datev); // TODO obsolete + $this->datec = $this->db->jdate($obj->datec); // TODO deprecated + $this->datev = $this->db->jdate($obj->datev); // TODO deprecated $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date $this->date_livraison = $this->db->jdate($obj->date_livraison); @@ -2431,7 +2476,17 @@ class AskPriceSupplierLine extends CommonObject var $fk_parent_line; var $desc; // Description ligne var $fk_product; // Id produit predefini - var $product_type = 0; // Type 0 = product, 1 = Service + /** + * @deprecated + * @see product_type + */ + var $fk_product_type; + /** + * Product type + * @var int + * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE + */ + public $product_type = Product::TYPE_PRODUCT; var $qty; var $tva_tx; @@ -2459,14 +2514,43 @@ class AskPriceSupplierLine extends CommonObject var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - // Ne plus utiliser + /** + * @deprecated + * @see remise_percent, fk_remise_except + */ var $remise; + /** + * @deprecated + * @see subprice + */ var $price; // From llx_product - var $ref; // Reference produit - var $libelle; // Label produit - var $product_desc; // Description produit + /** + * @deprecated + * @see product_ref + */ + var $ref; + /** + * Product reference + * @var string + */ + public $product_ref; + /** + * @deprecated + * @see product_label + */ + var $libelle; + /** + * Product label + * @var string + */ + public $product_label; + /** + * Product description + * @var string + */ + public $product_desc; var $localtax1_tx; // Local tax 1 var $localtax2_tx; // Local tax 2 diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index af9b7205d16..aba9433cabc 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -140,7 +141,7 @@ if (empty($reshook)) if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } - // update prospect level + // set communication status if ($action == 'setstcomm') { $object->fetch($id); @@ -468,6 +469,14 @@ if ($id > 0) print '
'; } + // Categories + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { + print '' . $langs->trans( "Categories" ) . ''; + print ''; + print $form->showCategories( $object->id, 'customer', 1 ); + print ""; + } + // Other attributes $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 69a3520d1e8..1df5a7ad18f 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -421,7 +421,7 @@ class Mailing extends CommonObject $resql=$this->db->query($sql); if ($resql) { - return 1; + return $this->delete_targets(); } else { @@ -429,6 +429,29 @@ class Mailing extends CommonObject return -1; } } + + /** + * Delete targets emailing + * + * @return int 1 if OK, 0 if error + */ + function delete_targets() + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.= " WHERE fk_mailing = ".$this->id; + + dol_syslog("Mailing::delete_targets", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + return 1; + } + else + { + $this->error=$this->db->lasterror(); + return 0; + } + } /** diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5be006c0053..8cd48a75f40 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; @@ -305,7 +306,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -331,7 +333,8 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); @@ -640,7 +643,6 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - // Go back to draft if ($action == 'modif' && $user->rights->propal->creer) { @@ -1257,6 +1259,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); $companystatic = new Societe($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1341,7 +1344,7 @@ if ($action == 'create') print ''; // Reference - print ''; + print ''; // Ref customer print ''; - // Model - print ''; - print ''; - print '"; + // Project + if (! empty($conf->projet->enabled) && $socid > 0) + { + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); + + $langs->load("projects"); + print ''; + print ''; + print ''; + } // Incoterms if (!empty($conf->incoterm->enabled)) @@ -1463,25 +1473,41 @@ if ($action == 'create') print ''; } - // Project - if (! empty($conf->projet->enabled) && $socid > 0) + // Template to use by default + print ''; + print ''; + print '"; + + // Public note + print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ' + print ''; } // Other attributes @@ -2281,10 +2307,13 @@ if ($action == 'create') $somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - /* - * Linked object block - */ - $somethingshown = $object->showLinkedObjectBlock(); + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object); + if ($linktoelem) print '
'.$linktoelem; + print '
'; // print '
"; print ''; - // Ligne info remises tiers + // Discounts print ''; - // Prospect levelt + // Prospect level print ''; print ''; print ''; // Print the search button @@ -407,10 +413,6 @@ if ($resql) $i = 0; $var=true; - $prospectstatic=new Client($db); - $prospectstatic->client=2; - $prospectstatic->loadCacheOfProspStatus(); - while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/commande/apercu.php b/htdocs/commande/apercu.php index e6878eef179..f3d83b837dd 100644 --- a/htdocs/commande/apercu.php +++ b/htdocs/commande/apercu.php @@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Si fichier detail PDF existe - // TODO obsolete ? + // TODO deprecated ? if (file_exists($filedetail)) { print ""; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 4b7d0104ec9..79f752f8355 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011 Philippe Grand @@ -1214,6 +1214,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } /** * ******************************************************************* @@ -1320,7 +1321,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; @@ -1445,13 +1448,20 @@ if ($action == 'create') } print '
' . $langs->trans("DefaultModel") . ''; - $liste = ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); - print "
' . $langs->trans("Project") . ''; + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print '   id).'">' . $langs->trans("AddProject") . ''; + print '
' . $langs->trans("DefaultModel") . ''; + $liste = ModelePDFPropales::liste_modeles($db); + print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); + print "
' . $langs->trans('NotePublic') . ''; + $note_public = ''; + if (is_object($objectsrc)) // Take value from source object { - $formproject = new FormProjets($db); - - $projectid = 0; - if ($origin == 'project') - $projectid = ($originid ? $originid : 0); + $note_public = $objectsrc->note_public; + } + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // Private note + if (empty($user->societe_id)) + { print '
' . $langs->trans("Project") . ''; - - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - if ($numprojet == 0) { - $langs->load("projects"); - print '   ' . $langs->trans("AddProject") . ''; + print '' . $langs->trans('NotePrivate') . ''; + $note_private = ''; + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object + { + $note_private = $objectsrc->note_private; } - print '
'; @@ -2311,8 +2340,8 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; // Define output language $outputlangs = $langs; @@ -2336,8 +2365,8 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } print '
'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index af46db14d9a..b80b96654c1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -75,26 +75,35 @@ class Propal extends CommonObject /** * Status of the quote - * Check the following constants: - * - STATUS_DRAFT - * - STATUS_VALIDATED - * - STATUS_SIGNED - * - STATUS_NOTSIGNED - * - STATUS_BILLED * @var int + * @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED */ var $statut; /** - * Date of creation - * @var + * @deprecated + * @see date_creation */ var $datec; + /** - * Date of validation - * @var + * Creation date + * @var int + */ + public $date_creation; + + /** + * @deprecated + * @see date_validation */ var $datev; + + /** + * Validation date + * @var int + */ + public $date_validation; + /** * Date of the quote * @var @@ -102,8 +111,8 @@ class Propal extends CommonObject var $date; /** - * Same than date ¿? - * @var + * @deprecated + * @see date */ var $datep; var $date_livraison; @@ -121,14 +130,17 @@ class Propal extends CommonObject /** * @deprecated + * @see total_ht */ var $price; /** * @deprecated + * @see total_tva */ var $tva; /** * @deprecated + * @see total_ttc */ var $total; @@ -142,6 +154,7 @@ class Propal extends CommonObject var $remise_absolue; /** * @deprecated + * @see note_private, note_public */ var $note; var $note_private; @@ -1048,8 +1061,10 @@ class Propal extends CommonObject */ function createFromClone($socid=0) { - global $user,$langs,$conf,$hookmanager; - + global $db, $user,$langs,$conf,$hookmanager; + + dol_include_once('/projet/class.project.class.php'); + $this->context['createfromclone']='createfromclone'; $error=0; @@ -1074,7 +1089,16 @@ class Propal extends CommonObject $this->socid = $objsoc->id; $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; + + $project = new Project($db); + + if($objFrom->fk_project > 0 && $project->fetch($objFrom->fk_project)) { + if($project->socid <= 0) $this->fk_project = $objFrom->fk_project; + else $this->fk_project = ''; + } else { + $this->fk_project = ''; + } + $this->fk_delivery_address = ''; } @@ -1222,7 +1246,7 @@ class Propal extends CommonObject $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO obsolete + $this->total = $obj->total; // TODO deprecated $this->total_ht = $obj->total_ht; $this->total_tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; @@ -1231,14 +1255,14 @@ class Propal extends CommonObject $this->socid = $obj->fk_soc; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; - $this->note = $obj->note_private; // TODO obsolete + $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->statut = $obj->fk_statut; $this->statut_libelle = $obj->statut_label; - $this->datec = $this->db->jdate($obj->datec); // TODO obsolete - $this->datev = $this->db->jdate($obj->datev); // TODO obsolete + $this->datec = $this->db->jdate($obj->datec); // TODO deprecated + $this->datev = $this->db->jdate($obj->datev); // TODO deprecated $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date $this->date = $this->db->jdate($obj->dp); // Proposal date @@ -1967,9 +1991,12 @@ class Propal extends CommonObject * * @return int <0 si ko, >0 si ok * @deprecated + * @see classifyBilled() */ function classer_facturee() { + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + return $this->classifyBilled(); } @@ -2724,7 +2751,7 @@ class Propal extends CommonObject * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link - * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $option Where point the link ('expedition', 'document', ...) * @param string $get_params Parametres added to url * @return string String with URL */ @@ -2912,17 +2939,19 @@ class PropaleLigne extends CommonObjectLine var $oldline; // From llx_propaldet - var $rowid; var $fk_propal; var $fk_parent_line; var $desc; // Description ligne var $fk_product; // Id produit predefini + /** + * @deprecated + * @see product_type + */ + var $fk_product_type; /** * Product type. - * Use the following constants: - * - Product::TYPE_PRODUCT - * - Product::TYPE_SERVICE * @var int + * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE */ var $product_type = Product::TYPE_PRODUCT; @@ -2952,14 +2981,43 @@ class PropaleLigne extends CommonObjectLine var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - // Ne plus utiliser + /** + * @deprecated + * @see $remise_percent, $fk_remise_except + */ var $remise; + /** + * @deprecated + * @see subprice + */ var $price; // From llx_product - var $ref; // Reference produit - var $libelle; // Label produit - var $product_desc; // Description produit + /** + * @deprecated + * @see product_ref + */ + var $ref; + /** + * Product reference + * @var string + */ + public $product_ref; + /** + * @deprecated + * @see product_label + */ + var $libelle; + /** + * Product label + * @var string + */ + public $product_label; + /** + * Product description + * @var string + */ + public $product_desc; var $localtax1_tx; // Local tax 1 var $localtax2_tx; // Local tax 2 @@ -3007,7 +3065,8 @@ class PropaleLigne extends CommonObjectLine { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; + $this->id = $objp->rowid; + $this->rowid = $objp->rowid; // deprecated $this->fk_propal = $objp->fk_propal; $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; @@ -3016,7 +3075,7 @@ class PropaleLigne extends CommonObjectLine $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; + $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index d224c20bc97..af603d0606b 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load('compta'); $langs->load('other'); +$langs->load('companies'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 9fbdb2ffd7e..c8e96919f84 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -56,6 +56,7 @@ $search_refcustomer=GETPOST('search_refcustomer','alpha'); $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_author=GETPOST('search_author','alpha'); +$search_product_category=GETPOST('search_product_category','int'); $search_town=GETPOST('search_town','alpha'); $viewstatut=$db->escape(GETPOST('viewstatut')); $object_statut=$db->escape(GETPOST('propal_statut')); @@ -91,6 +92,7 @@ if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both $search_societe=''; $search_montant_ht=''; $search_author=''; + $search_product_category=''; $search_town=''; $year=''; $month=''; @@ -145,14 +147,15 @@ if (! $sortorder) $sortorder='DESC'; $limit = $conf->liste_limit; -if (! $sall) $sql = 'SELECT'; -else $sql = 'SELECT DISTINCT'; +$sql = 'SELECT'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid, s.nom as name, s.town, s.client, s.code_client,'; $sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; -if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -190,7 +193,8 @@ if ($search_montant_ht != '') if ($sall) { $sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall); } -if ($socid) $sql.= ' AND s.rowid = '.$socid; +if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($viewstatut <> '') { $sql.= ' AND p.fk_statut IN ('.$viewstatut.')'; @@ -223,7 +227,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - +//print $sql; $sql.= $db->plimit($limit + 1,$offset); $result=$db->query($sql); @@ -265,15 +269,28 @@ if ($result) if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); - $moreforfilter.='       '; + $moreforfilter.='
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.='
'; + } + // If the user can view prospects other than his' + if ($conf->categorie->enabled && $user->rights->produit->lire) + { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.='
'; } if (! empty($moreforfilter)) { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 05cd2db3f04..1e5ace7353e 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; $langs->load('propal'); $langs->load('compta'); $langs->load('bills'); +$langs->load("companies"); $id = GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -103,7 +104,7 @@ if ($id > 0 || ! empty($ref)) print "
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$langs->trans('Discounts').''; if ($societe->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_percent); else print $langs->trans("CompanyHasNoRelativeDiscount"); diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index e807b3fcbc4..80ef52a372a 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -204,6 +204,9 @@ if (empty($reshook)) $formother=new FormOther($db); $form=new Form($db); +$prospectstatic=new Client($db); +$prospectstatic->client=2; +$prospectstatic->loadCacheOfProspStatus(); $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.datec, s.status as status, s.code_client, s.client,"; $sql.= " s.prefix_comm, s.fk_prospectlevel, s.fk_stcomm as stcomm_id,"; @@ -353,7 +356,7 @@ if ($resql) print ''; print ''; $options_from = ''; // Generate in $options_from the list of each option sorted foreach ($tab_level as $tab_level_sortorder => $tab_level_label) @@ -380,9 +383,12 @@ if ($resql) // Prospect status print ''; - // TODO Add here a list of prospect status - //print $form->selectarray($htmlname, $array, $search_stcomm); - //print ' '; + $arraystcomm=array(); + foreach($prospectstatic->cacheprospectstatus as $key => $val) + { + $arraystcomm[$val['id']]=$val['label']; + } + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, 1); print ''; @@ -390,7 +396,7 @@ if ($resql) print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print '
Commande detaillee
'; // Reference - print ''; + print ''; // Reference client print ''; + print ''; + print '   id).'">' . $langs->trans("AddProject") . ''; + print ''; + print ''; } // Incoterms @@ -1458,29 +1461,30 @@ if ($action == 'create' && $user->rights->commande->creer) print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print ""; - // Note publique + // Note public print ''; print ''; print ''; - // Note privee + // Note private if (empty($user->societe_id)) { print ''; print ''; print ''; } - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + { // TODO for compatibility if ($origin == 'contrat') { // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva @@ -1514,8 +1518,11 @@ if ($action == 'create' && $user->rights->commande->creer) } print '"; - } else { - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { + } + else + { + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { /* * Services/produits predefinis */ @@ -2298,10 +2305,13 @@ if ($action == 'create' && $user->rights->commande->creer) $delallowed = $user->rights->commande->supprimer; $somethingshown = $formfile->show_documents('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - /* - * Linked object block - */ - $somethingshown = $object->showLinkedObjectBlock(); + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object); + //if ($linktoelem) print '
'.$linktoelem; + print '
'; // print '
\n"; print "\n"; print ''; print ''; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index dc2d281e2a1..f09875456c2 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -44,7 +44,11 @@ class Deplacement extends CommonObject var $fk_user_author; var $fk_user; var $km; - var $note; // TODO obsolete + /** + * @deprecated + * @see note_private, note_public + */ + var $note; // TODO deprecated var $note_private; var $note_public; var $socid; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 88d6bb587e4..a461d1b9c82 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3,7 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel @@ -1759,10 +1759,8 @@ if (empty($reshook)) $upload_dir = $conf->facture->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); $action = ''; } } @@ -1856,6 +1854,8 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $bankaccountstatic = new Account($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } + $now = dol_now(); llxHeader('', $langs->trans('Bill'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); @@ -2082,22 +2082,21 @@ if ($action == 'create') } print ''; if ($socid > 0) @@ -2295,12 +2292,15 @@ if ($action == 'create') print ''; // Project - if (! empty($conf->projet->enabled) && $socid > 0) { - $formproject = new FormProjets($db); + if (! empty($conf->projet->enabled) && $socid > 0) + { + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); $langs->load('projects'); print ''; } @@ -2322,7 +2322,7 @@ if ($action == 'create') print $object->showOptionals($extrafields, 'edit'); } - // Modele PDF + // Template to use by default print ''; print ''; @@ -2420,7 +2420,9 @@ if ($action == 'create') print '"; } print '"; - } else { + } + else + { // Show deprecated optional form to add product line here if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { print ''; - print ''; - print ''; - print ''; - print ''; + if ($object->situation_cycle_ref && $object->statut == 0) { + print ''; + print ''; + print ''; + print ''; + print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - print ''; - print ''; - print ''; - if ($inputalsopricewithtax) print ''; - print ''; - print ''; - print ''; - if (! empty($conf->margin->enabled) && empty($user->societe_id)) - { - print ''; - if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { - print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; } - } - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + if ($inputalsopricewithtax) print ''; + print ''; + print ''; + print ''; + if (! empty($conf->margin->enabled) && empty($user->societe_id)) + { + print ''; + if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { + print ''; + } + } + print ''; + print ''; + print ''; + print ''; + print "\n"; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } } // Show object lines @@ -3754,7 +3756,7 @@ if ($action == 'create') } print '
'; - //Select mail models is same action as presend + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } @@ -3774,77 +3776,10 @@ if ($action == 'create') $somethingshown = $formfile->numoffiles; // Linked object block - $somethingshown = $object->showLinkedObjectBlock(); + $somethingshown = $form->showLinkedObjectBlock($object); - $linktoelem=''; - - if (! empty($conf->commande->enabled)) - { - $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedOrder') . ''; - - print ' - - '; - - print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; @@ -1422,14 +1423,16 @@ if ($action == 'create' && $user->rights->commande->creer) // Project if (! empty($conf->projet->enabled) && $socid > 0) { - $formproject = new FormProjets($db); + $projectid = GETPOST('projectid')?GETPOST('projectid'):0; + if ($origin == 'project') $projectid = ($originid ? $originid : 0); - print '
' . $langs->trans('Project') . ''; + $langs->load("projects"); + print '
' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - if ($numprojet == 0) { - print '   ' . $langs->trans("AddProject") . ''; - } - print '
' . $langs->trans('NotePublic') . ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print '
' . $langs->trans('NotePrivate') . ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print '
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
'; @@ -2324,8 +2334,7 @@ if ($action == 'create' && $user->rights->commande->creer) $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $file = $fileparams['fullname']; // Define output language $outputlangs = $langs; @@ -2349,8 +2358,8 @@ if ($action == 'create' && $user->rights->commande->creer) dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } print '
'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 18c8b554637..c941dfc1ff8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -74,17 +74,15 @@ class Commande extends CommonOrder /** * Status of the order. Check the following constants: - * - STATUS_CANCELED - * - STATUS_DRAFT - * - STATUS_ACCEPTED - * - STATUS_CLOSED * @var int + * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED */ var $statut; /** * @deprecated + * @see billed */ - var $facturee; // deprecated + var $facturee; var $billed; // billed or not var $brouillon; @@ -100,7 +98,11 @@ class Commande extends CommonOrder var $fk_delivery_address; var $address; var $date; // Date commande - var $date_commande; // Date commande (deprecated) + /** + * @deprecated + * @see date + */ + var $date_commande; var $date_livraison; // Date livraison souhaitee var $shipping_method_id; var $fk_remise_except; @@ -116,7 +118,11 @@ class Commande extends CommonOrder var $rang; var $special_code; var $source; // Origin of order - var $note; // deprecated + /** + * @deprecated + * @see note_private, note_public + */ + var $note; var $note_private; var $note_public; var $extraparams=array(); @@ -1033,7 +1039,9 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $conf,$user,$langs,$hookmanager; + global $db, $conf,$user,$langs,$hookmanager; + + dol_include_once('/core/class/extrafields.class.php'); $error=0; @@ -1104,9 +1112,15 @@ class Commande extends CommonOrder // get extrafields from original line $object->fetch_optionals($object->id); - foreach($object->array_options as $options_key => $value) - $this->array_options[$options_key] = $value; - + + $e = new ExtraFields($db); + $element_extrafields = $e->fetch_name_optionals_label($this->element); + + foreach($object->array_options as $options_key => $value) { + if(array_key_exists(str_replace('options_', '', $options_key), $element_extrafields)){ + $this->array_options[$options_key] = $value; + } + } // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) @@ -1728,6 +1742,7 @@ class Commande extends CommonOrder $i++; } + $this->db->free($result); return 1; @@ -1776,7 +1791,7 @@ class Commande extends CommonOrder * @param int $filtre_statut Filter on status * @return int <0 if KO, Nb of lines found if OK * - * TODO deprecated, move to Shipping class + * TODO deprecate, move to Shipping class */ function loadExpeditions($filtre_statut=-1) { @@ -1823,7 +1838,7 @@ class Commande extends CommonOrder * * @return int Nb of shipments * - * TODO deprecated, move to Shipping class + * TODO deprecate, move to Shipping class */ function nb_expedition() { @@ -1849,7 +1864,7 @@ class Commande extends CommonOrder * @param int $filtre_statut Filtre sur statut * @return int 0 si OK, <0 si KO * - * TODO deprecated, move to Shipping class + * TODO deprecate, move to Shipping class */ function livraison_array($filtre_statut=self::STATUS_CANCELED) { @@ -2399,9 +2414,12 @@ class Commande extends CommonOrder * * @return int <0 if ko, >0 if ok * @deprecated + * @see classifyBilled() */ function classer_facturee() { + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + return $this->classifyBilled(); } @@ -3346,6 +3364,7 @@ class OrderLine extends CommonOrderLine * Id of parent order * @var int * @deprecated Use fk_commande + * @see fk_commande */ public $commande_id; @@ -3367,6 +3386,7 @@ class OrderLine extends CommonOrderLine /** * @deprecated + * @see remise_percent, fk_remise_except */ var $remise; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c8badb1a880..f336cefda98 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -41,6 +41,7 @@ class Account extends CommonObject /** * @var int Use id instead of rowid * @deprecated + * @see id */ var $rowid; var $id; @@ -240,6 +241,11 @@ class Account extends CommonObject */ function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='') { + // Deprecatîon warning + if (is_numeric($oper)) { + dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); + } + // Clean parameters $emetteur=trim($emetteur); $banque=trim($banque); diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 08a76512cf4..d81390a0205 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García @@ -177,7 +177,7 @@ $form->select_comptes($account_to,'account_to',0,'',1); print "
"; -$form->select_date($dateo,'','','','','add'); +$form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "
' . $langs->trans('Type') . ''; - print '' . "\n"; + + print '
' . "\n"; // Standard invoice - print '
' . "\n"; + print ''; if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { // Deposit - print '' . "\n"; + + print ''; } if ($socid > 0) { if (! empty($conf->global->INVOICE_USE_SITUATION)) { - // First situation invoice - print '' . "\n"; + // First situation invoice + print '
'; + $tmp=' '; + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; - // Next situation invoice - $opt = $form->load_situation_invoices(GETPOST('originid'), $socid); - print '' . "\n"; + // Next situation invoice + $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); + print '
'; + $tmp='' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled'; + $tmp.= '> '; + $text = $tmp.$langs->trans("InvoiceSituationAsk") . ' '; + $text .= ''; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; } // Replacement - print '' . "\n"; + print ''; } else { - print '' . "\n"; + print ''; } if (empty($origin)) @@ -2193,12 +2192,10 @@ if ($action == 'create') if ($socid > 0) { // Credit note - print '' . "\n"; + print ''; } else { - print '' . "\n"; + print '' . "\n"; } } - print '
'; - print ''; - print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); + print '
'; + $tmp=' '; + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' '; print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1); - print ''; - if (($origin == 'propal') || ($origin == 'commande')) { + + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); + print '
' . $desc . '
'; + if (($origin == 'propal') || ($origin == 'commande')) + { print '
'; + print $desc; + print ''; $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); @@ -2115,44 +2118,41 @@ if ($action == 'create') print '' . $langs->trans('Value') . ':'; } print '
'; - print '
'; - print ''; - print ''; - $desc = $form->textwithpicto($langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1); - print $desc; - print '
'; - print '' . $langs->trans('NoSituations') . '' || (GETPOST('origin') && GETPOST('origin') != 'facture')) print 'disabled'; - print '>'; - print ''; - $text = $langs->trans("InvoiceSituationAsk") . ' '; - $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1); - print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' jQuery(document).ready(function() { jQuery("#fac_replacement").change(function() { @@ -2160,7 +2160,7 @@ if ($action == 'create') }); }); '; - $text = $langs->trans("InvoiceReplacementAsk") . ' '; + $text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' '; $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; - $text = $langs->trans("InvoiceReplacement") . ' '; + print '
'; + $tmp=' '; + $text = $tmp.$langs->trans("InvoiceReplacement") . ' '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print ''; - print ''; + print '
'; + $tmp=' jQuery(document).ready(function() { @@ -2214,7 +2211,7 @@ if ($action == 'create') }); }); '; - $text = $langs->transnoentities("InvoiceAvoirAsk") . ' '; + $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; // $text.=''; $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -2235,22 +2232,22 @@ if ($action == 'create') print '
    0 ? 'checked':'').' /> "; print '
'; - print '
'; - print ''; - print ''; - $text = $langs->trans("InvoiceAvoir") . ' '; + print '
'; + $tmp=' '; + $text = $tmp.$langs->trans("InvoiceAvoir") . ' '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; + print ''; + print '
' . $langs->trans('Project') . ''; - $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print '   id).'">' . $langs->trans("AddProject") . ''; print '
' . $langs->trans('Model') . ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; @@ -2339,7 +2339,7 @@ if ($action == 'create') { $note_public = $objectsrc->note_public; } - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // Private note @@ -2353,7 +2353,7 @@ if ($action == 'create') { $note_private = $objectsrc->note_private; } - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ' print '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
'; @@ -2479,7 +2481,7 @@ if ($action == 'create') // Button "Create Draft" print '
'; print ''; - print '     '; + print '     '; print ''; print '
'; @@ -3488,50 +3490,50 @@ if ($action == 'create') // Show global modifiers if (! empty($conf->global->INVOICE_US_SITUATION)) { - if ($object->situation_cycle_ref && $object->statut == 0) { - print '
 ' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '       
' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '      
  
     %
     %
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - while ($i < $num) - { - $objp = $db->fetch_object($resqlorderlist); - if ($objp->socid == $soc->id) { - $var = ! $var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - $i ++; - } - print '
' . $langs->trans("Ref") . '' . $langs->trans("RefCustomer") . '' . $langs->trans("AmountHTShort") . '' . $langs->trans("Company") . '
'; - print ''; - print '' . $objp->ref . '' . $objp->ref_client . '' . price($objp->total_ht) . '' . $objp->name . '
'; - print '
 
'; - print ''; - $db->free($resqlorderlist); - } else { - dol_print_error($db); - } - - print '
'; - } - - // Show link to elements + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print '
'.$linktoelem; // Link for paypal payment @@ -3886,8 +3821,8 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; // Define output language $outputlangs = $langs; @@ -3911,14 +3846,16 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/')); - $file = $fileparams ['fullname']; + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; } print '
'; print_titre($langs->trans($titreform)); // Cree l'objet formulaire mail + dol_fiche_head(); + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); @@ -3990,7 +3927,7 @@ if ($action == 'create') print $formmail->get_form(); - print '
'; + dol_fiche_end(); } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a347ccdbca8..fc3d8936edf 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -92,18 +92,16 @@ class Facture extends CommonInvoice var $revenuestamp; /** * @deprecated + * @see note_private, note_public */ var $note; var $note_private; var $note_public; /** - * Check constants for more info: - * - STATUS_DRAFT - * - STATUS_VALIDATED - * - STATUS_PAID - * - STATUS_ABANDONED + * Invoice status * @var int + * @see Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_PAID, Facture::STATUS_ABANDONED */ var $statut; //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon @@ -131,6 +129,9 @@ class Facture extends CommonInvoice * @deprecated */ var $products=array(); + /** + * @var FactureLigne[] + */ var $lines=array(); var $line; var $extraparams=array(); @@ -1119,7 +1120,8 @@ class Facture extends CommonInvoice $objp = $this->db->fetch_object($result); $line = new FactureLigne($this->db); - $line->rowid = $objp->rowid; + $line->id = $objp->rowid; + $line->rowid = $objp->rowid; // deprecated $line->label = $objp->custom_label; // deprecated $line->desc = $objp->description; // Description line $line->product_type = $objp->product_type; // Type of line @@ -2105,6 +2107,11 @@ class Facture extends CommonInvoice */ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null) { + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + } + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::addline facid=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); @@ -2289,6 +2296,11 @@ class Facture extends CommonInvoice */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null) { + // Deprecation warning + if ($label) { + dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + } + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; global $mysoc; @@ -3203,7 +3215,7 @@ class Facture extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; $response->label=$langs->trans("CustomerBillsUnpaid"); - $response->url=DOL_URL_ROOT.'/compta/facture/impayees.php'; + $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1'; $response->img=img_object($langs->trans("Bills"),"bill"); while ($obj=$this->db->fetch_object($resql)) @@ -3685,7 +3697,10 @@ class FactureLigne extends CommonInvoiceLine var $fk_facture; //! Id parent line var $fk_parent_line; - var $label; // deprecated + /** + * @deprecated + */ + var $label; //! Description ligne var $desc; @@ -3717,8 +3732,16 @@ class FactureLigne extends CommonInvoiceLine //var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) // From llx_product + /** + * @deprecated + * @see product_ref + */ var $ref; // Product ref (deprecated) var $product_ref; // Product ref + /** + * @deprecated + * @see product_label + */ var $libelle; // Product label (deprecated) var $product_label; // Product label var $product_desc; // Description produit diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 4028849b5fa..5d8d22cfa9d 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -84,6 +84,8 @@ class FactureStats extends Stats $this->where.=" AND f.fk_soc = ".$this->socid; } if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2)"; + else $this->where.= " AND f.type IN (0,1,2,3)"; } @@ -206,7 +208,7 @@ class FactureStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; $sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year,1,false))."' AND '".$this->db->idate(dol_get_last_day($year,12,false))."'"; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 60c47564743..e4f9846309a 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -37,6 +37,7 @@ $langs->load('propal'); $langs->load('compta'); $langs->load('other'); $langs->load("bills"); +$langs->load('companies'); $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6c82dcd4d8a..2668f0f1af6 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -2,10 +2,11 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -128,6 +129,8 @@ if ($action == 'create') print ''; print ''; print ''; + + dol_fiche_head(); $rowspan=4; if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++; @@ -139,7 +142,7 @@ if ($action == 'create') // Third party print ''.$langs->trans("Customer").''.$object->client->getNomUrl(1,'customer').''; print ''; - //print $langs->trans("NotePrivate"); + print $langs->trans("Comment"); print ''; // Title @@ -371,10 +374,15 @@ if ($action == 'create') print ''; print ''; } - print '
'; - print "\n"; print "\n"; + dol_fiche_end(); + + print '
'; + print '     '; + print ''; + print '
'; + print "\n"; } else { @@ -432,7 +440,7 @@ else $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none'); print ""; - print ''.$langs->trans("Note").''.nl2br($object->note_private).""; + print ''.$langs->trans("Comment").''.nl2br($object->note_private).""; print ""; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 08a14b75602..a68ed8ef903 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Ferran Marcet * * 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 @@ -88,6 +89,9 @@ $search_sale = GETPOST('search_sale','int'); $day = GETPOST('day','int'); $month = GETPOST('month','int'); $year = GETPOST('year','int'); +$day_lim = GETPOST('day_lim','int'); +$month_lim = GETPOST('month_lim','int'); +$year_lim = GETPOST('year_lim','int'); $filtre = GETPOST('filtre'); // Security check @@ -213,6 +217,19 @@ else if ($year > 0) { $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +if ($month_lim > 0) +{ + if ($year_lim > 0 && empty($day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'"; + else if ($year_lim > 0 && ! empty($day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; + else + $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$month_lim."'"; +} +else if ($year_lim > 0) +{ + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; +} if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { @@ -322,7 +339,11 @@ if ($resql) print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); + print ''; print ''; print ''; print ' '; diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index ff1bde24466..146ee53736c 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -275,7 +275,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s { $arrayofinclusion=array(); foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/'); - $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC); + $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); // liste les fichiers $files = array(); @@ -284,7 +284,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s { foreach($factures as $facture) { - if(strstr($facture["name"],$basename)) + if (strstr($facture["name"],$basename)) { $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 6954ad46249..0e1763d4b86 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -36,6 +36,7 @@ if (!$user->rights->facture->lire) accessforbidden(); $langs->load("bills"); $langs->load("banks"); $langs->load("withdrawals"); +$langs->load('companies'); $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $ref=GETPOST('ref','alpha'); @@ -396,7 +397,7 @@ if ($object->id > 0) } print ""; print ''; - + // Montants print ''.$langs->trans('AmountHT').''; print ''.price($object->total_ht).''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 3d3a8ab2197..11296bda93e 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -775,7 +775,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $i = 0; print ''; - print ''; + print ''; if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 90d6cbe8599..31eaf4375c3 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -109,7 +109,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec"); + $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 612014ac741..7396c625165 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -129,7 +129,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode"); - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec"); + $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $prevyear=$year_start; $prevquarter=$q; @@ -161,7 +161,7 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice if ($conf->global->$calc==2) // Invoice for goods, payment for services { $nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode"); - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec"); + $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $prevyear=$year_start; $prevquarter=$q; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 58865c38540..98fe402266c 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -6,7 +6,7 @@ * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2014 Raphaël Doursenaud - * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * * 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 @@ -403,6 +403,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(); + print '
'.$langs->trans("BillsCustomersUnpaid",$num).' '.$num.'
'.$langs->trans("BillsCustomersUnpaid",$num).' '.$num.''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").'
'; // Third party @@ -462,6 +464,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; + dol_fiche_end(); + /* * List of unpaid invoices */ diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 077bbde2420..60d669fcacf 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -40,7 +40,16 @@ class Paiement extends CommonObject var $ref; var $facid; var $datepaye; - var $total; // deprecated + /** + * @deprecated + * @see amount, amounts + */ + var $total; + /** + * @deprecated + * @see amount, amounts + */ + var $montant; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts var $author; diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php new file mode 100644 index 00000000000..71f10388ace --- /dev/null +++ b/htdocs/compta/salaries/document.php @@ -0,0 +1,136 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/compta/salaries/document.php + * \ingroup salaries + * \brief Page of linked files onto salaries + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; + +$langs->load("other"); +$langs->load("salaries"); +$langs->load("companies"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'salaries', $id, ''); + + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new PaymentSalary($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); +$modulepart='salaries'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + + +/* + * View + */ + +$form = new Form($db); + +llxHeader("","",$langs->trans("SalaryPayment")); + + +if ($object->id) +{ + $object->fetch_thirdparty(); + + $head=salaries_prepare_head($object); + + dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), 0, 'payment'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Societe + //print ""; + + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); + print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + $modulepart = 'salaries'; + $permission = $user->rights->salaries->write; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + +} +else +{ + print $langs->trans("ErrorUnknown"); +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 740f6f3bf5e..4d638e23cf7 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -501,7 +501,7 @@ if ($id > 0) } // Emettre paiement - if ($object->paye == 0 && ((price2num($object->amount) < 0 && round($resteapayer) < 0) || (price2num($object->amount) > 0 && round($resteapayer) > 0)) && $user->rights->tax->charges->creer) + if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) { print "id&action=create\">".$langs->trans("DoPayment").""; } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index d58e0add8ab..45b2c51acfa 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -40,6 +40,11 @@ class PaymentSocialContribution extends CommonObject var $datec=''; var $tms=''; var $datep=''; + /** + * @deprecated + * @see amount + */ + var $total; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts var $fk_typepaiement; diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 9e6624dda72..ad628fd6574 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -51,6 +51,8 @@ abstract class ActionsContactCardCommon */ private function getInstanceDao() { + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + if (! is_object($this->object)) { $modelclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php'); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 3d75c4a2036..e39c5502b4d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $langs->load("companies"); $langs->load("users"); $langs->load("other"); @@ -201,7 +202,11 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); - if ($ret < 0) $error++; + if ($ret < 0) + { + $error++; + $action = 'create'; + } if (! GETPOST("lastname")) { @@ -216,7 +221,17 @@ if (empty($reshook)) { $error++; $errors=array_merge($errors,($object->error?array($object->error):$object->errors)); $action = 'create'; - } + } else { + // Categories association + $contcats = GETPOST( 'contcats', 'array' ); + if (!empty( $contcats )) { + $cat = new Categorie( $db ); + foreach ($contcats as $id_category) { + $cat->fetch( $id_category ); + $cat->add_type( $object, 'contact' ); + } + } + } } if (! $error && $id > 0) @@ -309,8 +324,22 @@ if (empty($reshook)) $result = $object->update($contactid, $user); - if ($result > 0) - { + if ($result > 0) { + // Categories association + // First we delete all categories association + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_contact'; + $sql .= ' WHERE fk_socpeople = ' . $object->id; + $db->query( $sql ); + + // Then we add the associated categories + $categories = GETPOST( 'contcats', 'array' ); + if (!empty( $categories )) { + $cat = new Categorie( $db ); + foreach ($categories as $id_category) { + $cat->fetch( $id_category ); + $cat->add_type( $object, 'contact' ); + } + } $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; @@ -576,6 +605,15 @@ else print $form->selectarray('priv',$selectarray,(GETPOST("priv",'alpha')?GETPOST("priv",'alpha'):$object->priv),0); print ''; + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { + print '' . fieldLabel( 'Categories', 'contcats' ) . ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, 'parent', null, null, 1 ); + print $form->multiselectarray( 'contcats', $cate_arbo, GETPOST( 'contcats', 'array' ), null, null, null, + null, '90%' ); + print ""; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -815,6 +853,20 @@ else print $object->getLibStatut(4); print ''; + // Categories + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { + print '' . fieldLabel( 'Categories', 'contcats' ) . ''; + print ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 ); + $c = new Categorie( $db ); + $cats = $c->containing( $object->id, Categorie::TYPE_CONTACT ); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray( 'contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); + print ""; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1039,6 +1091,15 @@ else print $object->getLibStatut(4); print ''; print ''."\n"; + + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { + print '' . $langs->trans( "Categories" ) . ''; + print ''; + print $form->showCategories( $object->id, 'contact', 1 ); + print ''; + } + // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1101,18 +1162,14 @@ else { if ($user->rights->societe->contact->creer) { - print ''.$langs->trans('Modify').''; + print ''.$langs->trans('Modify').''; } if (! $object->user_id && $user->rights->user->user->creer) { - print ''.$langs->trans("CreateDolibarrLogin").''; + print ''.$langs->trans("CreateDolibarrLogin").''; } - if ($user->rights->societe->contact->supprimer) - { - print ''.$langs->trans('Delete').''; - } // Activer if ($object->statut == 0 && $user->rights->societe->contact->creer) { @@ -1122,6 +1179,12 @@ else if ($object->statut == 1 && $user->rights->societe->contact->creer) { print ''.$langs->trans("DisableUser").''; + } + + // Delete + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; } } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 72590c82e82..ebc167ae6d6 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -50,9 +50,21 @@ class Contact extends CommonObject var $zip; var $town; - var $fk_departement; // deprecated - var $departement_code; // deprecated - var $departement; // deprecated + /** + * @deprecated + * @see state_id + */ + var $fk_departement; + /** + * @deprecated + * @see state_code + */ + var $departement_code; + /** + * @deprecated + * @see state + */ + var $departement; var $state_id; // Id of department var $state_code; // Code of department var $state; // Label of department @@ -80,7 +92,11 @@ class Contact extends CommonObject var $birthday; var $default_lang; var $note_public; // Public note - var $note; // deprecated + /** + * @deprecated + * @see note_public, note_private + */ + var $note; var $note_private; // Private note var $no_email; // 1=Don't send e-mail to this contact, 0=do @@ -629,6 +645,13 @@ class Contact extends CommonObject } } + // Retreive all extrafield for contact + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + return 1; } else @@ -895,6 +918,11 @@ class Contact extends CommonObject $result=''; $label = '' . $langs->trans("ShowContact") . ''; $label.= '
' . $langs->trans("Name") . ': '.$this->getFullName($langs); + //if ($this->cibility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code + $label.= '
' . $langs->trans("Poste") . ': '.$this->poste; + $label.= '
' . $langs->trans("EMail") . ': '.$this->email; + $label.= '
' . $langs->trans("Phone") . ': '.join(', ',array($this->phone_pro,$this->phone_mobile,$this->phone_perso)); + $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); $link = ''; $linkend=''; @@ -1101,4 +1129,4 @@ class Contact extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } -} \ No newline at end of file +} diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 2241a1e67f1..9a5ab3b0f07 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -80,8 +80,9 @@ llxHeader("",$langs->trans("Contact"), $helpurl); if ($object->id) { $head = contact_prepare_head($object); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - dol_fiche_head($head, 'documents', $langs->trans("Contact"), 0, 'contact'); + dol_fiche_head($head, 'documents', $title, 0, 'contact'); // Construit liste des fichiers diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 72eee453c9f..11d46ad3fc4 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -159,7 +159,7 @@ else if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")"; } -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; +if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_firstlast_only) { @@ -256,11 +256,11 @@ if ($result) { $contactstatic=new Contact($db); - $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); - $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); - if (!empty($search_categ)) $param.='&search_categ='.$search_categ; - if ($search_status != '') $param.='&search_status='.$search_status; - if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); + $param ='&begin='.htmlspecialchars($begin).'&view='.htmlspecialchars($view).'&userid='.htmlspecialchars($userid).'&contactname='.htmlspecialchars($sall); + $param.='&type='.htmlspecialchars($type).'&view='.htmlspecialchars($view).'&search_lastname='.htmlspecialchars($search_lastname).'&search_firstname='.htmlspecialchars($search_firstname).'&search_societe='.htmlspecialchars($search_societe).'&search_email='.htmlspecialchars($search_email); + if (!empty($search_categ)) $param.='&search_categ='.htmlspecialchars($search_categ); + if ($search_status != '') $param.='&search_status='.htmlspecialchars($search_status); + if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".htmlspecialchars($search_priv); $num = $db->num_rows($result); $i = 0; @@ -269,7 +269,7 @@ if ($result) print '
'; print ''; - print ''; + print ''; print ''; print ''; @@ -317,36 +317,36 @@ if ($result) // Ligne des champs de filtres print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { print ''; - print ''; + print ''; print ''; } print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; if (! empty($conf->skype->enabled)) { print ''; - print ''; + print ''; print ''; } print ' '; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index dd48b27684f..6bf7dcaeacc 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -823,10 +823,8 @@ else if ($action == 'remove_file' && $user->rights->contrat->creer) { $upload_dir = $conf->contrat->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); } } @@ -1873,10 +1871,13 @@ else $somethingshown = $formfile->show_documents('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object); + if ($linktoelem) print '
'.$linktoelem; + print '
'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 08bc8387387..fb0038b509f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -154,6 +154,7 @@ class Contrat extends CommonObject /** * @deprecated Use fk_project instead + * @see fk_project */ var $fk_projet; @@ -1642,6 +1643,8 @@ class Contrat extends CommonObject */ function update_statut($user) { + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + // If draft, we keep it (should not happen) if ($this->statut == 0) return 1; @@ -2165,6 +2168,7 @@ class ContratLigne extends CommonObjectLine /** * @var string * @deprecated Use $label instead + * @see label */ public $libelle; @@ -2189,6 +2193,7 @@ class ContratLigne extends CommonObjectLine /** * @var float * @deprecated Use $price_ht instead + * @see price_ht */ public $price; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 25b5d80fa98..669f2b09775 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -100,7 +100,8 @@ $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " WHERE c.fk_soc = s.rowid "; $sql.= " AND c.entity = ".$conf->entity; -if ($socid) $sql.= " AND s.rowid = ".$socid; +if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid); +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_name) { $sql .= natural_search('s.nom', $search_name); @@ -112,7 +113,7 @@ if (!empty($search_ref_supplier)) { $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); } -if ($search_sale > 0) +if ($search_sale > 0) { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; } @@ -131,7 +132,7 @@ if ($resql) $i = 0; print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], '&search_contract='.$search_contract.'&search_name='.$search_name, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png'); - + print ''; print ''; @@ -144,7 +145,7 @@ if ($resql) $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); $moreforfilter.='       '; } - + if ($moreforfilter) { print ''; @@ -152,13 +153,14 @@ if ($resql) print $moreforfilter; print ''; } - + print ''; - $param='&search_contract='.$search_contract; - $param.='&search_name='.$search_name; - $param.='&search_ref_supplier='.$search_ref_supplier; + + $param='&search_contract='.$search_contract; + $param.='&search_name='.$search_name; + $param.='&search_ref_supplier='.$search_ref_supplier; $param.='&search_sale=' .$search_sale; - + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); @@ -175,13 +177,13 @@ if ($resql) print ''; print ''; print ''; print ''; print ''; print ''; //print ''; @@ -202,7 +204,7 @@ if ($resql) print ''; print ''; //print ''; - + // Sales Rapresentatives print ''; - - + + print ''; //print ''; print ''; diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 03d724b9bba..4c5f0b512d2 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,7 +148,21 @@ if ($action == 'add') } } - $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params,(GETPOST('alwayseditable')?1:0)); + $result=$extrafields->addExtraField( + GETPOST('attrname'), + GETPOST('label'), + GETPOST('type'), + GETPOST('pos'), + $extrasize, + $elementtype, + (GETPOST('unique')?1:0), + (GETPOST('required')?1:0), + $default_value, + $params, + (GETPOST('alwayseditable')?1:0), + (GETPOST('perms')?GETPOST('perms'):''), + (GETPOST('list')?1:0) + ); if ($result > 0) { setEventMessage($langs->trans('SetupSaved')); @@ -285,7 +299,20 @@ if ($action == 'update') $params['options'][$key] = $value; } } - $result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params,(GETPOST('alwayseditable')?1:0)); + $result=$extrafields->update( + GETPOST('attrname'), + GETPOST('label'), + GETPOST('type'), + $extrasize, + $elementtype, + (GETPOST('unique')?1:0), + (GETPOST('required')?1:0), + $pos, + $params, + (GETPOST('alwayseditable')?1:0), + (GETPOST('perms')?GETPOST('perms'):''), + (GETPOST('list')?1:0) + ); if ($result > 0) { setEventMessage($langs->trans('SetupSaved')); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 6e41384dbce..1aadc47b79e 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -37,7 +37,7 @@ class CMailFile { var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') + var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain. // Return-Path: Email where to send bounds. @@ -387,7 +387,7 @@ class CMailFile // If Windows, sendmail_from must be defined if (isset($_SERVER["WINDIR"])) { - if (empty($this->addr_from)) $this->addr_from = 'robot@mydomain.com'; + if (empty($this->addr_from)) $this->addr_from = 'robot@example.com'; @ini_set('sendmail_from',$this->getValidAddress($this->addr_from,2)); } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 22a33f4d2a8..d0730149b36 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -118,6 +118,7 @@ abstract class CommonDocGenerator 'mycompany_idprof5'=>$mysoc->idprof5, 'mycompany_idprof6'=>$mysoc->idprof6, 'mycompany_vatnumber'=>$mysoc->tva_intra, + 'mycompany_object'=>$mysoc->object, // Only private not exists for "mysoc" 'mycompany_note_private'=>$mysoc->note_private, diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0bd0625ee5d..8ae7332fc6e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2014 Philippe Grand * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador * * This program is free software; you can redistribute it and/or modify @@ -44,6 +44,7 @@ abstract class CommonObject /** * @var string Error string * @deprecated Use instead the array of error strings + * @see errors */ public $error; @@ -82,7 +83,7 @@ abstract class CommonObject public $errors=array(); /** - * @var string Can be used to pass information when only object is provided to method + * @var string[] Can be used to pass information when only object is provided to method */ public $context=array(); @@ -96,7 +97,24 @@ abstract class CommonObject public $lastname; public $firstname; public $civility_id; + /** + * @deprecated + * @see thirdparty + */ + public $client; + /** + * @var Societe + */ public $thirdparty; + /** + * @deprecated + * @see project + */ + public $projet; + /** + * @var Project + */ + public $project; // No constructor as it is an abstract class @@ -113,13 +131,15 @@ abstract class CommonObject */ static function isExistingObject($element, $id, $ref='', $ref_ext='') { - global $db; + global $db,$conf; $sql = "SELECT rowid, ref, ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX.$element; - if ($id > 0) $sql.= " WHERE rowid = ".$db->escape($id); - else if ($ref) $sql.= " WHERE ref = '".$db->escape($ref)."'"; - else if ($ref_ext) $sql.= " WHERE ref_ext = '".$db->escape($ref_ext)."'"; + $sql.= " WHERE entity IN (".getEntity($element).")" ; + + if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); + else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; + else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; else { $error='ErrorWrongParameters'; dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); @@ -525,9 +545,9 @@ abstract class CommonObject * Return array with list of possible values for type of contacts * * @param string $source 'internal', 'external' or 'all' - * @param string $order Sort order by : 'code' or 'rowid' - * @param string $option 0=Return array id->label, 1=Return array code->label - * @param string $activeonly 0=all status of contact, 1=only the active + * @param string $order Sort order by 'code' or 'rowid' + * @param int $option 0=Return array id->label, 1=Return array code->label + * @param int $activeonly 0=all status of contact, 1=only the active * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ @@ -541,7 +561,7 @@ abstract class CommonObject $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE tc.element='".$this->element."'"; - if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type + if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'"; if (! empty($code)) $sql.= " AND tc.code='".$code."'"; $sql.= " ORDER by tc.".$order; @@ -626,12 +646,12 @@ abstract class CommonObject } /** - * Charge le contact d'id $id dans this->contact + * Load object contact with id=$this->contactid into $this->contact * * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid='') + function fetch_contact($contactid=null) { if (empty($contactid)) $contactid=$this->contactid; @@ -759,10 +779,14 @@ abstract class CommonObject */ function fetch_projet() { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility if (empty($this->fk_project)) return 0; $project = new Project($this->db); $result = $project->fetch($this->fk_project); + $this->projet = $project; // deprecated $this->project = $project; return $result; @@ -858,14 +882,14 @@ abstract class CommonObject /** * Update a specific field into database * - * @param string $field Field to update - * @param mixed $value New value - * @param string $table To force other table element or element line (should not be used) - * @param int $id To force other object id (should not be used) - * @param string $format Data format ('text', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used it not defined - * @param string $user Update last update fields also if user object provided - * @return int <0 if KO, >0 if OK + * @param string $field Field to update + * @param mixed $value New value + * @param string $table To force other table element or element line (should not be used) + * @param int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used it not defined + * @param User|string $user Update last update fields also if user object provided + * @return int <0 if KO, >0 if OK */ function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='') { @@ -1639,9 +1663,10 @@ abstract class CommonObject /** * Update public note (kept for backward compatibility) * - * @param string $note New value for note - * @return int <0 if KO, >0 if OK - * @deprecated + * @param string $note New value for note + * @return int <0 if KO, >0 if OK + * @deprecated + * @see update_note() */ function update_note_public($note) { @@ -1655,10 +1680,10 @@ abstract class CommonObject * @param int $exclspec >0 = Exclude special product (product_type=9) * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object. - * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object. + * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object and for this, we need seller object. * @return int <0 if KO, >0 if OK */ - function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='') + function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null) { global $conf; @@ -2555,88 +2580,19 @@ abstract class CommonObject // TODO: All functions here must be redesigned and moved as they are not business functions but output functions // -------------------- - /* This is to show linked object block */ - /** - * Show linked object block - * TODO Move this into html.class.php - * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * Show linked object block. * - * @return int + * @return int <0 if KO, >0 if OK + * @deprecated 3.8 Use instead $form->shoLinkedObjectBlock($object) */ function showLinkedObjectBlock() { - global $conf,$langs,$hookmanager; - global $bc; - - $this->fetchObjectLinked(); - - // Bypass the default method - $hookmanager->initHooks(array('commonobject')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook - - if (empty($reshook)) - { - $num = count($this->linkedObjects); - - foreach($this->linkedObjects as $objecttype => $objects) - { - $tplpath = $element = $subelement = $objecttype; - - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - $tplpath = $element.'/'.$subelement; - } - - // To work with non standard path - if ($objecttype == 'facture') { - $tplpath = 'compta/'.$element; - if (empty($conf->facture->enabled)) continue; // Do not show if module disabled - } - else if ($objecttype == 'propal') { - $tplpath = 'comm/'.$element; - if (empty($conf->propal->enabled)) continue; // Do not show if module disabled - } - else if ($objecttype == 'askpricesupplier') { - $tplpath = 'comm/'.$element; - if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled - } - else if ($objecttype == 'shipping' || $objecttype == 'shipment') { - $tplpath = 'expedition'; - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled - } - else if ($objecttype == 'delivery') { - $tplpath = 'livraison'; - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled - } - else if ($objecttype == 'invoice_supplier') { - $tplpath = 'fourn/facture'; - } - else if ($objecttype == 'order_supplier') { - $tplpath = 'fourn/commande'; - } - - global $linkedObjectBlock; - $linkedObjectBlock = $objects; - - // Output template part (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php'); - if ($res) break; - } - } - - return $num; - } + global $form; + return $form->showLinkedObjectBlock($this); } - /* This is to show add lines */ /** @@ -2684,9 +2640,9 @@ abstract class CommonObject * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * * @param string $action Action code - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected + * @param Societe $seller Object of seller third party + * @param Societe $buyer Object of buyer third party + * @param int $selected Object line selected * @param int $dateSelector 1=Show also date range input fields * @return void */ @@ -2799,16 +2755,16 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output - * @param string $var Is it a an odd line (true) - * @param int $num Number of line (0) - * @param int $i I - * @param int $dateSelector 1=Show also date range input fields - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected - * @param object $extrafieldsline Object of extrafield line attribute + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output + * @param string $var Is it a an odd line (true) + * @param int $num Number of line (0) + * @param int $i I + * @param int $dateSelector 1=Show also date range input fields + * @param Societe $seller Object of seller third party + * @param Societe $buyer Object of buyer third party + * @param int $selected Object line selected + * @param object $extrafieldsline Object of extrafield line attribute * @return void */ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) @@ -3083,228 +3039,24 @@ abstract class CommonObject } - /** - * get Margin info - * - * @param string $force_price True of not - * @return mixed Array with info - */ - function getMarginInfos($force_price=false) - { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - - $marginInfos = array( - 'pa_products' => 0, - 'pv_products' => 0, - 'margin_on_products' => 0, - 'margin_rate_products' => '', - 'mark_rate_products' => '', - 'pa_services' => 0, - 'pv_services' => 0, - 'margin_on_services' => 0, - 'margin_rate_services' => '', - 'mark_rate_services' => '', - 'pa_total' => 0, - 'pv_total' => 0, - 'total_margin' => 0, - 'total_margin_rate' => '', - 'total_mark_rate' => '' - ); - - foreach($this->lines as $line) { - if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) { - $product = new ProductFournisseur($this->db); - if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) - $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); - if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) - $line->pa_ht += $product->fourn_unitcharges; - } - // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente - if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { - $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); - } - - // calcul des marges - if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise - $pa = $line->qty * $line->pa_ht; - $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); - if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit - $marginInfos['pa_products'] += $pa; - $marginInfos['pv_products'] += $pv; - $marginInfos['pa_total'] += $pa; - $marginInfos['pv_total'] += $pv; - // if credit note, margin = -1 * (abs(selling_price) - buying_price) - if ($pv < 0) - $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa); - else - $marginInfos['margin_on_products'] += $pv - $pa; - } - elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service - $marginInfos['pa_services'] += $pa; - $marginInfos['pv_services'] += $pv; - $marginInfos['pa_total'] += $pa; - $marginInfos['pv_total'] += $pv; - // if credit note, margin = -1 * (abs(selling_price) - buying_price) - if ($pv < 0) - $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa); - else - $marginInfos['margin_on_services'] += $pv - $pa; - } - elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total - $marginInfos['pa_total'] += $pa; - $marginInfos['pv_total'] += $pv; - } - } - else { - $type=$line->product_type?$line->product_type:$line->fk_product_type; - if ($type == 0) { // product - $pa = $line->qty * $line->pa_ht; - $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); - $marginInfos['pa_products'] += $pa; - $marginInfos['pv_products'] += $pv; - $marginInfos['pa_total'] += $pa; - $marginInfos['pv_total'] += $pv; - // if credit note, margin = -1 * (abs(selling_price) - buying_price) - if ($pv < 0) - $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa); - else - $marginInfos['margin_on_products'] += $pv - $pa; - } - elseif ($type == 1) { // service - $pa = $line->qty * $line->pa_ht; - $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); - $marginInfos['pa_services'] += $pa; - $marginInfos['pv_services'] += $pv; - $marginInfos['pa_total'] += $pa; - $marginInfos['pv_total'] += $pv; - // if credit note, margin = -1 * (abs(selling_price) - buying_price) - if ($pv < 0) - $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa); - else - $marginInfos['margin_on_services'] += $pv - $pa; - } - } - } - if ($marginInfos['pa_products'] > 0) - $marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products']; - if ($marginInfos['pv_products'] > 0) - $marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products']; - - if ($marginInfos['pa_services'] > 0) - $marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services']; - if ($marginInfos['pv_services'] > 0) - $marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services']; - - // if credit note, margin = -1 * (abs(selling_price) - buying_price) - if ($marginInfos['pv_total'] < 0) - $marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']); - else - $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; - if ($marginInfos['pa_total'] > 0) - $marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total']; - if ($marginInfos['pv_total'] > 0) - $marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total']; - - return $marginInfos; - } - /** * Show the array with all margin infos * - * @param string $force_price Force price - * @return void + * @param boolean $force_price Force price + * @return void + * @deprecated 3.8 Load FormMargin class and make a direct call to displayMarginInfos */ function displayMarginInfos($force_price=false) { - global $langs, $conf, $user; - - if (! empty($user->societe_id)) return; - - if (! $user->rights->margins->liretous) return; - - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - - $marginInfo = $this->getMarginInfos($force_price); - - if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better - { - print $langs->trans('ShowMarginInfos').' : '; - $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']; - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - - print ''; - if (!empty($hidemargininfos)) print ''; - } - - print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '  '.$obj->ref_supplier.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.dol_print_date($obj->datec).''; if($obj->socid) @@ -237,8 +239,8 @@ if ($resql) print ' '; } print ''.dol_print_date($db->jdate($obj->date_contrat)).''.$staticcontrat->LibStatut($obj->statut,3).''.($obj->nb_initial>0?$obj->nb_initial:'').'
'; - print ''; - print ''; - print ''; - if ($conf->global->MARGIN_TYPE == "1") - print ''; - else - print ''; - print ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; - print ''; - - if (! empty($conf->product->enabled)) - { - //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; - print ''; - } - - if (! empty($conf->service->enabled)) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; - print ''; - } - - if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; - print ''; - } - print '
'.$langs->trans('Margins').''.$langs->trans('SellingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'
'.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'
'.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'
'.$langs->trans('TotalMargin').''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'
'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; + $formmargin=new FormMargin($this->db); + $formmargin->displayMarginInfos($this, $force_price); } /** * Add resources to the current object : add entry into llx_element_resources - *Need $this->element & $this->id + * Need $this->element & $this->id * * @param int $resource_id Resource id * @param string $resource_element Resource element @@ -3726,7 +3478,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeSize = $extrafields->attribute_size[$attributeKey]; + //$attributeSize = $extrafields->attribute_size[$attributeKey]; Not required to insert an extrafield value. Only used for definition. $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey]; switch ($attributeType) @@ -3751,19 +3503,19 @@ abstract class CommonObject case 'datetime': $this->array_options[$key]=$this->db->idate($this->array_options[$key]); break; - case 'link': - $param_list=array_keys($attributeParam ['options']); - // 0 : ObjectName - // 1 : classPath - $InfoFieldList = explode(":", $param_list[0]); - dol_include_once($InfoFieldList[1]); - $object = new $InfoFieldList[0]($this->db); - if ($value) - { - $object->fetch(0,$value); - $this->array_options[$key]=$object->id; - } - break; + case 'link': + $param_list=array_keys($attributeParam ['options']); + // 0 : ObjectName + // 1 : classPath + $InfoFieldList = explode(":", $param_list[0]); + dol_include_once($InfoFieldList[1]); + $object = new $InfoFieldList[0]($this->db); + if ($value) + { + $object->fetch(0,$value); + $this->array_options[$key]=$object->id; + } + break; } } $this->db->begin(); @@ -3771,6 +3523,7 @@ abstract class CommonObject $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; foreach($this->array_options as $key => $value) { @@ -3825,7 +3578,7 @@ abstract class CommonObject * * @return string */ - function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') + function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='') { global $_POST, $conf; @@ -3955,15 +3708,16 @@ abstract class CommonObject * This function is meant to be called from replaceThirdparty with the appropiate tables * Column name fk_soc MUST be used to identify thirdparties * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @param array $tables Tables that need to be changed + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id (the thirdparty to delete) + * @param int $dest_id New thirdparty id (the thirdparty that will received element of the other) + * @param array $tables Tables that need to be changed * @return bool */ public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables) { - foreach ($tables as $table) { + foreach ($tables as $table) + { $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; if (!$db->query($sql)) { diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 07019a0fa1d..ef854a2452e 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -39,6 +39,7 @@ abstract class CommonObjectLine extends CommonObject * Id of the line * @var int * @deprecated Try to use id property as possible (even if field into database is still rowid) + * @see id */ public $rowid; diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index b4882af8a58..5309b5524ee 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -43,6 +43,7 @@ abstract class CommonOrderLine extends CommonObjectLine * Product ref * @var string * @deprecated Use product_ref + * @see product_ref */ public $ref; @@ -56,6 +57,7 @@ abstract class CommonOrderLine extends CommonObjectLine * Product label * @var string * @deprecated Use product_label + * @see product_label */ public $libelle; @@ -78,7 +80,9 @@ abstract class CommonOrderLine extends CommonObjectLine public $qty; /** + * Unit price * @deprecated + * @see subprice */ var $price; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 6370062a6a9..13d2881563f 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -404,7 +404,7 @@ class Conf $this->css = "/theme/".$this->theme."/style.css.php"; // conf->email_from = email pour envoi par dolibarr des mails automatiques - $this->email_from = "robot@domain.com"; + $this->email_from = "robot@example.com"; if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; // conf->notification->email_from = email pour envoi par Dolibarr des notifications diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php index 4b934b331f3..fdd0fc2732c 100644 --- a/htdocs/core/class/dolprintipp.class.php +++ b/htdocs/core/class/dolprintipp.class.php @@ -91,7 +91,14 @@ class dolprintIPP } } // Getting Jobs - $ipp->getJobs(false,0,'completed',false); + try { + $ipp->getJobs(false,0,'completed',false); // May return errors if setup not correct + } + catch(Exception $e) + { + print $e->getMessage(); + } + print ''; print ''; print ""; @@ -102,19 +109,22 @@ class dolprintIPP print ""; print "\n"; $jobs = $ipp->jobs_attributes; - $var = True; + $var = true; //print '
'.print_r($jobs,true).'
'; - foreach ($jobs as $value ) + if (is_array($jobs)) { - $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + foreach ($jobs as $value) + { + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } print "
IdCancel
'.$value->job_id->_value0.''.$value->job_originating_user_name->_value0.''.$value->printer_uri->_value0.''.$value->job_name->_value0.''.$value->job_state->_value0.''.$value->job_uri->_value0.'
'.$value->job_id->_value0.''.$value->job_originating_user_name->_value0.''.$value->printer_uri->_value0.''.$value->job_name->_value0.''.$value->job_state->_value0.''.$value->job_uri->_value0.'
"; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e2313d157d5..34abeeb8c6e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,7 +39,7 @@ class ExtraFields var $attribute_type; // Tableau contenant le nom des champs en clef et le label de ces champs en value var $attribute_label; - // Tableau contenant le nom des champs en clef et la taille de ces champs en value + // Tableau contenant le nom des champs en clef et la taille/longueur max de ces champs en value var $attribute_size; // Tableau contenant le nom des choix en clef et la valeur de ces choix en value var $attribute_choice; @@ -124,6 +124,7 @@ class ExtraFields if (empty($label)) return -1; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; // Create field into database except for separator type which is not stored in database if ($type != 'separate') @@ -169,6 +170,7 @@ class ExtraFields private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0) { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -248,6 +250,7 @@ class ExtraFields global $conf; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; // Clean parameters if (empty($pos)) $pos=0; @@ -308,6 +311,7 @@ class ExtraFields function delete($attrname, $elementtype='member') { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -342,6 +346,7 @@ class ExtraFields global $conf; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { @@ -389,6 +394,7 @@ class ExtraFields function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='') { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -486,6 +492,8 @@ class ExtraFields // Clean parameters if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; + if (empty($list)) $list=0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) @@ -570,6 +578,7 @@ class ExtraFields if ( empty($elementtype) ) return array(); if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $array_name_label=array(); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 47810e204bd..ee7742660c1 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -116,9 +116,9 @@ class HookManager * @param array $parameters Array of parameters * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. - * Can also return some values into an array ->results. + * @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. + * All types can also return some values into an array ->results. * $this->error or this->errors are also defined by class called by this function if error. */ function executeHooks($method, $parameters=false, &$object='', &$action='') @@ -135,7 +135,8 @@ class HookManager array( 'addMoreActionsButtons', 'addStatisticLine', - 'doActions', + 'deleteFile', + 'doActions', 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', @@ -147,7 +148,7 @@ class HookManager 'formatEvent' ) )) $hooktype='addreplace'; - // Deprecated hook types + // Deprecated hook types ('returnvalue') if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks. if ($method == 'insertExtraFields') { @@ -195,7 +196,7 @@ class HookManager if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; } - // Generic hooks that return a string or array (printSearchForm, printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) + // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) else { // TODO. this should be done into the method of hook by returning nothing diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b4e5a8a0ec0..c236df18199 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -41,6 +41,8 @@ /** * Class to manage generation of HTML components * Only common components must be here. + * + * TODO Merge all function load_cache_* and loadCache* (except load_cache_vatrates) into one generic function loadCacheTable */ class Form { @@ -101,7 +103,7 @@ class Form } } else - { + { $ret.=''; @@ -376,7 +378,7 @@ class Form * @return string Code html du tooltip (texte+picto) * @see Use function textwithpicto if you can. */ - function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 0, $incbefore = '', $noencodehtmltext = 0) + function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0) { global $conf; @@ -391,14 +393,19 @@ class Form $htmltext=str_replace("\r","",$htmltext); $htmltext=str_replace("\n","",$htmltext); + $extrastyle=''; + if ($direction < 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-left: 3px !important;'; } + if ($direction > 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-right: 3px !important;'; } + $htmltext=str_replace('"',""",$htmltext); - if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip - else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip - else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip + else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag + if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip + else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag $s=""; if (empty($notabs)) $s.='
'; $ret.=$langs->trans($text); $ret.='
'; elseif ($notabs == 2) $s.='
'; + // Define value if value is before if ($direction < 0) { $s.='<'.$tag.$paramfortooltipimg; if ($tag == 'td') { @@ -407,16 +414,12 @@ class Form $s.= '>'.$img.''; } // Use another method to help avoid having a space in value in order to use this value with jquery - // TODO add this in css - //if ($text != '') $s.='<'.$tag.$paramfortooltiptd.'>'.(($direction < 0)?' ':'').$text.(($direction > 0)?' ':'').''; - $paramfortooltiptd.= (($direction < 0)?' class="inline-block" style="padding: 0px; padding-left: 3px !important;"':''); - $paramfortooltiptd.= (($direction > 0)?' class="inline-block" style="padding: 0px; padding-right: 3px !important;"':''); + // Define label if ((string) $text != '') $s.='<'.$tag.$paramfortooltiptd.'>'.$text.''; + // Define value if value is after if ($direction > 0) { $s.='<'.$tag.$paramfortooltipimg; - if ($tag == 'td') { - $s .= ' valign="top" width="14"'; - } + if ($tag == 'td') $s .= ' valign="middle" width="14"'; $s.= '>'.$img.''; } if (empty($notabs)) $s.='
'; @@ -437,7 +440,7 @@ class Form * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span * @return string HTML code of text, picto, tooltip */ - function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 0) + function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2) { global $conf; @@ -496,14 +499,14 @@ class Form $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite"; $sql.= " FROM ".MAIN_DB_PREFIX."c_country"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; //$sql.= " ORDER BY code ASC"; dol_syslog(get_class($this)."::select_country", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { - $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -531,7 +534,7 @@ class Form if (empty($row['favorite']) && $atleastonefavorite) { $atleastonefavorite=0; - $out.= ''; + $out.= ''; } if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) ) { @@ -554,6 +557,10 @@ class Form dol_print_error($this->db); } + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox('select'.$htmlname); + return $out; } @@ -580,7 +587,7 @@ class Form $sql = "SELECT rowid, code"; $sql.= " FROM ".MAIN_DB_PREFIX."c_incoterms"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; $sql.= " ORDER BY code ASC"; dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG); @@ -707,22 +714,23 @@ class Form /** * Load into cache cache_types_fees, array of types of fees * - * @return int Nb of lines loaded, 0 if already loaded, <0 if ko - * TODO move in DAO class + * @return int Nb of lines loaded, <0 if KO */ function load_cache_types_fees() { global $langs; - $langs->load("trips"); + $num = count($this->cache_types_fees); + if ($num > 0) return 0; // Cache already loaded - if (count($this->cache_types_fees)) return 0; // Cache already load + dol_syslog(__METHOD__, LOG_DEBUG); + + $langs->load("trips"); $sql = "SELECT c.code, c.label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; - //$sql.= " ORDER BY c.label ASC"; // No sort here, sort must be done after translation + $sql.= " WHERE active > 0"; - dol_syslog(get_class($this).'::load_cache_types_fees', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -744,7 +752,7 @@ class Form return $num; } else - { + { dol_print_error($this->db); return -1; } @@ -762,7 +770,7 @@ class Form { global $user, $langs; - dol_syslog(get_class($this)."::select_type_fees ".$selected.", ".$htmlname, LOG_DEBUG); + dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); $this->load_cache_types_fees(); @@ -798,11 +806,28 @@ class Form * @param array $ajaxoptions Options for ajax_autocompleter * @param int $forcecombo Force to use combo box * @return string Return select box for thirdparty. + * @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0) */ function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0) { - global $langs,$conf; + return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit); + } + /** + * Output html form to select a third party + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param string $filter optional filters criteras (example: 's.rowid <> x') + * @param int $showempty Add an empty field + * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $forcecombo Force to use combo box + * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param int $limit Maximum number of elements + * @return string HTML string with select box for thirdparty. + */ + function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0) + { $out=''; /* TODO Use ajax_autocompleter like for products (not finished) @@ -835,31 +860,12 @@ class Form } else {*/ - $out.=$this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit); + $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit); //} return $out; } - /** - * Output html form to select a third party - * - * @param string $selected Preselected type - * @param string $htmlname Name of field in form - * @param string $filter optional filters criteras (example: 's.rowid <> x') - * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box - * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param int $limit Maximum number of elements - * @return string HTML string with - * @deprecated Use select_thirdparty instead - */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0) - { - return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit); - } - /** * Output html form to select a third party * @@ -890,7 +896,7 @@ class Form if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id; if ($filter) $sql.= " AND (".$filter.")"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status<>0 "; + if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status <> 0"; // Add criteria if ($filterkey && $filterkey != '') { @@ -1117,7 +1123,7 @@ class Form if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc"; $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid; - if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut<>0"; + if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0"; $sql.= " ORDER BY sp.lastname ASC"; dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG); @@ -1223,6 +1229,7 @@ class Form * @param int $force_entity 0 or Id of environment to force * @return void * @deprecated + * @see select_dolusers() */ function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) { @@ -1244,10 +1251,11 @@ class Form * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param string $morefilter Add more filters into sql request * @param string $show_every 0=default list, 1=add also a value "Everybody" at beginning of list + * @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0) + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='') { global $conf,$user,$langs; @@ -1343,8 +1351,8 @@ class Form $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; - $disableline=0; - if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=1; + $disableline=''; + if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=($enableonlytext?$enableonlytext:'1'); if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid)) { @@ -1394,6 +1402,10 @@ class Form } } $out.=($moreinfo?')':''); + if ($disableline && $disableline != '1') + { + $out.=' - '.$disableline; // This is text from $enableonlytext parameter + } $out.= ''; $i++; @@ -1451,12 +1463,12 @@ class Form $out.=''; $out.=''; $out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out.=''; + $out.=' '; } $assignedtouser=array(); if (!empty($_SESSION['assignedtouser'])) { - $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); + $assignedtouser=json_decode($_SESSION['assignedtouser'], true); } $nbassignetouser=count($assignedtouser); @@ -2312,19 +2324,22 @@ class Form /** * Charge dans cache la liste des conditions de paiements possibles * - * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko + * @return int Nb of lines loaded, <0 if KO */ function load_cache_conditions_paiements() { global $langs; - if (count($this->cache_conditions_paiements)) return 0; // Cache deja charge + $num = count($this->cache_conditions_paiements); + if ($num > 0) return 0; // Cache already loaded - $sql = "SELECT rowid, code, libelle"; + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; - $sql.= " WHERE active=1"; + $sql.= " WHERE active > 0"; $sql.= " ORDER BY sortorder"; - dol_syslog(get_class($this).'::load_cache_conditions_paiements', LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { @@ -2335,14 +2350,18 @@ class Form $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $libelle=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->libelle!='-'?$obj->libelle:'')); + $label=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->label!='-'?$obj->label:'')); $this->cache_conditions_paiements[$obj->rowid]['code'] =$obj->code; - $this->cache_conditions_paiements[$obj->rowid]['label']=$libelle; + $this->cache_conditions_paiements[$obj->rowid]['label']=$label; $i++; } - return 1; + + //$this->cache_conditions_paiements=dol_sort_array($this->cache_conditions_paiements, 'label'); // We use the sortorder + + return $num; } - else { + else + { dol_print_error($this->db); return -1; } @@ -2351,19 +2370,21 @@ class Form /** * Charge dans cache la liste des délais de livraison possibles * - * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko + * @return int Nb of lines loaded, <0 if KO */ function load_cache_availability() { global $langs; - if (count($this->cache_availability)) return 0; // Cache deja charge + $num = count($this->cache_availability); + if ($num > 0) return 0; // Cache already loaded + + dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT rowid, code, label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_availability'; - $sql.= " WHERE active=1"; - $sql.= " ORDER BY rowid"; - dol_syslog(get_class($this).'::load_cache_availability', LOG_DEBUG); + $sql.= " WHERE active > 0"; + $resql = $this->db->query($sql); if ($resql) { @@ -2379,9 +2400,13 @@ class Form $this->cache_availability[$obj->rowid]['label']=$label; $i++; } - return 1; + + $this->cache_availability = dol_sort_array($this->cache_availability, 'label'); + + return $num; } - else { + else + { dol_print_error($this->db); return -1; } @@ -2402,6 +2427,8 @@ class Form $this->load_cache_availability(); + dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); + print ''; @@ -2595,7 +2631,7 @@ class Form { global $langs,$user; - dol_syslog(get_class($this)."::select_type_paiements ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG); + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); $filterarray=array(); if ($filtertype == 'CRDT') $filterarray=array(0,2,3); @@ -2635,26 +2671,13 @@ class Form /** - * Selection HT or TTC + * Selection HT or TTC * - * @param string $selected Id pre-selectionne - * @param string $htmlname Nom de la zone select - * @return void + * @param string $selected Id pre-selectionne + * @param string $htmlname Nom de la zone select + * @return string Code of HTML select to chose tax or not */ - function select_PriceBaseType($selected='',$htmlname='price_base_type') - { - print $this->load_PriceBaseType($selected,$htmlname); - } - - - /** - * Selection HT or TTC - * - * @param string $selected Id pre-selectionne - * @param string $htmlname Nom de la zone select - * @return void - */ - function load_PriceBaseType($selected='',$htmlname='price_base_type') + function selectPriceBaseType($selected='',$htmlname='price_base_type') { global $langs; @@ -2699,9 +2722,9 @@ class Form $langs->load("admin"); $langs->load("deliveries"); - $sql = "SELECT rowid, code, libelle"; + $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY libelle ASC"; @@ -2722,7 +2745,7 @@ class Form } else { print ''; $i++; } @@ -2774,12 +2797,12 @@ class Form /** * Creates HTML last in cycle situation invoices selector * - * @param string $selected Preselected ID - * @param int $socid Company ID + * @param string $selected Preselected ID + * @param int $socid Company ID * * @return string HTML select */ - function load_situation_invoices($selected = '', $socid = '') + function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -2787,7 +2810,7 @@ class Form $opt = ''; $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; - $sql .= ' order by situation_cycle_ref, situation_counter desc'; + $sql.= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { // Last seen cycle @@ -2813,10 +2836,13 @@ class Form } } } - } else { + } + else + { dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); } - if ($opt == '') { + if ($opt == '') + { $opt = ''; } return $opt; @@ -2825,7 +2851,7 @@ class Form /** * Creates HTML units selector (code => label) * - * @param string $selected Preselected code ('km', 'm', 'l', 'p', ...) + * @param string $selected Preselected Unit ID * @param string $htmlname Select name * @param int $showempty Add a nempty line * @return string HTML select @@ -2838,7 +2864,9 @@ class Form $return= ''; @@ -3025,6 +3053,7 @@ class Form * @param int $width Force width of box * @return void * @deprecated + * @see formconfirm() */ function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) { @@ -3082,7 +3111,7 @@ class Form // Now add questions $more.=''."\n"; - $more.=''."\n"; + $more.=''."\n"; foreach ($formquestion as $key => $input) { if (is_array($input) && ! empty($input)) @@ -3091,15 +3120,15 @@ class Form if ($input['type'] == 'text') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'password') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'select') { - $more.=''."\n"; @@ -3107,13 +3136,13 @@ class Form else if ($input['type'] == 'checkbox') { $more.=''; - $more.=''; - $more.=''."\n"; } @@ -3508,9 +3537,9 @@ class Form * * @param string $page Page * @param string $selected Id of user preselected - * @param string $htmlname Name of input html field - * @param array $exclude List of users id to exclude - * @param array $include List of users id to include + * @param string $htmlname Name of input html field. If 'none', we just output the user link. + * @param array $exclude List of users id to exclude + * @param array $include List of users id to include * @return void */ function form_users($page, $selected='', $htmlname='userid', $exclude='', $include='') @@ -3530,12 +3559,10 @@ class Form print '
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'; + $more.='
'; if (! empty($input['label'])) $more.=$input['label'].''; $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); $more.='
'.$input['label'].' '; + $more.=''.$input['label'].' '; $more.=''; else $more.=' '; + $more.='
'; + if (! empty($input['label'])) $more.=$input['label'].''; $more.=$input['value']; $more.='
'; } else - { + { if ($selected) { require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; - //$this->load_cache_contacts(); - //print $this->cache_contacts[$selected]; $theuser=new User($this->db); $theuser->fetch($selected); print $theuser->getNomUrl(1); @@ -3646,12 +3673,12 @@ class Form /** - * Affiche formulaire de selection des contacts + * Show forms to select a contact * - * @param string $page Page - * @param Societe $societe Third party - * @param int $selected Id contact pre-selectionne - * @param string $htmlname Nom du formulaire select + * @param string $page Page + * @param Societe $societe Filter on third party + * @param int $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML select. If 'none', we just show contact link. * @return void */ function form_contacts($page, $societe, $selected='', $htmlname='contactid') @@ -3681,8 +3708,6 @@ class Form if ($selected) { require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; - //$this->load_cache_contacts(); - //print $this->cache_contacts[$selected]; $contact=new Contact($this->db); $contact->fetch($selected); print $contact->getFullName($langs); @@ -3798,12 +3823,14 @@ class Form global $langs; $num = count($this->cache_vatrates); - if ($num > 0) return $num; // Cache deja charge + if ($num > 0) return $num; // Cache already loaded - $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid"; - $sql.= " AND t.active = 1"; + $sql.= " AND t.active > 0"; $sql.= " AND c.code IN (".$country_code.")"; $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; @@ -3837,7 +3864,8 @@ class Form } /** - * Output an HTML select vat rate + * Output an HTML select vat rate. + * The name of this function should be selectVat. We keep bad name for compatibility purpose. * * @param string $htmlname Name of html select field * @param float $selectedrate Force preselected vat rate. Use '' for no forcing. @@ -4244,6 +4272,7 @@ class Form $hourSelected=0; $minSelected=0; + // Hours if ($iSecond != '') { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -4274,6 +4303,7 @@ class Form $retstring.=' '.$langs->trans('HourShort'); + // Minutes if ($minunderhours) $retstring.='
'; else $retstring.=" "; @@ -4327,24 +4357,26 @@ class Form global $conf, $langs; // Do we want a multiselect ? - $multiselect = 0; - if (preg_match('/^multi/',$htmlname)) $multiselect = 1; + //$jsbeautify = 0; + //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1; + $jsbeautify = 1; if ($value_as_key) $array=array_combine($array, $array); $out=''; // Add code for jquery to use multiselect - if ($addjscombo && empty($conf->dol_use_jmobile) && $multiselect) + if ($addjscombo && empty($conf->dol_use_jmobile) && $jsbeautify) { + $minLengthToAutocomplete=0; $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2':$conf->global->MAIN_USE_JQUERY_MULTISELECT; $out.=' '; @@ -4419,7 +4451,7 @@ class Form { $out = ''; - // Add code for jquery to use multiselect + // Add code for jquery to use select2 if ($addjscombo && empty($conf->dol_use_jmobile)) { $tmpplugin='select2'; @@ -4605,6 +4637,236 @@ class Form } + /** + * Show linked object block. + * + * @param CommonObject $object Object we want to show links to + * @return int <0 if KO, >0 if OK + */ + function showLinkedObjectBlock($object) + { + global $conf,$langs,$hookmanager; + global $bc; + + $object->fetchObjectLinked(); + + // Bypass the default method + $hookmanager->initHooks(array('commonobject')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + + if (empty($reshook)) + { + $num = count($object->linkedObjects); + + foreach($object->linkedObjects as $objecttype => $objects) + { + $tplpath = $element = $subelement = $objecttype; + + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + $tplpath = $element.'/'.$subelement; + } + + // To work with non standard path + if ($objecttype == 'facture') { + $tplpath = 'compta/'.$element; + if (empty($conf->facture->enabled)) continue; // Do not show if module disabled + } + else if ($objecttype == 'propal') { + $tplpath = 'comm/'.$element; + if (empty($conf->propal->enabled)) continue; // Do not show if module disabled + } + else if ($objecttype == 'askpricesupplier') { + $tplpath = 'comm/'.$element; + if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled + } + else if ($objecttype == 'shipping' || $objecttype == 'shipment') { + $tplpath = 'expedition'; + if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled + } + else if ($objecttype == 'delivery') { + $tplpath = 'livraison'; + if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled + } + else if ($objecttype == 'invoice_supplier') { + $tplpath = 'fourn/facture'; + } + else if ($objecttype == 'order_supplier') { + $tplpath = 'fourn/commande'; + } + + global $linkedObjectBlock; + $linkedObjectBlock = $objects; + + // Output template part (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl')); + foreach($dirtpls as $reldir) + { + $res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php'); + if ($res) break; + } + } + + return $num; + } + } + + /** + * Show block with links to link to other objects. + * + * @param CommonObject $object Object we want to show links to + * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order') + * @return int <0 if KO, >0 if OK + */ + function showLinkToObjectBlock($object, $restrictlinksto=array()) + { + global $conf, $langs, $hookmanager; + global $bc; + + $linktoelem=''; + + if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); + + + if (((! is_array($restrictlinksto)) || in_array('order',$restrictlinksto)) + && ! empty($conf->commande->enabled)) + { + $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedOrder') . ''; + + print ' + + '; + + print '
global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>'; + + $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; + $sql .= ", " . MAIN_DB_PREFIX . "commande as c"; + $sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id . ''; + + $resqlorderlist = $this->db->query($sql); + if ($resqlorderlist) + { + $num = $this->db->num_rows($resqlorderlist); + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + while ($i < $num) + { + $objp = $this->db->fetch_object($resqlorderlist); + + $var = ! $var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $i ++; + } + print '
' . $langs->trans("Ref") . '' . $langs->trans("RefCustomer") . '' . $langs->trans("AmountHTShort") . '' . $langs->trans("Company") . '
'; + print ''; + print '' . $objp->ref . '' . $objp->ref_client . '' . price($objp->total_ht) . '' . $objp->name . '
'; + print '
     
'; + print '
'; + $this->db->free($resqlorderlist); + } else { + dol_print_error($this->db); + } + + print '
'; + } + + if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto)) + && ! empty($conf->fournisseur->enabled)) + { + $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedOrder') . ''; + + print ' + + '; + + print '
global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>'; + + $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; + $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c"; + $sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id; + + $resqlorderlist = $this->db->query($sql); + if ($resqlorderlist) + { + $num = $this->db->num_rows($resqlorderlist); + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + while ($i < $num) { + $objp = $this->db->fetch_object($resqlorderlist); + if ($objp->socid == $societe->id) { + $var = ! $var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + $i ++; + } + print '
' . $langs->trans("Ref") . '' . $langs->trans("RefSupplier") . '' . $langs->trans("AmountHTShort") . '' . $langs->trans("Company") . '
'; + print ''; + print '' . $objp->ref . '' . $objp->ref_supplier . '' . price($objp->total_ht) . '' . $objp->name . '
'; + print '
 
'; + print '
'; + $this->db->free($resqlorderlist); + } else { + dol_print_error($this->db); + } + + print '
'; + } + + + return $linktoelem; + } + /** * Return an html string with a select combo box to choose yes or no * @@ -4701,15 +4963,15 @@ class Form * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. * * @param object $object Object to show - * @param string $paramid Name of parameter to use to name the id into the URL link - * @param string $morehtml More html content to output just before the nav bar + * @param string $paramid Name of parameter to use to name the id into the URL link + * @param string $morehtml More html content to output just before the nav bar * @param int $shownav Show Condition (navigation is shown if value is 1) - * @param string $fieldid Nom du champ en base a utiliser pour select next et previous - * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous - * @param string $morehtmlref Code html supplementaire a afficher apres ref - * @param string $moreparam More param to add in nav link url. + * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) + * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * @param string $morehtmlref Code html supplementaire a afficher apres ref + * @param string $moreparam More param to add in nav link url. * @param int $nodbprefix Do not include DB prefix to forge table name - * @return string Portion HTML avec ref + boutons nav + * @return string Portion HTML avec ref + boutons nav */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0) { @@ -4722,33 +4984,47 @@ class Form //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); - $previous_ref = $object->ref_previous?''.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Previous"),'previous.png'):' ').'':''; - $next_ref = $object->ref_next?''.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Next"),'next.png'):' ').'':''; + //$previous_ref = $object->ref_previous?''.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Previous"),'previous.png'):' ').'':''; + //$next_ref = $object->ref_next?''.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Next"),'next.png'):' ').'':''; + $previous_ref = $object->ref_previous?''.(empty($conf->dol_use_jmobile)?'<':' ').'':''; + $next_ref = $object->ref_next?''.(empty($conf->dol_use_jmobile)?'>':' ').'':''; //print "xx".$previous_ref."x".$next_ref; - if ($previous_ref || $next_ref || $morehtml) { - $ret.='
'; - } + //if ($previous_ref || $next_ref || $morehtml) { + //$ret.=''; - $ret.=''; + //$ret.='
'; + $ret.='
'; + //} $ret.=dol_htmlentities($object->$fieldref); if ($morehtmlref) { $ret.=' '.$morehtmlref; } + $ret.='
'; + if ($previous_ref || $next_ref || $morehtml) + { + $ret.='
'.$morehtml; + //$ret.=''.$morehtml; + $ret.='
  • '.$morehtml.'
  • '; } if ($shownav && ($previous_ref || $next_ref)) { - $ret.='
    '.$previous_ref.''.$next_ref; + //$ret.=''.$previous_ref.''.$next_ref; + $ret.=''; + $ret.=''; } if ($previous_ref || $next_ref || $morehtml) { - $ret.='
    '; + //$ret.='
    '; + $ret.='
    '; } + $ret.='
    '; + return $ret; } @@ -4788,11 +5064,14 @@ class Form * @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto') * @param object $object Object containing data to retrieve file name * @param int $width Width of photo + * @param int $height Height of photo (auto if 0) + * @param int $caneditfield Add edit fields + * @param string $cssclass CSS name to use on img for photo * @return string HTML code to output photo */ - static function showphoto($modulepart,$object,$width=100) + static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin') { - global $conf; + global $conf,$langs; $entity = (! empty($object->entity) ? $object->entity : $conf->entity); $id = (! empty($object->id) ? $object->id : $object->rowid); @@ -4819,7 +5098,7 @@ class Form if ($object->photo) $file=get_exdir($id, 2, 0, 0, $object, 'invoice_supplier').'photos/'.$object->photo; if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; - }else { + } else { $dir=$conf->$modulepart->dir_output; if ($object->photo) $file=get_exdir($id, 2, 0, 0, $adherent, 'member').'photos/'.$object->photo; if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility @@ -4831,30 +5110,51 @@ class Form $cache='0'; if ($file && file_exists($dir."/".$file)) { - // TODO Link to large image $ret.=''; - $ret.=''; + $ret.='Photo'; $ret.=''; } else if ($altfile && file_exists($dir."/".$altfile)) { $ret.=''; - $ret.=''; + $ret.='Photo alt'; $ret.=''; } else - { - if (! empty($conf->gravatar->enabled) && $email) + { + $nophoto='/public/theme/common/nophoto.jpg'; + if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users + { + $nophoto='/public/theme/common/user_anonymous.png'; + if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png'; + if ($object->gender == 'woman') $nophoto='/public/theme/common/user_woman.png'; + } + + if (! empty($conf->gravatar->enabled) && $email) { + /** + * @see https://gravatar.com/site/implement/images/php/ + */ global $dolibarr_main_url_root; $ret.=''; - $ret.='Photo found on Gravatar'; // gravatar need md5 hash + $ret.='Gravatar avatar'; // gravatar need md5 hash } else - { - $ret.='No photo'; + { + $ret.='No photo'; } } + + if ($caneditfield) + { + if ($object->photo) $ret.="
    \n"; + $ret.=''; + if ($object->photo) $ret.=''; + $ret.=''; + $ret.=''; + $ret.='
    '.$langs->trans("Delete").'

    '.$langs->trans("PhotoFile").'
    '; + } + } else dol_print_error('','Call of showphoto with wrong parameters'); diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index e5d8fa5688e..d3ffa569a7a 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -105,6 +105,10 @@ class FormAdmin } $out.= ''; + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname); + return $out; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 4f600ac0705..a005fb2b228 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -210,6 +210,7 @@ class FormCompany * @param string $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show * @param string $htmlname Id of department * @return string String with HTML select + * @see select_country */ function select_state($selected='',$country_codeid=0, $htmlname='state_id') { @@ -234,7 +235,7 @@ class FormCompany $result=$this->db->query($sql); if ($result) { - if (!empty($htmlname)) $out.= ''; if ($country_codeid) $out.= ''; $num = $this->db->num_rows($result); $i = 0; @@ -277,13 +278,17 @@ class FormCompany } } if (! empty($htmlname)) $out.= ''; - if (! empty($htmlname) && $user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } else { dol_print_error($this->db); } + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + return $out; } @@ -418,6 +423,7 @@ class FormCompany * @param string $filter Add a SQL filter on list * @return void * @deprecated Use print xxx->select_juridicalstatus instead + * @see select_juridicalstatus() */ function select_forme_juridique($selected='', $country_codeid=0, $filter='') { @@ -431,9 +437,10 @@ class FormCompany * @param string $selected Preselected code of juridical type * @param int $country_codeid 0=list for all countries, otherwise list only country requested * @param string $filter Add a SQL filter on list + * @param string $htmlname HTML name of select * @return string String with HTML select */ - function select_juridicalstatus($selected='', $country_codeid=0, $filter='') + function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') { global $conf,$langs,$user; $langs->load("dict"); @@ -454,7 +461,7 @@ class FormCompany if ($resql) { $out.= '
    '; - $out.= ''; if ($country_codeid) $out.= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. $num = $this->db->num_rows($resql); @@ -488,7 +495,7 @@ class FormCompany // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out.= '\n"; + $out.= '\n"; $country=$val['country']; } } @@ -507,7 +514,12 @@ class FormCompany } } $out.= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + $out.= '
    '; } else diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 926ee8a337a..699060afcfc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -249,7 +249,7 @@ class FormFile * @param string $modelselected Model to preselect by default * @param string $allowgenifempty Allow generation even if list of template ($genallowed) is empty (show however a warning) * @param string $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined) - * @param int $iconPDF Obsolete, see getDocumentsLink + * @param int $iconPDF Deprecated, see getDocumentsLink * @param int $maxfilenamelength Max length for filename shown * @param string $noform Do not output html form tags * @param string $param More param on http links @@ -261,6 +261,11 @@ class FormFile */ function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='') { + // Deprecation warning + if (0 !== $iconPDF) { + dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING); + } + global $langs, $conf, $user, $hookmanager; global $form, $bc; @@ -684,7 +689,7 @@ class FormFile $out=''; $this->numoffiles=0; - $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir).'.pdf','/'), '\.meta$|\.png$'); + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // For ajax treatment $out.= '
    '.img_picto('', 'refresh').'
    '."\n"; @@ -713,7 +718,7 @@ class FormFile $mime=dol_mimetype($relativepath,'',0); if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; $out.= '>'; - $out.= img_pdf($file["name"],2); + $out.= img_mime($relativepath, $file["name"]); $out.= ''."\n"; $this->numoffiles++; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b9d5048db74..4e1a8ffc0c5 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -48,7 +48,16 @@ class FormMail extends Form var $withsubstit; // Show substitution array var $withfrom; - var $withto; // Show recipient emails + /** + * @var int + * @deprecated Fill withto with array before calling method. + * @see withto + */ + public $withtosocid; + /** + * @var int|int[] + */ + public $withto; // Show recipient emails var $withtofree; // Show free text for recipient emails var $withtocc; var $withtoccc; @@ -275,7 +284,7 @@ class FormMail extends Form $out.= "\n\n"; if ($this->withform == 1) { - $out.= '
    '."\n"; + $out.= ''."\n"; $out.= ''; $out.= ''; $out.= ''; @@ -703,6 +712,23 @@ class FormMail extends Form $out.= ''."\n"; if ($this->withform == 1) $out.= '
    '."\n"; + + // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTER is set + if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) + { + $out.= ''; + } + $out.= "\n"; return $out; diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php new file mode 100644 index 00000000000..a52238be1b9 --- /dev/null +++ b/htdocs/core/class/html.formmargin.class.php @@ -0,0 +1,273 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formmargin.class.php + * \ingroup core + * \brief Fichier de la classe des fonctions predefinie de composants html autre + */ + + +/** + * Classe permettant la generation de composants html autre + * Only common components are here. + */ +class FormMargin +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + + return 1; + } + + + + /** + * get array with margin information from lines of object + * + * @param CommonObject $object Object we want to get margin information for + * @param boolean $force_price True of not + * @return array Array with info + */ + function getMarginInfosArray($object, $force_price=false) + { + global $conf, $db; + + // Default returned array + $marginInfos = array( + 'pa_products' => 0, + 'pv_products' => 0, + 'margin_on_products' => 0, + 'margin_rate_products' => '', + 'mark_rate_products' => '', + 'pa_services' => 0, + 'pv_services' => 0, + 'margin_on_services' => 0, + 'margin_rate_services' => '', + 'mark_rate_services' => '', + 'pa_total' => 0, + 'pv_total' => 0, + 'total_margin' => 0, + 'total_margin_rate' => '', + 'total_mark_rate' => '' + ); + + foreach($object->lines as $line) + { + if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $product = new ProductFournisseur($db); + if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) + $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); + if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) + $line->pa_ht += $product->fourn_unitcharges; + } + // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente + if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { + $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); + } + + // calcul des marges + if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise + $pa = $line->qty * $line->pa_ht; + $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); + if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit + $marginInfos['pa_products'] += $pa; + $marginInfos['pv_products'] += $pv; + $marginInfos['pa_total'] += $pa; + $marginInfos['pv_total'] += $pv; + // if credit note, margin = -1 * (abs(selling_price) - buying_price) + if ($pv < 0) + $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa); + else + $marginInfos['margin_on_products'] += $pv - $pa; + } + elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service + $marginInfos['pa_services'] += $pa; + $marginInfos['pv_services'] += $pv; + $marginInfos['pa_total'] += $pa; + $marginInfos['pv_total'] += $pv; + // if credit note, margin = -1 * (abs(selling_price) - buying_price) + if ($pv < 0) + $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa); + else + $marginInfos['margin_on_services'] += $pv - $pa; + } + elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total + $marginInfos['pa_total'] += $pa; + $marginInfos['pv_total'] += $pv; + } + } + else { + $type=$line->product_type?$line->product_type:$line->fk_product_type; + if ($type == 0) { // product + $pa = $line->qty * $line->pa_ht; + $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); + $marginInfos['pa_products'] += $pa; + $marginInfos['pv_products'] += $pv; + $marginInfos['pa_total'] += $pa; + $marginInfos['pv_total'] += $pv; + // if credit note, margin = -1 * (abs(selling_price) - buying_price) + if ($pv < 0) + $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa); + else + $marginInfos['margin_on_products'] += $pv - $pa; + } + elseif ($type == 1) { // service + $pa = $line->qty * $line->pa_ht; + $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); + $marginInfos['pa_services'] += $pa; + $marginInfos['pv_services'] += $pv; + $marginInfos['pa_total'] += $pa; + $marginInfos['pv_total'] += $pv; + // if credit note, margin = -1 * (abs(selling_price) - buying_price) + if ($pv < 0) + $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa); + else + $marginInfos['margin_on_services'] += $pv - $pa; + } + } + } + if ($marginInfos['pa_products'] > 0) + $marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products']; + if ($marginInfos['pv_products'] > 0) + $marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products']; + + if ($marginInfos['pa_services'] > 0) + $marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services']; + if ($marginInfos['pv_services'] > 0) + $marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services']; + + // if credit note, margin = -1 * (abs(selling_price) - buying_price) + if ($marginInfos['pv_total'] < 0) + $marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']); + else + $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; + if ($marginInfos['pa_total'] > 0) + $marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total']; + if ($marginInfos['pv_total'] > 0) + $marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total']; + + return $marginInfos; + } + + /** + * Show the array with all margin infos + * + * @param CommonObject $object Object we want to get margin information for + * @param boolean $force_price Force price + * @return void + */ + function displayMarginInfos($object, $force_price=false) + { + global $langs, $conf, $user; + + if (! empty($user->societe_id)) return; + + if (! $user->rights->margins->liretous) return; + + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); + + $marginInfo = $this->getMarginInfosArray($object, $force_price); + + if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better + { + print $langs->trans('ShowMarginInfos').' : '; + $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + + print ''; + if (!empty($hidemargininfos)) print ''; + } + + print ''; + print ''; + print ''; + print ''; + if ($conf->global->MARGIN_TYPE == "1") + print ''; + else + print ''; + print ''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print ''; + print ''; + + if (! empty($conf->product->enabled)) + { + //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print ''; + print ''; + } + + if (! empty($conf->service->enabled)) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print ''; + print ''; + } + + if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print ''; + print ''; + } + print '
    '.$langs->trans('Margins').''.$langs->trans('SellingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'
    '.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'
    '.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'
    '.$langs->trans('TotalMargin').''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'
    '; + } + +} + diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 08c19463d27..4f286d26eb7 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -592,6 +592,7 @@ class FormOther * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @return void * @deprecated + * @see selectColor() */ function select_color($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='') { @@ -599,7 +600,7 @@ class FormOther } /** - * Output a HTML code to select a color + * Output a HTML code to select a color. Field will return an hexa color like '334455'. * * @param string $set_color Pre-selected color * @param string $prefix Name of HTML field @@ -611,6 +612,11 @@ class FormOther */ function selectColor($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='', $morecss='') { + // Deprecation warning + if ($form_name) { + dol_syslog(__METHOD__ . ": form_name parameter is deprecated", LOG_WARNING); + } + global $langs,$conf; $out=''; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9469b680631..6411c76eeab 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -53,9 +53,10 @@ class FormProjets * @param int $show_empty Add an empty line * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled * @return int Nber of project if OK, <0 if KO */ - function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0) + function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0) { global $user,$conf,$langs; @@ -82,7 +83,7 @@ class FormProjets if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; $sql.= " ORDER BY p.ref ASC"; - dol_syslog(get_class($this)."::select_projects", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -100,7 +101,7 @@ class FormProjets } if (empty($option_only)) { - $out.= ''; } if (!empty($show_empty)) { $out.= ''; @@ -147,13 +148,15 @@ class FormProjets $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); } - if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) + if (!empty($selected) && $selected == $obj->rowid) { - $out.= ''; + $out.= '