@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | const TYPE_USER = 'user'; |
| 53 | 53 | const TYPE_PROJECT = 'project'; |
| 54 | 54 | const TYPE_ACCOUNT = 'bank_account'; |
| 55 | - const TYPE_BANK_LINE = 'bank_line'; |
|
| 56 | - const TYPE_WAREHOUSE = 'warehouse'; |
|
| 57 | - const TYPE_ACTIONCOMM = 'actioncomm'; |
|
| 58 | - const TYPE_WEBSITE_PAGE = 'website_page'; |
|
| 55 | + const TYPE_BANK_LINE = 'bank_line'; |
|
| 56 | + const TYPE_WAREHOUSE = 'warehouse'; |
|
| 57 | + const TYPE_ACTIONCOMM = 'actioncomm'; |
|
| 58 | + const TYPE_WEBSITE_PAGE = 'website_page'; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | 'member' => 3, |
| 74 | 74 | 'contact' => 4, |
| 75 | 75 | 'bank_account' => 5, |
| 76 | - 'project' => 6, |
|
| 76 | + 'project' => 6, |
|
| 77 | 77 | 'user' => 7, |
| 78 | 78 | 'bank_line' => 8, |
| 79 | 79 | 'warehouse' => 9, |
| 80 | - 'actioncomm' => 10, |
|
| 80 | + 'actioncomm' => 10, |
|
| 81 | 81 | 'website_page' => 11 |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - /** |
|
| 84 | + /** |
|
| 85 | 85 | * @var array Code mapping from ID |
| 86 | 86 | * |
| 87 | 87 | * @note This array should be removed in future, once previous constants are moved to the string value. Deprecated |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | 7 => 'user', |
| 98 | 98 | 8 => 'bank_line', |
| 99 | 99 | 9 => 'warehouse', |
| 100 | - 10 => 'actioncomm', |
|
| 100 | + 10 => 'actioncomm', |
|
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | 'customer' => 'soc', |
| 110 | 110 | 'supplier' => 'soc', |
| 111 | 111 | 'contact' => 'socpeople', |
| 112 | - 'bank_account' => 'account', |
|
| 113 | - ); |
|
| 112 | + 'bank_account' => 'account', |
|
| 113 | + ); |
|
| 114 | 114 | |
| 115 | - /** |
|
| 115 | + /** |
|
| 116 | 116 | * @var array Category tables mapping from type string (llx_categorie_...) when value does not match |
| 117 | 117 | * |
| 118 | 118 | * @note Move to const array when PHP 5.6 will be our minimum target |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | protected $MAP_CAT_TABLE = array( |
| 121 | 121 | 'customer' => 'societe', |
| 122 | 122 | 'supplier' => 'fournisseur', |
| 123 | - 'bank_account'=> 'account', |
|
| 123 | + 'bank_account'=> 'account', |
|
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - /** |
|
| 126 | + /** |
|
| 127 | 127 | * @var array Object class mapping from type string |
| 128 | 128 | * |
| 129 | 129 | * @note Move to const array when PHP 5.6 will be our minimum target |
@@ -137,33 +137,33 @@ discard block |
||
| 137 | 137 | 'user' => 'User', |
| 138 | 138 | 'account' => 'Account', // old for bank account |
| 139 | 139 | 'bank_account' => 'Account', |
| 140 | - 'project' => 'Project', |
|
| 141 | - 'warehouse'=> 'Entrepot', |
|
| 142 | - 'actioncomm' => 'ActionComm', |
|
| 140 | + 'project' => 'Project', |
|
| 141 | + 'warehouse'=> 'Entrepot', |
|
| 142 | + 'actioncomm' => 'ActionComm', |
|
| 143 | 143 | 'website_page' => 'WebsitePage' |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * @var array Title Area mapping from type string |
|
| 148 | - * |
|
| 149 | - * @note Move to const array when PHP 5.6 will be our minimum target |
|
| 150 | - */ |
|
| 151 | - public static $MAP_TYPE_TITLE_AREA = array( |
|
| 152 | - 'product' => 'ProductsCategoriesArea', |
|
| 153 | - 'customer' => 'CustomersCategoriesArea', |
|
| 154 | - 'supplier' => 'SuppliersCategoriesArea', |
|
| 155 | - 'member' => 'MembersCategoriesArea', |
|
| 156 | - 'contact' => 'ContactsCategoriesArea', |
|
| 157 | - 'user' => 'UsersCategoriesArea', |
|
| 158 | - 'account' => 'AccountsCategoriesArea', // old for bank account |
|
| 159 | - 'bank_account' => 'AccountsCategoriesArea', |
|
| 160 | - 'project' => 'ProjectsCategoriesArea', |
|
| 161 | - 'warehouse'=> 'StocksCategoriesArea', |
|
| 162 | - 'actioncomm' => 'ActioncommCategoriesArea', |
|
| 163 | - 'website_page' => 'WebsitePageCategoriesArea' |
|
| 164 | - ); |
|
| 165 | - |
|
| 166 | - /** |
|
| 146 | + /** |
|
| 147 | + * @var array Title Area mapping from type string |
|
| 148 | + * |
|
| 149 | + * @note Move to const array when PHP 5.6 will be our minimum target |
|
| 150 | + */ |
|
| 151 | + public static $MAP_TYPE_TITLE_AREA = array( |
|
| 152 | + 'product' => 'ProductsCategoriesArea', |
|
| 153 | + 'customer' => 'CustomersCategoriesArea', |
|
| 154 | + 'supplier' => 'SuppliersCategoriesArea', |
|
| 155 | + 'member' => 'MembersCategoriesArea', |
|
| 156 | + 'contact' => 'ContactsCategoriesArea', |
|
| 157 | + 'user' => 'UsersCategoriesArea', |
|
| 158 | + 'account' => 'AccountsCategoriesArea', // old for bank account |
|
| 159 | + 'bank_account' => 'AccountsCategoriesArea', |
|
| 160 | + 'project' => 'ProjectsCategoriesArea', |
|
| 161 | + 'warehouse'=> 'StocksCategoriesArea', |
|
| 162 | + 'actioncomm' => 'ActioncommCategoriesArea', |
|
| 163 | + 'website_page' => 'WebsitePageCategoriesArea' |
|
| 164 | + ); |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | 167 | * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. |
| 168 | 168 | * |
| 169 | 169 | * @note Move to const array when PHP 5.6 will be our minimum target |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | 'contact' => 'socpeople', |
| 176 | 176 | 'account' => 'bank_account', // old for bank account |
| 177 | 177 | 'project' => 'projet', |
| 178 | - 'warehouse'=> 'entrepot' |
|
| 178 | + 'warehouse'=> 'entrepot' |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | public $table_element = 'categorie'; |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * @var int ID |
|
| 193 | - */ |
|
| 192 | + * @var int ID |
|
| 193 | + */ |
|
| 194 | 194 | public $fk_parent; |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | - * @var string Category label |
|
| 198 | - */ |
|
| 197 | + * @var string Category label |
|
| 198 | + */ |
|
| 199 | 199 | public $label; |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | * @see Categorie::TYPE_USER |
| 226 | 226 | * @see Categorie::TYPE_PROJECT |
| 227 | 227 | * @see Categorie::TYPE_BANK_LINE |
| 228 | - * @see Categorie::TYPE_WAREHOUSE |
|
| 229 | - * @see Categorie::TYPE_ACTIONCOMM |
|
| 228 | + * @see Categorie::TYPE_WAREHOUSE |
|
| 229 | + * @see Categorie::TYPE_ACTIONCOMM |
|
| 230 | 230 | */ |
| 231 | 231 | public $type; |
| 232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public $cats = array(); |
| 237 | 237 | |
| 238 | - /** |
|
| 238 | + /** |
|
| 239 | 239 | * @var array Mother of table |
| 240 | 240 | */ |
| 241 | 241 | public $motherof = array(); |
@@ -464,20 +464,20 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | if (!$error) |
| 466 | 466 | { |
| 467 | - // Call trigger |
|
| 468 | - $result = $this->call_trigger('CATEGORY_CREATE', $user); |
|
| 469 | - if ($result < 0) { $error++; } |
|
| 470 | - // End call triggers |
|
| 467 | + // Call trigger |
|
| 468 | + $result = $this->call_trigger('CATEGORY_CREATE', $user); |
|
| 469 | + if ($result < 0) { $error++; } |
|
| 470 | + // End call triggers |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if (!$error) |
|
| 474 | - { |
|
| 475 | - $this->db->commit(); |
|
| 476 | - return $id; |
|
| 477 | - } else { |
|
| 478 | - $this->db->rollback(); |
|
| 479 | - return -3; |
|
| 480 | - } |
|
| 473 | + if (!$error) |
|
| 474 | + { |
|
| 475 | + $this->db->commit(); |
|
| 476 | + return $id; |
|
| 477 | + } else { |
|
| 478 | + $this->db->rollback(); |
|
| 479 | + return -3; |
|
| 480 | + } |
|
| 481 | 481 | } else { |
| 482 | 482 | $this->db->rollback(); |
| 483 | 483 | return -2; |
@@ -550,10 +550,10 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | if (!$error) |
| 552 | 552 | { |
| 553 | - // Call trigger |
|
| 554 | - $result = $this->call_trigger('CATEGORY_MODIFY', $user); |
|
| 555 | - if ($result < 0) { $error++; $this->db->rollback(); return -1; } |
|
| 556 | - // End call triggers |
|
| 553 | + // Call trigger |
|
| 554 | + $result = $this->call_trigger('CATEGORY_MODIFY', $user); |
|
| 555 | + if ($result < 0) { $error++; $this->db->rollback(); return -1; } |
|
| 556 | + // End call triggers |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | $this->db->commit(); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * Delete a category from database |
| 571 | 571 | * |
| 572 | 572 | * @param User $user Object user that ask to delete |
| 573 | - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 573 | + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 574 | 574 | * @return int <0 KO >0 OK |
| 575 | 575 | */ |
| 576 | 576 | public function delete($user, $notrigger = 0) |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | $error = 0; |
| 581 | 581 | |
| 582 | - // Clean parameters |
|
| 582 | + // Clean parameters |
|
| 583 | 583 | $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); |
| 584 | 584 | |
| 585 | 585 | dol_syslog(get_class($this)."::remove"); |
@@ -588,10 +588,10 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | if (!$error && !$notrigger) |
| 590 | 590 | { |
| 591 | - // Call trigger |
|
| 592 | - $result = $this->call_trigger('CATEGORY_DELETE', $user); |
|
| 593 | - if ($result < 0) $error++; |
|
| 594 | - // End call triggers |
|
| 591 | + // Call trigger |
|
| 592 | + $result = $this->call_trigger('CATEGORY_DELETE', $user); |
|
| 593 | + if ($result < 0) $error++; |
|
| 594 | + // End call triggers |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /* FIX #1317 : Check for child category and move up 1 level*/ |
@@ -608,26 +608,26 @@ discard block |
||
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - $arraydelete = array( |
|
| 612 | - 'categorie_societe' => 'fk_categorie', |
|
| 613 | - 'categorie_fournisseur' => 'fk_categorie', |
|
| 614 | - 'categorie_product' => 'fk_categorie', |
|
| 615 | - 'categorie_member' => 'fk_categorie', |
|
| 616 | - 'categorie_contact' => 'fk_categorie', |
|
| 617 | - 'categorie_account' => 'fk_categorie', |
|
| 618 | - 'bank_class' => 'fk_categ', |
|
| 619 | - 'categorie_lang' => 'fk_category', |
|
| 620 | - 'categorie' => 'rowid', |
|
| 621 | - ); |
|
| 622 | - foreach ($arraydelete as $key => $value) { |
|
| 623 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; |
|
| 624 | - $sql .= " WHERE ".$value." = ".$this->id; |
|
| 625 | - if (!$this->db->query($sql)) { |
|
| 626 | - $this->errors[] = $this->db->lasterror(); |
|
| 627 | - dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); |
|
| 628 | - $error++; |
|
| 629 | - } |
|
| 630 | - } |
|
| 611 | + $arraydelete = array( |
|
| 612 | + 'categorie_societe' => 'fk_categorie', |
|
| 613 | + 'categorie_fournisseur' => 'fk_categorie', |
|
| 614 | + 'categorie_product' => 'fk_categorie', |
|
| 615 | + 'categorie_member' => 'fk_categorie', |
|
| 616 | + 'categorie_contact' => 'fk_categorie', |
|
| 617 | + 'categorie_account' => 'fk_categorie', |
|
| 618 | + 'bank_class' => 'fk_categ', |
|
| 619 | + 'categorie_lang' => 'fk_category', |
|
| 620 | + 'categorie' => 'rowid', |
|
| 621 | + ); |
|
| 622 | + foreach ($arraydelete as $key => $value) { |
|
| 623 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; |
|
| 624 | + $sql .= " WHERE ".$value." = ".$this->id; |
|
| 625 | + if (!$this->db->query($sql)) { |
|
| 626 | + $this->errors[] = $this->db->lasterror(); |
|
| 627 | + dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); |
|
| 628 | + $error++; |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | 632 | // Removed extrafields |
| 633 | 633 | if (!$error) |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 653 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 654 | 654 | /** |
| 655 | 655 | * Link an object to the category |
| 656 | 656 | * |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | */ |
| 661 | 661 | public function add_type($obj, $type = '') |
| 662 | 662 | { |
| 663 | - // phpcs:enable |
|
| 663 | + // phpcs:enable |
|
| 664 | 664 | global $user, $langs, $conf; |
| 665 | 665 | |
| 666 | 666 | $error = 0; |
@@ -669,9 +669,9 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | if (empty($type)) $type = $obj->element; |
| 671 | 671 | |
| 672 | - $this->db->begin(); |
|
| 672 | + $this->db->begin(); |
|
| 673 | 673 | |
| 674 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); |
|
| 674 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); |
|
| 675 | 675 | $sql .= " (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).")"; |
| 676 | 676 | $sql .= " VALUES (".$this->id.", ".$obj->id.")"; |
| 677 | 677 | |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | { |
| 690 | 690 | if ($this->db->num_rows($resql) > 0) |
| 691 | 691 | { |
| 692 | - $objparent = $this->db->fetch_object($resql); |
|
| 692 | + $objparent = $this->db->fetch_object($resql); |
|
| 693 | 693 | |
| 694 | 694 | if (!empty($objparent->fk_parent)) |
| 695 | 695 | { |
@@ -712,29 +712,29 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | if ($error) |
| 714 | 714 | { |
| 715 | - $this->db->rollback(); |
|
| 715 | + $this->db->rollback(); |
|
| 716 | 716 | return -1; |
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | |
| 721 | 721 | |
| 722 | - // Call trigger |
|
| 722 | + // Call trigger |
|
| 723 | 723 | $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger |
| 724 | 724 | $result = $this->call_trigger('CATEGORY_LINK', $user); |
| 725 | - if ($result < 0) { $error++; } |
|
| 726 | - // End call triggers |
|
| 725 | + if ($result < 0) { $error++; } |
|
| 726 | + // End call triggers |
|
| 727 | 727 | |
| 728 | 728 | if (!$error) |
| 729 | 729 | { |
| 730 | - $this->db->commit(); |
|
| 731 | - return 1; |
|
| 730 | + $this->db->commit(); |
|
| 731 | + return 1; |
|
| 732 | 732 | } else { |
| 733 | - $this->db->rollback(); |
|
| 734 | - return -2; |
|
| 733 | + $this->db->rollback(); |
|
| 734 | + return -2; |
|
| 735 | 735 | } |
| 736 | 736 | } else { |
| 737 | - $this->db->rollback(); |
|
| 737 | + $this->db->rollback(); |
|
| 738 | 738 | if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 739 | 739 | { |
| 740 | 740 | $this->error = $this->db->lasterrno(); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | } |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 749 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 750 | 750 | /** |
| 751 | 751 | * Delete object from category |
| 752 | 752 | * |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | public function del_type($obj, $type) |
| 759 | 759 | { |
| 760 | - // phpcs:enable |
|
| 760 | + // phpcs:enable |
|
| 761 | 761 | global $user, $langs, $conf; |
| 762 | 762 | |
| 763 | 763 | $error = 0; |
@@ -771,31 +771,31 @@ discard block |
||
| 771 | 771 | dol_syslog(get_class($this)."::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $this->db->begin(); |
|
| 774 | + $this->db->begin(); |
|
| 775 | 775 | |
| 776 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); |
|
| 776 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); |
|
| 777 | 777 | $sql .= " WHERE fk_categorie = ".$this->id; |
| 778 | 778 | $sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id; |
| 779 | 779 | |
| 780 | 780 | dol_syslog(get_class($this).'::del_type', LOG_DEBUG); |
| 781 | 781 | if ($this->db->query($sql)) |
| 782 | 782 | { |
| 783 | - // Call trigger |
|
| 783 | + // Call trigger |
|
| 784 | 784 | $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger |
| 785 | 785 | $result = $this->call_trigger('CATEGORY_UNLINK', $user); |
| 786 | - if ($result < 0) { $error++; } |
|
| 787 | - // End call triggers |
|
| 786 | + if ($result < 0) { $error++; } |
|
| 787 | + // End call triggers |
|
| 788 | 788 | |
| 789 | 789 | if (!$error) |
| 790 | 790 | { |
| 791 | - $this->db->commit(); |
|
| 792 | - return 1; |
|
| 791 | + $this->db->commit(); |
|
| 792 | + return 1; |
|
| 793 | 793 | } else { |
| 794 | - $this->db->rollback(); |
|
| 795 | - return -2; |
|
| 794 | + $this->db->rollback(); |
|
| 795 | + return -2; |
|
| 796 | 796 | } |
| 797 | 797 | } else { |
| 798 | - $this->db->rollback(); |
|
| 798 | + $this->db->rollback(); |
|
| 799 | 799 | $this->error = $this->db->lasterror(); |
| 800 | 800 | return -1; |
| 801 | 801 | } |
@@ -842,14 +842,14 @@ discard block |
||
| 842 | 842 | { |
| 843 | 843 | while ($rec = $this->db->fetch_array($resql)) |
| 844 | 844 | { |
| 845 | - if ($onlyids) |
|
| 846 | - { |
|
| 847 | - $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; |
|
| 848 | - } else { |
|
| 849 | - $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); |
|
| 850 | - $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); |
|
| 851 | - $objs[] = $obj; |
|
| 852 | - } |
|
| 845 | + if ($onlyids) |
|
| 846 | + { |
|
| 847 | + $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; |
|
| 848 | + } else { |
|
| 849 | + $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); |
|
| 850 | + $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); |
|
| 851 | + $objs[] = $obj; |
|
| 852 | + } |
|
| 853 | 853 | } |
| 854 | 854 | return $objs; |
| 855 | 855 | } else { |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | return $categories; |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 991 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 992 | 992 | /** |
| 993 | 993 | * Return direct childs id of a category into an array |
| 994 | 994 | * |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | */ |
| 997 | 997 | public function get_filles() |
| 998 | 998 | { |
| 999 | - // phpcs:enable |
|
| 999 | + // phpcs:enable |
|
| 1000 | 1000 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; |
| 1001 | 1001 | $sql .= " WHERE fk_parent = ".$this->id; |
| 1002 | 1002 | $sql .= " AND entity IN (".getEntity('category').")"; |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1021 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1022 | 1022 | /** |
| 1023 | 1023 | * Load the array this->motherof that is array(id_son=>id_parent, ...) |
| 1024 | 1024 | * |
@@ -1026,8 +1026,8 @@ discard block |
||
| 1026 | 1026 | */ |
| 1027 | 1027 | protected function load_motherof() |
| 1028 | 1028 | { |
| 1029 | - // phpcs:enable |
|
| 1030 | - $this->motherof = array(); |
|
| 1029 | + // phpcs:enable |
|
| 1030 | + $this->motherof = array(); |
|
| 1031 | 1031 | |
| 1032 | 1032 | // Load array[child]=parent |
| 1033 | 1033 | $sql = "SELECT fk_parent as id_parent, rowid as id_son"; |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | } |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1053 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1054 | 1054 | /** |
| 1055 | 1055 | * Rebuilding the category tree as an array |
| 1056 | 1056 | * Return an array of table('id','id_mere',...) trie selon arbre et avec: |
@@ -1063,17 +1063,17 @@ discard block |
||
| 1063 | 1063 | * |
| 1064 | 1064 | * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...) |
| 1065 | 1065 | * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. |
| 1066 | - * $markafterid can be an : |
|
| 1067 | - * - int (id of category) |
|
| 1068 | - * - string (categories ids separated by comma) |
|
| 1069 | - * - array (list of categories ids) |
|
| 1070 | - * @param int $include [=0] Removed or 1=Keep only |
|
| 1066 | + * $markafterid can be an : |
|
| 1067 | + * - int (id of category) |
|
| 1068 | + * - string (categories ids separated by comma) |
|
| 1069 | + * - array (list of categories ids) |
|
| 1070 | + * @param int $include [=0] Removed or 1=Keep only |
|
| 1071 | 1071 | * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error |
| 1072 | 1072 | */ |
| 1073 | 1073 | public function get_full_arbo($type, $markafterid = 0, $include = 0) |
| 1074 | 1074 | { |
| 1075 | - // phpcs:enable |
|
| 1076 | - global $conf, $langs; |
|
| 1075 | + // phpcs:enable |
|
| 1076 | + global $conf, $langs; |
|
| 1077 | 1077 | |
| 1078 | 1078 | if (!is_numeric($type)) $type = $this->MAP_ID[$type]; |
| 1079 | 1079 | if (is_null($type)) { |
@@ -1081,23 +1081,23 @@ discard block |
||
| 1081 | 1081 | return -1; |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | - if (is_string($markafterid)) |
|
| 1085 | - { |
|
| 1086 | - $markafterid = explode(',', $markafterid); |
|
| 1087 | - } elseif (is_numeric($markafterid)) |
|
| 1088 | - { |
|
| 1089 | - if ($markafterid > 0) |
|
| 1090 | - { |
|
| 1091 | - $markafterid = array($markafterid); |
|
| 1092 | - } else { |
|
| 1093 | - $markafterid = array(); |
|
| 1094 | - } |
|
| 1095 | - } elseif (!is_array($markafterid)) |
|
| 1096 | - { |
|
| 1097 | - $markafterid = array(); |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - $this->cats = array(); |
|
| 1084 | + if (is_string($markafterid)) |
|
| 1085 | + { |
|
| 1086 | + $markafterid = explode(',', $markafterid); |
|
| 1087 | + } elseif (is_numeric($markafterid)) |
|
| 1088 | + { |
|
| 1089 | + if ($markafterid > 0) |
|
| 1090 | + { |
|
| 1091 | + $markafterid = array($markafterid); |
|
| 1092 | + } else { |
|
| 1093 | + $markafterid = array(); |
|
| 1094 | + } |
|
| 1095 | + } elseif (!is_array($markafterid)) |
|
| 1096 | + { |
|
| 1097 | + $markafterid = array(); |
|
| 1098 | + } |
|
| 1099 | + |
|
| 1100 | + $this->cats = array(); |
|
| 1101 | 1101 | |
| 1102 | 1102 | // Init this->motherof that is array(id_son=>id_parent, ...) |
| 1103 | 1103 | $this->load_motherof(); |
@@ -1141,27 +1141,27 @@ discard block |
||
| 1141 | 1141 | $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - // Include or exclude leaf including $markafterid from tree |
|
| 1145 | - if (count($markafterid) > 0) |
|
| 1146 | - { |
|
| 1147 | - $keyfiltercatid = '('.implode('|', $markafterid).')'; |
|
| 1148 | - |
|
| 1149 | - //print "Look to discard category ".$markafterid."\n"; |
|
| 1150 | - $keyfilter1 = '^'.$keyfiltercatid.'$'; |
|
| 1151 | - $keyfilter2 = '_'.$keyfiltercatid.'$'; |
|
| 1152 | - $keyfilter3 = '^'.$keyfiltercatid.'_'; |
|
| 1153 | - $keyfilter4 = '_'.$keyfiltercatid.'_'; |
|
| 1154 | - foreach ($this->cats as $key => $val) |
|
| 1155 | - { |
|
| 1156 | - $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) |
|
| 1157 | - || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); |
|
| 1158 | - |
|
| 1159 | - if (($test && !$include) || (!$test && $include)) |
|
| 1160 | - { |
|
| 1161 | - unset($this->cats[$key]); |
|
| 1162 | - } |
|
| 1163 | - } |
|
| 1164 | - } |
|
| 1144 | + // Include or exclude leaf including $markafterid from tree |
|
| 1145 | + if (count($markafterid) > 0) |
|
| 1146 | + { |
|
| 1147 | + $keyfiltercatid = '('.implode('|', $markafterid).')'; |
|
| 1148 | + |
|
| 1149 | + //print "Look to discard category ".$markafterid."\n"; |
|
| 1150 | + $keyfilter1 = '^'.$keyfiltercatid.'$'; |
|
| 1151 | + $keyfilter2 = '_'.$keyfiltercatid.'$'; |
|
| 1152 | + $keyfilter3 = '^'.$keyfiltercatid.'_'; |
|
| 1153 | + $keyfilter4 = '_'.$keyfiltercatid.'_'; |
|
| 1154 | + foreach ($this->cats as $key => $val) |
|
| 1155 | + { |
|
| 1156 | + $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) |
|
| 1157 | + || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); |
|
| 1158 | + |
|
| 1159 | + if (($test && !$include) || (!$test && $include)) |
|
| 1160 | + { |
|
| 1161 | + unset($this->cats[$key]); |
|
| 1162 | + } |
|
| 1163 | + } |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | 1166 | dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); |
| 1167 | 1167 | $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | return $this->cats; |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1174 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1175 | 1175 | /** |
| 1176 | 1176 | * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. |
| 1177 | 1177 | * It is called by get_full_arbo() |
@@ -1182,10 +1182,10 @@ discard block |
||
| 1182 | 1182 | * @return void |
| 1183 | 1183 | * @see get_full_arbo() |
| 1184 | 1184 | */ |
| 1185 | - public function build_path_from_id_categ($id_categ, $protection = 1000) |
|
| 1186 | - { |
|
| 1187 | - // phpcs:enable |
|
| 1188 | - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); |
|
| 1185 | + public function build_path_from_id_categ($id_categ, $protection = 1000) |
|
| 1186 | + { |
|
| 1187 | + // phpcs:enable |
|
| 1188 | + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); |
|
| 1189 | 1189 | |
| 1190 | 1190 | if (!empty($this->cats[$id_categ]['fullpath'])) |
| 1191 | 1191 | { |
@@ -1215,10 +1215,10 @@ discard block |
||
| 1215 | 1215 | // We count number of _ to have level |
| 1216 | 1216 | $this->cats[$id_categ]['level'] = dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); |
| 1217 | 1217 | |
| 1218 | - return; |
|
| 1219 | - } |
|
| 1218 | + return; |
|
| 1219 | + } |
|
| 1220 | 1220 | |
| 1221 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1221 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1222 | 1222 | /** |
| 1223 | 1223 | * Display content of $this->cats |
| 1224 | 1224 | * |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | */ |
| 1227 | 1227 | public function debug_cats() |
| 1228 | 1228 | { |
| 1229 | - // phpcs:enable |
|
| 1229 | + // phpcs:enable |
|
| 1230 | 1230 | // Display $this->cats |
| 1231 | 1231 | foreach ($this->cats as $key => $val) |
| 1232 | 1232 | { |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | |
| 1244 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1244 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1245 | 1245 | /** |
| 1246 | 1246 | * Returns all categories |
| 1247 | 1247 | * |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | */ |
| 1252 | 1252 | public function get_all_categories($type = null, $parent = false) |
| 1253 | 1253 | { |
| 1254 | - // phpcs:enable |
|
| 1254 | + // phpcs:enable |
|
| 1255 | 1255 | if (!is_numeric($type)) $type = $this->MAP_ID[$type]; |
| 1256 | 1256 | |
| 1257 | 1257 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; |
@@ -1287,11 +1287,11 @@ discard block |
||
| 1287 | 1287 | */ |
| 1288 | 1288 | public function get_main_categories($type = null) |
| 1289 | 1289 | { |
| 1290 | - // phpcs:enable |
|
| 1291 | - return $this->get_all_categories($type, true); |
|
| 1290 | + // phpcs:enable |
|
| 1291 | + return $this->get_all_categories($type, true); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1294 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1295 | 1295 | /** |
| 1296 | 1296 | * Check if no category with same label already exists for this cat's parent or root and for this cat's type |
| 1297 | 1297 | * |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | */ |
| 1300 | 1300 | public function already_exists() |
| 1301 | 1301 | { |
| 1302 | - // phpcs:enable |
|
| 1302 | + // phpcs:enable |
|
| 1303 | 1303 | $type = $this->type; |
| 1304 | 1304 | |
| 1305 | 1305 | if (!is_numeric($type)) $type = $this->MAP_ID[$type]; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | |
| 1344 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1344 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1345 | 1345 | /** |
| 1346 | 1346 | * Returns the path of the category, with the names of the categories |
| 1347 | 1347 | * separated by $sep (" >> " by default) |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | */ |
| 1355 | 1355 | public function print_all_ways($sep = ' >> ', $url = '', $nocolor = 0, $addpicto = 0) |
| 1356 | 1356 | { |
| 1357 | - // phpcs:enable |
|
| 1357 | + // phpcs:enable |
|
| 1358 | 1358 | $ways = array(); |
| 1359 | 1359 | |
| 1360 | 1360 | $allways = $this->get_all_ways(); // Load array of categories |
@@ -1365,27 +1365,27 @@ discard block |
||
| 1365 | 1365 | $forced_color = ''; |
| 1366 | 1366 | foreach ($way as $cat) |
| 1367 | 1367 | { |
| 1368 | - $i++; |
|
| 1369 | - |
|
| 1370 | - if (empty($nocolor)) |
|
| 1371 | - { |
|
| 1372 | - $forced_color = 'toreplace'; |
|
| 1373 | - if ($i == count($way)) |
|
| 1374 | - { |
|
| 1375 | - // Check contrast with background and correct text color |
|
| 1376 | - $forced_color = 'categtextwhite'; |
|
| 1377 | - if ($cat->color) |
|
| 1378 | - { |
|
| 1379 | - if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; |
|
| 1380 | - } |
|
| 1381 | - } |
|
| 1382 | - } |
|
| 1368 | + $i++; |
|
| 1369 | + |
|
| 1370 | + if (empty($nocolor)) |
|
| 1371 | + { |
|
| 1372 | + $forced_color = 'toreplace'; |
|
| 1373 | + if ($i == count($way)) |
|
| 1374 | + { |
|
| 1375 | + // Check contrast with background and correct text color |
|
| 1376 | + $forced_color = 'categtextwhite'; |
|
| 1377 | + if ($cat->color) |
|
| 1378 | + { |
|
| 1379 | + if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; |
|
| 1380 | + } |
|
| 1381 | + } |
|
| 1382 | + } |
|
| 1383 | 1383 | |
| 1384 | 1384 | if ($url == '') |
| 1385 | 1385 | { |
| 1386 | - $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color.'">'; |
|
| 1387 | - $linkend = '</a>'; |
|
| 1388 | - $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; |
|
| 1386 | + $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color.'">'; |
|
| 1387 | + $linkend = '</a>'; |
|
| 1388 | + $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; |
|
| 1389 | 1389 | } elseif ($url == 'none') { |
| 1390 | 1390 | $link = ''; |
| 1391 | 1391 | $linkend = ''; |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | |
| 1406 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1406 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1407 | 1407 | /** |
| 1408 | 1408 | * Returns an array containing the list of parent categories |
| 1409 | 1409 | * |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | */ |
| 1412 | 1412 | public function get_meres() |
| 1413 | 1413 | { |
| 1414 | - // phpcs:enable |
|
| 1414 | + // phpcs:enable |
|
| 1415 | 1415 | $parents = array(); |
| 1416 | 1416 | |
| 1417 | 1417 | $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie"; |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | } |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1440 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1441 | 1441 | /** |
| 1442 | 1442 | * Returns in a table all possible paths to get to the category |
| 1443 | 1443 | * starting with the major categories represented by Tables of categories |
@@ -1446,7 +1446,7 @@ discard block |
||
| 1446 | 1446 | */ |
| 1447 | 1447 | public function get_all_ways() |
| 1448 | 1448 | { |
| 1449 | - // phpcs:enable |
|
| 1449 | + // phpcs:enable |
|
| 1450 | 1450 | $ways = array(); |
| 1451 | 1451 | |
| 1452 | 1452 | $parents = $this->get_meres(); |
@@ -1488,60 +1488,60 @@ discard block |
||
| 1488 | 1488 | |
| 1489 | 1489 | if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code |
| 1490 | 1490 | { |
| 1491 | - // Load bank groups |
|
| 1492 | - $sql = "SELECT c.label, c.rowid"; |
|
| 1493 | - $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; |
|
| 1494 | - $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; |
|
| 1495 | - $sql .= " ORDER BY c.label"; |
|
| 1496 | - |
|
| 1497 | - $res = $this->db->query($sql); |
|
| 1498 | - if ($res) |
|
| 1499 | - { |
|
| 1500 | - while ($obj = $this->db->fetch_object($res)) |
|
| 1501 | - { |
|
| 1502 | - if ($mode == 'id') { |
|
| 1503 | - $cats[] = $obj->rowid; |
|
| 1504 | - } elseif ($mode == 'label') { |
|
| 1505 | - $cats[] = $obj->label; |
|
| 1506 | - } else { |
|
| 1507 | - $cat = new Categorie($this->db); |
|
| 1508 | - $cat->id = $obj->rowid; |
|
| 1509 | - $cat->label = $obj->label; |
|
| 1510 | - $cats[] = $cat; |
|
| 1511 | - } |
|
| 1512 | - } |
|
| 1513 | - } else { |
|
| 1514 | - dol_print_error($this->db); |
|
| 1515 | - return -1; |
|
| 1516 | - } |
|
| 1491 | + // Load bank groups |
|
| 1492 | + $sql = "SELECT c.label, c.rowid"; |
|
| 1493 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; |
|
| 1494 | + $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; |
|
| 1495 | + $sql .= " ORDER BY c.label"; |
|
| 1496 | + |
|
| 1497 | + $res = $this->db->query($sql); |
|
| 1498 | + if ($res) |
|
| 1499 | + { |
|
| 1500 | + while ($obj = $this->db->fetch_object($res)) |
|
| 1501 | + { |
|
| 1502 | + if ($mode == 'id') { |
|
| 1503 | + $cats[] = $obj->rowid; |
|
| 1504 | + } elseif ($mode == 'label') { |
|
| 1505 | + $cats[] = $obj->label; |
|
| 1506 | + } else { |
|
| 1507 | + $cat = new Categorie($this->db); |
|
| 1508 | + $cat->id = $obj->rowid; |
|
| 1509 | + $cat->label = $obj->label; |
|
| 1510 | + $cats[] = $cat; |
|
| 1511 | + } |
|
| 1512 | + } |
|
| 1513 | + } else { |
|
| 1514 | + dol_print_error($this->db); |
|
| 1515 | + return -1; |
|
| 1516 | + } |
|
| 1517 | 1517 | } else { |
| 1518 | - $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; |
|
| 1519 | - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; |
|
| 1520 | - $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; |
|
| 1521 | - $sql .= " AND c.entity IN (".getEntity('category').")"; |
|
| 1522 | - |
|
| 1523 | - $res = $this->db->query($sql); |
|
| 1524 | - if ($res) |
|
| 1525 | - { |
|
| 1526 | - while ($obj = $this->db->fetch_object($res)) |
|
| 1527 | - { |
|
| 1528 | - if ($mode == 'id') { |
|
| 1529 | - $cats[] = $obj->rowid; |
|
| 1530 | - } elseif ($mode == 'label') { |
|
| 1531 | - $cats[] = $obj->label; |
|
| 1532 | - } else { |
|
| 1533 | - $cat = new Categorie($this->db); |
|
| 1534 | - $cat->fetch($obj->fk_categorie); |
|
| 1535 | - $cats[] = $cat; |
|
| 1536 | - } |
|
| 1537 | - } |
|
| 1538 | - } else { |
|
| 1539 | - dol_print_error($this->db); |
|
| 1540 | - return -1; |
|
| 1541 | - } |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - return $cats; |
|
| 1518 | + $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; |
|
| 1519 | + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; |
|
| 1520 | + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; |
|
| 1521 | + $sql .= " AND c.entity IN (".getEntity('category').")"; |
|
| 1522 | + |
|
| 1523 | + $res = $this->db->query($sql); |
|
| 1524 | + if ($res) |
|
| 1525 | + { |
|
| 1526 | + while ($obj = $this->db->fetch_object($res)) |
|
| 1527 | + { |
|
| 1528 | + if ($mode == 'id') { |
|
| 1529 | + $cats[] = $obj->rowid; |
|
| 1530 | + } elseif ($mode == 'label') { |
|
| 1531 | + $cats[] = $obj->label; |
|
| 1532 | + } else { |
|
| 1533 | + $cat = new Categorie($this->db); |
|
| 1534 | + $cat->fetch($obj->fk_categorie); |
|
| 1535 | + $cats[] = $cat; |
|
| 1536 | + } |
|
| 1537 | + } |
|
| 1538 | + } else { |
|
| 1539 | + dol_print_error($this->db); |
|
| 1540 | + return -1; |
|
| 1541 | + } |
|
| 1542 | + } |
|
| 1543 | + |
|
| 1544 | + return $cats; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | * |
| 1552 | 1552 | * @param int $id Id |
| 1553 | 1553 | * @param string $nom Name |
| 1554 | - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. |
|
| 1554 | + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. |
|
| 1555 | 1555 | * @param boolean $exact Exact string search (true/false) |
| 1556 | 1556 | * @param boolean $case Case sensitive (true/false) |
| 1557 | 1557 | * @return Categorie[]|int Array of Categorie, -1 if error |
@@ -1565,15 +1565,15 @@ discard block |
||
| 1565 | 1565 | |
| 1566 | 1566 | $cats = array(); |
| 1567 | 1567 | |
| 1568 | - // For backward compatibility |
|
| 1569 | - if (is_numeric($type)) { |
|
| 1570 | - // We want to reverse lookup |
|
| 1571 | - $map_type = array_flip($this->MAP_ID); |
|
| 1572 | - $type = $map_type[$type]; |
|
| 1573 | - dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); |
|
| 1574 | - } |
|
| 1568 | + // For backward compatibility |
|
| 1569 | + if (is_numeric($type)) { |
|
| 1570 | + // We want to reverse lookup |
|
| 1571 | + $map_type = array_flip($this->MAP_ID); |
|
| 1572 | + $type = $map_type[$type]; |
|
| 1573 | + dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); |
|
| 1574 | + } |
|
| 1575 | 1575 | |
| 1576 | - // Generation requete recherche |
|
| 1576 | + // Generation requete recherche |
|
| 1577 | 1577 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; |
| 1578 | 1578 | $sql .= " WHERE type = ".$this->MAP_ID[$type]; |
| 1579 | 1579 | $sql .= " AND entity IN (".getEntity('category').")"; |
@@ -1636,14 +1636,14 @@ discard block |
||
| 1636 | 1636 | $picto = 'category'; |
| 1637 | 1637 | |
| 1638 | 1638 | |
| 1639 | - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); |
|
| 1639 | + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); |
|
| 1640 | 1640 | if ($withpicto && $withpicto != 2) $result .= ' '; |
| 1641 | 1641 | if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; |
| 1642 | 1642 | return $result; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | |
| 1646 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1646 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1647 | 1647 | /** |
| 1648 | 1648 | * Deplace fichier uploade sous le nom $files dans le repertoire sdir |
| 1649 | 1649 | * |
@@ -1653,7 +1653,7 @@ discard block |
||
| 1653 | 1653 | */ |
| 1654 | 1654 | public function add_photo($sdir, $file) |
| 1655 | 1655 | { |
| 1656 | - // phpcs:enable |
|
| 1656 | + // phpcs:enable |
|
| 1657 | 1657 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 1658 | 1658 | |
| 1659 | 1659 | $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | } |
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1696 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1697 | 1697 | /** |
| 1698 | 1698 | * Return tableau de toutes les photos de la categorie |
| 1699 | 1699 | * |
@@ -1703,7 +1703,7 @@ discard block |
||
| 1703 | 1703 | */ |
| 1704 | 1704 | public function liste_photos($dir, $nbmax = 0) |
| 1705 | 1705 | { |
| 1706 | - // phpcs:enable |
|
| 1706 | + // phpcs:enable |
|
| 1707 | 1707 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 1708 | 1708 | |
| 1709 | 1709 | $nbphoto = 0; |
@@ -1714,43 +1714,43 @@ discard block |
||
| 1714 | 1714 | if (file_exists($dir)) |
| 1715 | 1715 | { |
| 1716 | 1716 | $handle = opendir($dir); |
| 1717 | - if (is_resource($handle)) |
|
| 1718 | - { |
|
| 1719 | - while (($file = readdir($handle)) !== false) |
|
| 1720 | - { |
|
| 1721 | - if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) |
|
| 1722 | - { |
|
| 1723 | - $nbphoto++; |
|
| 1724 | - $photo = $file; |
|
| 1725 | - |
|
| 1726 | - // On determine nom du fichier vignette |
|
| 1727 | - $photo_vignette = ''; |
|
| 1728 | - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) |
|
| 1729 | - { |
|
| 1730 | - $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; |
|
| 1731 | - } |
|
| 1732 | - |
|
| 1733 | - // Objet |
|
| 1734 | - $obj = array(); |
|
| 1735 | - $obj['photo'] = $photo; |
|
| 1736 | - if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; |
|
| 1737 | - else $obj['photo_vignette'] = ""; |
|
| 1738 | - |
|
| 1739 | - $tabobj[$nbphoto - 1] = $obj; |
|
| 1740 | - |
|
| 1741 | - // On continue ou on arrete de boucler |
|
| 1742 | - if ($nbmax && $nbphoto >= $nbmax) break; |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - closedir($handle); |
|
| 1747 | - } |
|
| 1717 | + if (is_resource($handle)) |
|
| 1718 | + { |
|
| 1719 | + while (($file = readdir($handle)) !== false) |
|
| 1720 | + { |
|
| 1721 | + if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) |
|
| 1722 | + { |
|
| 1723 | + $nbphoto++; |
|
| 1724 | + $photo = $file; |
|
| 1725 | + |
|
| 1726 | + // On determine nom du fichier vignette |
|
| 1727 | + $photo_vignette = ''; |
|
| 1728 | + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) |
|
| 1729 | + { |
|
| 1730 | + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; |
|
| 1731 | + } |
|
| 1732 | + |
|
| 1733 | + // Objet |
|
| 1734 | + $obj = array(); |
|
| 1735 | + $obj['photo'] = $photo; |
|
| 1736 | + if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; |
|
| 1737 | + else $obj['photo_vignette'] = ""; |
|
| 1738 | + |
|
| 1739 | + $tabobj[$nbphoto - 1] = $obj; |
|
| 1740 | + |
|
| 1741 | + // On continue ou on arrete de boucler |
|
| 1742 | + if ($nbmax && $nbphoto >= $nbmax) break; |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + closedir($handle); |
|
| 1747 | + } |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | return $tabobj; |
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1753 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1754 | 1754 | /** |
| 1755 | 1755 | * Efface la photo de la categorie et sa vignette |
| 1756 | 1756 | * |
@@ -1759,10 +1759,10 @@ discard block |
||
| 1759 | 1759 | */ |
| 1760 | 1760 | public function delete_photo($file) |
| 1761 | 1761 | { |
| 1762 | - // phpcs:enable |
|
| 1763 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 1762 | + // phpcs:enable |
|
| 1763 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 1764 | 1764 | |
| 1765 | - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine |
|
| 1765 | + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine |
|
| 1766 | 1766 | $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette |
| 1767 | 1767 | $filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier |
| 1768 | 1768 | |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | } |
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1783 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1784 | 1784 | /** |
| 1785 | 1785 | * Load size of image file |
| 1786 | 1786 | * |
@@ -1789,7 +1789,7 @@ discard block |
||
| 1789 | 1789 | */ |
| 1790 | 1790 | public function get_image_size($file) |
| 1791 | 1791 | { |
| 1792 | - // phpcs:enable |
|
| 1792 | + // phpcs:enable |
|
| 1793 | 1793 | $infoImg = getimagesize($file); // Recuperation des infos de l'image |
| 1794 | 1794 | $this->imgWidth = $infoImg[0]; // Largeur de l'image |
| 1795 | 1795 | $this->imgHeight = $infoImg[1]; // Hauteur de l'image |
@@ -1804,63 +1804,63 @@ discard block |
||
| 1804 | 1804 | */ |
| 1805 | 1805 | public function setMultiLangs($user) |
| 1806 | 1806 | { |
| 1807 | - global $langs; |
|
| 1808 | - |
|
| 1809 | - $langs_available = $langs->get_available_languages(); |
|
| 1810 | - $current_lang = $langs->getDefaultLang(); |
|
| 1811 | - |
|
| 1812 | - foreach ($langs_available as $key => $value) |
|
| 1813 | - { |
|
| 1814 | - $sql = "SELECT rowid"; |
|
| 1815 | - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1816 | - $sql .= " WHERE fk_category=".$this->id; |
|
| 1817 | - $sql .= " AND lang='".$key."'"; |
|
| 1818 | - |
|
| 1819 | - $result = $this->db->query($sql); |
|
| 1820 | - |
|
| 1821 | - if ($key == $current_lang) |
|
| 1822 | - { |
|
| 1823 | - if ($this->db->num_rows($result)) // si aucune ligne dans la base |
|
| 1824 | - { |
|
| 1825 | - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1826 | - $sql2 .= " SET label='".$this->db->escape($this->label)."',"; |
|
| 1827 | - $sql2 .= " description='".$this->db->escape($this->description)."'"; |
|
| 1828 | - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1829 | - } else { |
|
| 1830 | - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; |
|
| 1831 | - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); |
|
| 1832 | - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; |
|
| 1833 | - } |
|
| 1834 | - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); |
|
| 1835 | - if (!$this->db->query($sql2)) |
|
| 1836 | - { |
|
| 1837 | - $this->error = $this->db->lasterror(); |
|
| 1838 | - return -1; |
|
| 1839 | - } |
|
| 1840 | - } elseif (isset($this->multilangs["$key"])) |
|
| 1841 | - { |
|
| 1842 | - if ($this->db->num_rows($result)) // si aucune ligne dans la base |
|
| 1843 | - { |
|
| 1844 | - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1845 | - $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1846 | - $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1847 | - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1848 | - } else { |
|
| 1849 | - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; |
|
| 1850 | - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); |
|
| 1851 | - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - // on ne sauvegarde pas des champs vides |
|
| 1855 | - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) |
|
| 1856 | - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); |
|
| 1857 | - if (!$this->db->query($sql2)) |
|
| 1858 | - { |
|
| 1859 | - $this->error = $this->db->lasterror(); |
|
| 1860 | - return -1; |
|
| 1861 | - } |
|
| 1862 | - } |
|
| 1863 | - } |
|
| 1807 | + global $langs; |
|
| 1808 | + |
|
| 1809 | + $langs_available = $langs->get_available_languages(); |
|
| 1810 | + $current_lang = $langs->getDefaultLang(); |
|
| 1811 | + |
|
| 1812 | + foreach ($langs_available as $key => $value) |
|
| 1813 | + { |
|
| 1814 | + $sql = "SELECT rowid"; |
|
| 1815 | + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1816 | + $sql .= " WHERE fk_category=".$this->id; |
|
| 1817 | + $sql .= " AND lang='".$key."'"; |
|
| 1818 | + |
|
| 1819 | + $result = $this->db->query($sql); |
|
| 1820 | + |
|
| 1821 | + if ($key == $current_lang) |
|
| 1822 | + { |
|
| 1823 | + if ($this->db->num_rows($result)) // si aucune ligne dans la base |
|
| 1824 | + { |
|
| 1825 | + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1826 | + $sql2 .= " SET label='".$this->db->escape($this->label)."',"; |
|
| 1827 | + $sql2 .= " description='".$this->db->escape($this->description)."'"; |
|
| 1828 | + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1829 | + } else { |
|
| 1830 | + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; |
|
| 1831 | + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); |
|
| 1832 | + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; |
|
| 1833 | + } |
|
| 1834 | + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); |
|
| 1835 | + if (!$this->db->query($sql2)) |
|
| 1836 | + { |
|
| 1837 | + $this->error = $this->db->lasterror(); |
|
| 1838 | + return -1; |
|
| 1839 | + } |
|
| 1840 | + } elseif (isset($this->multilangs["$key"])) |
|
| 1841 | + { |
|
| 1842 | + if ($this->db->num_rows($result)) // si aucune ligne dans la base |
|
| 1843 | + { |
|
| 1844 | + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1845 | + $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1846 | + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1847 | + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1848 | + } else { |
|
| 1849 | + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; |
|
| 1850 | + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); |
|
| 1851 | + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + // on ne sauvegarde pas des champs vides |
|
| 1855 | + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) |
|
| 1856 | + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); |
|
| 1857 | + if (!$this->db->query($sql2)) |
|
| 1858 | + { |
|
| 1859 | + $this->error = $this->db->lasterror(); |
|
| 1860 | + return -1; |
|
| 1861 | + } |
|
| 1862 | + } |
|
| 1863 | + } |
|
| 1864 | 1864 | |
| 1865 | 1865 | // Call trigger |
| 1866 | 1866 | $result = $this->call_trigger('CATEGORY_SET_MULTILANGS', $user); |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | } |
| 1871 | 1871 | // End call triggers |
| 1872 | 1872 | |
| 1873 | - return 1; |
|
| 1873 | + return 1; |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | /** |
@@ -1880,33 +1880,33 @@ discard block |
||
| 1880 | 1880 | */ |
| 1881 | 1881 | public function getMultiLangs() |
| 1882 | 1882 | { |
| 1883 | - global $langs; |
|
| 1884 | - |
|
| 1885 | - $current_lang = $langs->getDefaultLang(); |
|
| 1886 | - |
|
| 1887 | - $sql = "SELECT lang, label, description"; |
|
| 1888 | - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1889 | - $sql .= " WHERE fk_category=".$this->id; |
|
| 1890 | - |
|
| 1891 | - $result = $this->db->query($sql); |
|
| 1892 | - if ($result) |
|
| 1893 | - { |
|
| 1894 | - while ($obj = $this->db->fetch_object($result)) |
|
| 1895 | - { |
|
| 1896 | - //print 'lang='.$obj->lang.' current='.$current_lang.'<br>'; |
|
| 1897 | - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. |
|
| 1898 | - { |
|
| 1899 | - $this->label = $obj->label; |
|
| 1900 | - $this->description = $obj->description; |
|
| 1901 | - } |
|
| 1902 | - $this->multilangs["$obj->lang"]["label"] = $obj->label; |
|
| 1903 | - $this->multilangs["$obj->lang"]["description"] = $obj->description; |
|
| 1904 | - } |
|
| 1905 | - return 1; |
|
| 1906 | - } else { |
|
| 1907 | - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 1908 | - return -1; |
|
| 1909 | - } |
|
| 1883 | + global $langs; |
|
| 1884 | + |
|
| 1885 | + $current_lang = $langs->getDefaultLang(); |
|
| 1886 | + |
|
| 1887 | + $sql = "SELECT lang, label, description"; |
|
| 1888 | + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; |
|
| 1889 | + $sql .= " WHERE fk_category=".$this->id; |
|
| 1890 | + |
|
| 1891 | + $result = $this->db->query($sql); |
|
| 1892 | + if ($result) |
|
| 1893 | + { |
|
| 1894 | + while ($obj = $this->db->fetch_object($result)) |
|
| 1895 | + { |
|
| 1896 | + //print 'lang='.$obj->lang.' current='.$current_lang.'<br>'; |
|
| 1897 | + if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. |
|
| 1898 | + { |
|
| 1899 | + $this->label = $obj->label; |
|
| 1900 | + $this->description = $obj->description; |
|
| 1901 | + } |
|
| 1902 | + $this->multilangs["$obj->lang"]["label"] = $obj->label; |
|
| 1903 | + $this->multilangs["$obj->lang"]["description"] = $obj->description; |
|
| 1904 | + } |
|
| 1905 | + return 1; |
|
| 1906 | + } else { |
|
| 1907 | + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 1908 | + return -1; |
|
| 1909 | + } |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | /** |
@@ -1917,47 +1917,47 @@ discard block |
||
| 1917 | 1917 | */ |
| 1918 | 1918 | public function getLibStatut($mode) |
| 1919 | 1919 | { |
| 1920 | - return ''; |
|
| 1920 | + return ''; |
|
| 1921 | + } |
|
| 1922 | + |
|
| 1923 | + |
|
| 1924 | + /** |
|
| 1925 | + * Initialise an instance with random values. |
|
| 1926 | + * Used to build previews or test instances. |
|
| 1927 | + * id must be 0 if object instance is a specimen. |
|
| 1928 | + * |
|
| 1929 | + * @return void |
|
| 1930 | + */ |
|
| 1931 | + public function initAsSpecimen() |
|
| 1932 | + { |
|
| 1933 | + dol_syslog(get_class($this)."::initAsSpecimen"); |
|
| 1934 | + |
|
| 1935 | + // Initialise parametres |
|
| 1936 | + $this->id = 0; |
|
| 1937 | + $this->fk_parent = 0; |
|
| 1938 | + $this->label = 'SPECIMEN'; |
|
| 1939 | + $this->specimen = 1; |
|
| 1940 | + $this->description = 'This is a description'; |
|
| 1941 | + $this->socid = 1; |
|
| 1942 | + $this->type = self::TYPE_PRODUCT; |
|
| 1921 | 1943 | } |
| 1922 | 1944 | |
| 1945 | + /** |
|
| 1946 | + * Function used to replace a thirdparty id with another one. |
|
| 1947 | + * |
|
| 1948 | + * @param DoliDB $db Database handler |
|
| 1949 | + * @param int $origin_id Old thirdparty id |
|
| 1950 | + * @param int $dest_id New thirdparty id |
|
| 1951 | + * @return bool |
|
| 1952 | + */ |
|
| 1953 | + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) |
|
| 1954 | + { |
|
| 1955 | + $tables = array( |
|
| 1956 | + 'categorie_societe' |
|
| 1957 | + ); |
|
| 1923 | 1958 | |
| 1924 | - /** |
|
| 1925 | - * Initialise an instance with random values. |
|
| 1926 | - * Used to build previews or test instances. |
|
| 1927 | - * id must be 0 if object instance is a specimen. |
|
| 1928 | - * |
|
| 1929 | - * @return void |
|
| 1930 | - */ |
|
| 1931 | - public function initAsSpecimen() |
|
| 1932 | - { |
|
| 1933 | - dol_syslog(get_class($this)."::initAsSpecimen"); |
|
| 1934 | - |
|
| 1935 | - // Initialise parametres |
|
| 1936 | - $this->id = 0; |
|
| 1937 | - $this->fk_parent = 0; |
|
| 1938 | - $this->label = 'SPECIMEN'; |
|
| 1939 | - $this->specimen = 1; |
|
| 1940 | - $this->description = 'This is a description'; |
|
| 1941 | - $this->socid = 1; |
|
| 1942 | - $this->type = self::TYPE_PRODUCT; |
|
| 1943 | - } |
|
| 1944 | - |
|
| 1945 | - /** |
|
| 1946 | - * Function used to replace a thirdparty id with another one. |
|
| 1947 | - * |
|
| 1948 | - * @param DoliDB $db Database handler |
|
| 1949 | - * @param int $origin_id Old thirdparty id |
|
| 1950 | - * @param int $dest_id New thirdparty id |
|
| 1951 | - * @return bool |
|
| 1952 | - */ |
|
| 1953 | - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) |
|
| 1954 | - { |
|
| 1955 | - $tables = array( |
|
| 1956 | - 'categorie_societe' |
|
| 1957 | - ); |
|
| 1958 | - |
|
| 1959 | - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); |
|
| 1960 | - } |
|
| 1959 | + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); |
|
| 1960 | + } |
|
| 1961 | 1961 | |
| 1962 | 1962 | /** |
| 1963 | 1963 | * Return the addtional SQL JOIN query for filtering a list by a category |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. |
| 637 | 637 | * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. |
| 638 | 638 | * @param int $alwaysvisible 1=select button always visible |
| 639 | - * @param string $name Name for massaction |
|
| 640 | - * @param string $cssclass CSS class used to check for select |
|
| 639 | + * @param string $name Name for massaction |
|
| 640 | + * @param string $cssclass CSS class used to check for select |
|
| 641 | 641 | * @return string|void Select list |
| 642 | 642 | */ |
| 643 | 643 | public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name = 'massaction', $cssclass = 'checkforselect') |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $disabled = 0; |
| 649 | 649 | $ret = '<div class="centpercent center">'; |
| 650 | - $ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' ' . $name . ' ' . $name . 'select valignmiddle alignstart" name="' . $name . '"'.($disabled ? ' disabled="disabled"' : '').'>'; |
|
| 650 | + $ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' ' . $name . ' ' . $name . 'select valignmiddle alignstart" name="' . $name . '"'.($disabled ? ' disabled="disabled"' : '').'>'; |
|
| 651 | 651 | |
| 652 | 652 | // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. |
| 653 | 653 | $parameters = array(); |
@@ -666,11 +666,11 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | $ret .= '</select>'; |
| 668 | 668 | |
| 669 | - if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.' . $name . 'select'); |
|
| 669 | + if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.' . $name . 'select'); |
|
| 670 | 670 | |
| 671 | 671 | // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button |
| 672 | 672 | $ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER. |
| 673 | - $ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' ' . $name . ' ' . $name . 'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; |
|
| 673 | + $ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' ' . $name . ' ' . $name . 'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; |
|
| 674 | 674 | $ret .= '</div>'; |
| 675 | 675 | |
| 676 | 676 | if (!empty($conf->use_javascript_ajax)) |
@@ -2056,7 +2056,7 @@ discard block |
||
| 2056 | 2056 | } |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2059 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2060 | 2060 | /** |
| 2061 | 2061 | * Return list of products for a customer |
| 2062 | 2062 | * |
@@ -2080,18 +2080,18 @@ discard block |
||
| 2080 | 2080 | * 'warehouseinternal' = count products from warehouses for internal correct/transfer only |
| 2081 | 2081 | * @return array Array of keys for json |
| 2082 | 2082 | */ |
| 2083 | - public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') |
|
| 2083 | + public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') |
|
| 2084 | 2084 | { |
| 2085 | - // phpcs:enable |
|
| 2085 | + // phpcs:enable |
|
| 2086 | 2086 | global $langs, $conf, $user, $db; |
| 2087 | 2087 | |
| 2088 | 2088 | $out = ''; |
| 2089 | 2089 | $outarray = array(); |
| 2090 | 2090 | |
| 2091 | - // Units |
|
| 2092 | - if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2093 | - $langs->load('other'); |
|
| 2094 | - } |
|
| 2091 | + // Units |
|
| 2092 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2093 | + $langs->load('other'); |
|
| 2094 | + } |
|
| 2095 | 2095 | |
| 2096 | 2096 | $warehouseStatusArray = array(); |
| 2097 | 2097 | if (!empty($warehouseStatus)) |
@@ -2114,9 +2114,9 @@ discard block |
||
| 2114 | 2114 | $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; |
| 2115 | 2115 | if (count($warehouseStatusArray)) |
| 2116 | 2116 | { |
| 2117 | - $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock |
|
| 2117 | + $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock |
|
| 2118 | 2118 | } else { |
| 2119 | - $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; |
|
| 2119 | + $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; |
|
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | 2122 | $sql = "SELECT "; |
@@ -2139,11 +2139,11 @@ discard block |
||
| 2139 | 2139 | $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; |
| 2140 | 2140 | $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; |
| 2141 | 2141 | } |
| 2142 | - // Units |
|
| 2143 | - if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2144 | - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; |
|
| 2145 | - $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; |
|
| 2146 | - } |
|
| 2142 | + // Units |
|
| 2143 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2144 | + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; |
|
| 2145 | + $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; |
|
| 2146 | + } |
|
| 2147 | 2147 | |
| 2148 | 2148 | // Multilang : we add translation |
| 2149 | 2149 | if (!empty($conf->global->MAIN_MULTILANGS)) |
@@ -2175,17 +2175,17 @@ discard block |
||
| 2175 | 2175 | // include search in supplier ref |
| 2176 | 2176 | if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) |
| 2177 | 2177 | { |
| 2178 | - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; |
|
| 2178 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; |
|
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | 2181 | //Price by customer |
| 2182 | 2182 | if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { |
| 2183 | 2183 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; |
| 2184 | 2184 | } |
| 2185 | - // Units |
|
| 2186 | - if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2187 | - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; |
|
| 2188 | - } |
|
| 2185 | + // Units |
|
| 2186 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2187 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; |
|
| 2188 | + } |
|
| 2189 | 2189 | // Multilang : we add translation |
| 2190 | 2190 | if (!empty($conf->global->MAIN_MULTILANGS)) |
| 2191 | 2191 | { |
@@ -2293,7 +2293,7 @@ discard block |
||
| 2293 | 2293 | if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
| 2294 | 2294 | else $textifempty .= $langs->trans("All"); |
| 2295 | 2295 | } else { |
| 2296 | - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 2296 | + if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>'; |
| 2299 | 2299 | |
@@ -2433,43 +2433,43 @@ discard block |
||
| 2433 | 2433 | |
| 2434 | 2434 | if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
| 2435 | 2435 | |
| 2436 | - // Units |
|
| 2437 | - $outvalUnits = ''; |
|
| 2438 | - if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2439 | - if (!empty($objp->unit_short)) { |
|
| 2440 | - $outvalUnits .= ' - '.$objp->unit_short; |
|
| 2441 | - } |
|
| 2442 | - } |
|
| 2443 | - if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { |
|
| 2444 | - if (!empty($objp->weight) && $objp->weight_units !== null) { |
|
| 2445 | - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); |
|
| 2446 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2447 | - } |
|
| 2448 | - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { |
|
| 2449 | - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); |
|
| 2450 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2451 | - } |
|
| 2452 | - if (!empty($objp->surface) && $objp->surface_units !== null) { |
|
| 2453 | - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); |
|
| 2454 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2455 | - } |
|
| 2456 | - if (!empty($objp->volume) && $objp->volume_units !== null) { |
|
| 2457 | - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); |
|
| 2458 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2459 | - } |
|
| 2460 | - } |
|
| 2461 | - if ($outdurationvalue && $outdurationunit) { |
|
| 2462 | - $da = array( |
|
| 2463 | - 'h' => $langs->trans('Hour'), |
|
| 2464 | - 'd' => $langs->trans('Day'), |
|
| 2465 | - 'w' => $langs->trans('Week'), |
|
| 2466 | - 'm' => $langs->trans('Month'), |
|
| 2467 | - 'y' => $langs->trans('Year') |
|
| 2468 | - ); |
|
| 2469 | - if (isset($da[$outdurationunit])) { |
|
| 2470 | - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); |
|
| 2471 | - } |
|
| 2472 | - } |
|
| 2436 | + // Units |
|
| 2437 | + $outvalUnits = ''; |
|
| 2438 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
| 2439 | + if (!empty($objp->unit_short)) { |
|
| 2440 | + $outvalUnits .= ' - '.$objp->unit_short; |
|
| 2441 | + } |
|
| 2442 | + } |
|
| 2443 | + if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { |
|
| 2444 | + if (!empty($objp->weight) && $objp->weight_units !== null) { |
|
| 2445 | + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); |
|
| 2446 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2447 | + } |
|
| 2448 | + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { |
|
| 2449 | + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); |
|
| 2450 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2451 | + } |
|
| 2452 | + if (!empty($objp->surface) && $objp->surface_units !== null) { |
|
| 2453 | + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); |
|
| 2454 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2455 | + } |
|
| 2456 | + if (!empty($objp->volume) && $objp->volume_units !== null) { |
|
| 2457 | + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); |
|
| 2458 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2459 | + } |
|
| 2460 | + } |
|
| 2461 | + if ($outdurationvalue && $outdurationunit) { |
|
| 2462 | + $da = array( |
|
| 2463 | + 'h' => $langs->trans('Hour'), |
|
| 2464 | + 'd' => $langs->trans('Day'), |
|
| 2465 | + 'w' => $langs->trans('Week'), |
|
| 2466 | + 'm' => $langs->trans('Month'), |
|
| 2467 | + 'y' => $langs->trans('Year') |
|
| 2468 | + ); |
|
| 2469 | + if (isset($da[$outdurationunit])) { |
|
| 2470 | + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); |
|
| 2471 | + } |
|
| 2472 | + } |
|
| 2473 | 2473 | |
| 2474 | 2474 | $opt = '<option value="'.$objp->rowid.'"'; |
| 2475 | 2475 | $opt .= ($objp->rowid == $selected) ? ' selected' : ''; |
@@ -2479,10 +2479,10 @@ discard block |
||
| 2479 | 2479 | } |
| 2480 | 2480 | if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) |
| 2481 | 2481 | { |
| 2482 | - if (!empty($user->rights->stock->lire)) { |
|
| 2483 | - if ($objp->stock > 0) $opt .= ' class="product_line_stock_ok"'; |
|
| 2484 | - elseif ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"'; |
|
| 2485 | - } |
|
| 2482 | + if (!empty($user->rights->stock->lire)) { |
|
| 2483 | + if ($objp->stock > 0) $opt .= ' class="product_line_stock_ok"'; |
|
| 2484 | + elseif ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"'; |
|
| 2485 | + } |
|
| 2486 | 2486 | } |
| 2487 | 2487 | $opt .= '>'; |
| 2488 | 2488 | $opt .= $objp->ref; |
@@ -2497,9 +2497,9 @@ discard block |
||
| 2497 | 2497 | $outval .= ' - '.dol_trunc($label, $maxlengtharticle); |
| 2498 | 2498 | if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .= ' ('.getCountry($outorigin, 1).')'; |
| 2499 | 2499 | |
| 2500 | - // Units |
|
| 2501 | - $opt .= $outvalUnits; |
|
| 2502 | - $outval .= $outvalUnits; |
|
| 2500 | + // Units |
|
| 2501 | + $opt .= $outvalUnits; |
|
| 2502 | + $outval .= $outvalUnits; |
|
| 2503 | 2503 | |
| 2504 | 2504 | $found = 0; |
| 2505 | 2505 | |
@@ -2618,46 +2618,46 @@ discard block |
||
| 2618 | 2618 | |
| 2619 | 2619 | if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) |
| 2620 | 2620 | { |
| 2621 | - if (!empty($user->rights->stock->lire)) { |
|
| 2622 | - $opt .= ' - '.$langs->trans("Stock").':'.$objp->stock; |
|
| 2623 | - |
|
| 2624 | - if ($objp->stock > 0) { |
|
| 2625 | - $outval .= ' - <span class="product_line_stock_ok">'; |
|
| 2626 | - } elseif ($objp->stock <= 0) { |
|
| 2627 | - $outval .= ' - <span class="product_line_stock_too_low">'; |
|
| 2628 | - } |
|
| 2629 | - $outval .= $langs->transnoentities("Stock").':'.$objp->stock; |
|
| 2630 | - $outval .= '</span>'; |
|
| 2631 | - if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation |
|
| 2632 | - { |
|
| 2633 | - $langs->load("stocks"); |
|
| 2634 | - |
|
| 2635 | - $tmpproduct = new Product($this->db); |
|
| 2636 | - $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) |
|
| 2637 | - $tmpproduct->load_virtual_stock(); |
|
| 2638 | - $virtualstock = $tmpproduct->stock_theorique; |
|
| 2639 | - |
|
| 2640 | - $opt .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; |
|
| 2641 | - |
|
| 2642 | - $outval .= ' - '.$langs->transnoentities("VirtualStock").':'; |
|
| 2643 | - if ($virtualstock > 0) { |
|
| 2644 | - $outval .= ' - <span class="product_line_stock_ok">'; |
|
| 2645 | - } elseif ($virtualstock <= 0) { |
|
| 2646 | - $outval .= ' - <span class="product_line_stock_too_low">'; |
|
| 2647 | - } |
|
| 2648 | - $outval .= $virtualstock; |
|
| 2649 | - $outval .= '</span>'; |
|
| 2650 | - |
|
| 2651 | - unset($tmpproduct); |
|
| 2652 | - } |
|
| 2653 | - } |
|
| 2621 | + if (!empty($user->rights->stock->lire)) { |
|
| 2622 | + $opt .= ' - '.$langs->trans("Stock").':'.$objp->stock; |
|
| 2623 | + |
|
| 2624 | + if ($objp->stock > 0) { |
|
| 2625 | + $outval .= ' - <span class="product_line_stock_ok">'; |
|
| 2626 | + } elseif ($objp->stock <= 0) { |
|
| 2627 | + $outval .= ' - <span class="product_line_stock_too_low">'; |
|
| 2628 | + } |
|
| 2629 | + $outval .= $langs->transnoentities("Stock").':'.$objp->stock; |
|
| 2630 | + $outval .= '</span>'; |
|
| 2631 | + if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation |
|
| 2632 | + { |
|
| 2633 | + $langs->load("stocks"); |
|
| 2634 | + |
|
| 2635 | + $tmpproduct = new Product($this->db); |
|
| 2636 | + $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) |
|
| 2637 | + $tmpproduct->load_virtual_stock(); |
|
| 2638 | + $virtualstock = $tmpproduct->stock_theorique; |
|
| 2639 | + |
|
| 2640 | + $opt .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; |
|
| 2641 | + |
|
| 2642 | + $outval .= ' - '.$langs->transnoentities("VirtualStock").':'; |
|
| 2643 | + if ($virtualstock > 0) { |
|
| 2644 | + $outval .= ' - <span class="product_line_stock_ok">'; |
|
| 2645 | + } elseif ($virtualstock <= 0) { |
|
| 2646 | + $outval .= ' - <span class="product_line_stock_too_low">'; |
|
| 2647 | + } |
|
| 2648 | + $outval .= $virtualstock; |
|
| 2649 | + $outval .= '</span>'; |
|
| 2650 | + |
|
| 2651 | + unset($tmpproduct); |
|
| 2652 | + } |
|
| 2653 | + } |
|
| 2654 | 2654 | } |
| 2655 | 2655 | |
| 2656 | 2656 | $opt .= "</option>\n"; |
| 2657 | 2657 | $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); |
| 2658 | 2658 | } |
| 2659 | 2659 | |
| 2660 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2660 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2661 | 2661 | /** |
| 2662 | 2662 | * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) |
| 2663 | 2663 | * |
@@ -2672,9 +2672,9 @@ discard block |
||
| 2672 | 2672 | * @param string $morecss More CSS |
| 2673 | 2673 | * @return void |
| 2674 | 2674 | */ |
| 2675 | - public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') |
|
| 2675 | + public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') |
|
| 2676 | 2676 | { |
| 2677 | - // phpcs:enable |
|
| 2677 | + // phpcs:enable |
|
| 2678 | 2678 | global $langs, $conf; |
| 2679 | 2679 | global $price_level, $status, $finished; |
| 2680 | 2680 | |
@@ -2699,7 +2699,7 @@ discard block |
||
| 2699 | 2699 | } |
| 2700 | 2700 | } |
| 2701 | 2701 | |
| 2702 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2702 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2703 | 2703 | /** |
| 2704 | 2704 | * Return list of suppliers products |
| 2705 | 2705 | * |
@@ -2716,9 +2716,9 @@ discard block |
||
| 2716 | 2716 | * @param string $morecss Add more CSS |
| 2717 | 2717 | * @return array Array of keys for json |
| 2718 | 2718 | */ |
| 2719 | - public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') |
|
| 2719 | + public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') |
|
| 2720 | 2720 | { |
| 2721 | - // phpcs:enable |
|
| 2721 | + // phpcs:enable |
|
| 2722 | 2722 | global $langs, $conf, $db; |
| 2723 | 2723 | |
| 2724 | 2724 | $out = ''; |
@@ -2727,28 +2727,28 @@ discard block |
||
| 2727 | 2727 | $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); |
| 2728 | 2728 | |
| 2729 | 2729 | $langs->load('stocks'); |
| 2730 | - // Units |
|
| 2731 | - if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2732 | - $langs->load('other'); |
|
| 2733 | - } |
|
| 2730 | + // Units |
|
| 2731 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2732 | + $langs->load('other'); |
|
| 2733 | + } |
|
| 2734 | 2734 | |
| 2735 | 2735 | $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,"; |
| 2736 | 2736 | $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; |
| 2737 | 2737 | $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; |
| 2738 | 2738 | $sql .= " pfp.supplier_reputation"; |
| 2739 | - // Units |
|
| 2740 | - if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2741 | - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; |
|
| 2742 | - } |
|
| 2743 | - if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; |
|
| 2739 | + // Units |
|
| 2740 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2741 | + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; |
|
| 2742 | + } |
|
| 2743 | + if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; |
|
| 2744 | 2744 | $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; |
| 2745 | 2745 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; |
| 2746 | 2746 | if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; |
| 2747 | 2747 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; |
| 2748 | - // Units |
|
| 2749 | - if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2750 | - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; |
|
| 2751 | - } |
|
| 2748 | + // Units |
|
| 2749 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2750 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; |
|
| 2751 | + } |
|
| 2752 | 2752 | $sql .= " WHERE p.entity IN (".getEntity('product').")"; |
| 2753 | 2753 | $sql .= " AND p.tobuy = 1"; |
| 2754 | 2754 | if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); |
@@ -2770,9 +2770,9 @@ discard block |
||
| 2770 | 2770 | } |
| 2771 | 2771 | if (count($scrit) > 1) $sql .= ")"; |
| 2772 | 2772 | if (!empty($conf->barcode->enabled)) { |
| 2773 | - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2774 | - $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2775 | - } |
|
| 2773 | + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2774 | + $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; |
|
| 2775 | + } |
|
| 2776 | 2776 | $sql .= ')'; |
| 2777 | 2777 | } |
| 2778 | 2778 | $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; |
@@ -2811,41 +2811,41 @@ discard block |
||
| 2811 | 2811 | $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; |
| 2812 | 2812 | $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; |
| 2813 | 2813 | |
| 2814 | - // Units |
|
| 2815 | - $outvalUnits = ''; |
|
| 2816 | - if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2817 | - if (!empty($objp->unit_short)) { |
|
| 2818 | - $outvalUnits .= ' - '.$objp->unit_short; |
|
| 2819 | - } |
|
| 2820 | - if (!empty($objp->weight) && $objp->weight_units !== null) { |
|
| 2821 | - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); |
|
| 2822 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2823 | - } |
|
| 2824 | - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { |
|
| 2825 | - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); |
|
| 2826 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2827 | - } |
|
| 2828 | - if (!empty($objp->surface) && $objp->surface_units !== null) { |
|
| 2829 | - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); |
|
| 2830 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2831 | - } |
|
| 2832 | - if (!empty($objp->volume) && $objp->volume_units !== null) { |
|
| 2833 | - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); |
|
| 2834 | - $outvalUnits .= ' - '.$unitToShow; |
|
| 2835 | - } |
|
| 2836 | - if ($outdurationvalue && $outdurationunit) { |
|
| 2837 | - $da = array( |
|
| 2838 | - 'h' => $langs->trans('Hour'), |
|
| 2839 | - 'd' => $langs->trans('Day'), |
|
| 2840 | - 'w' => $langs->trans('Week'), |
|
| 2841 | - 'm' => $langs->trans('Month'), |
|
| 2842 | - 'y' => $langs->trans('Year') |
|
| 2843 | - ); |
|
| 2844 | - if (isset($da[$outdurationunit])) { |
|
| 2845 | - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); |
|
| 2846 | - } |
|
| 2847 | - } |
|
| 2848 | - } |
|
| 2814 | + // Units |
|
| 2815 | + $outvalUnits = ''; |
|
| 2816 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 2817 | + if (!empty($objp->unit_short)) { |
|
| 2818 | + $outvalUnits .= ' - '.$objp->unit_short; |
|
| 2819 | + } |
|
| 2820 | + if (!empty($objp->weight) && $objp->weight_units !== null) { |
|
| 2821 | + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); |
|
| 2822 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2823 | + } |
|
| 2824 | + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { |
|
| 2825 | + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); |
|
| 2826 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2827 | + } |
|
| 2828 | + if (!empty($objp->surface) && $objp->surface_units !== null) { |
|
| 2829 | + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); |
|
| 2830 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2831 | + } |
|
| 2832 | + if (!empty($objp->volume) && $objp->volume_units !== null) { |
|
| 2833 | + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); |
|
| 2834 | + $outvalUnits .= ' - '.$unitToShow; |
|
| 2835 | + } |
|
| 2836 | + if ($outdurationvalue && $outdurationunit) { |
|
| 2837 | + $da = array( |
|
| 2838 | + 'h' => $langs->trans('Hour'), |
|
| 2839 | + 'd' => $langs->trans('Day'), |
|
| 2840 | + 'w' => $langs->trans('Week'), |
|
| 2841 | + 'm' => $langs->trans('Month'), |
|
| 2842 | + 'y' => $langs->trans('Year') |
|
| 2843 | + ); |
|
| 2844 | + if (isset($da[$outdurationunit])) { |
|
| 2845 | + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); |
|
| 2846 | + } |
|
| 2847 | + } |
|
| 2848 | + } |
|
| 2849 | 2849 | |
| 2850 | 2850 | $objRef = $objp->ref; |
| 2851 | 2851 | if ($filterkey && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1); |
@@ -2872,7 +2872,7 @@ discard block |
||
| 2872 | 2872 | } |
| 2873 | 2873 | $outvallabel .= ' - '.dol_trunc($label, $maxlengtharticle); |
| 2874 | 2874 | |
| 2875 | - // Units |
|
| 2875 | + // Units |
|
| 2876 | 2876 | $optlabel .= $outvalUnits; |
| 2877 | 2877 | $outvallabel .= $outvalUnits; |
| 2878 | 2878 | |
@@ -2996,7 +2996,7 @@ discard block |
||
| 2996 | 2996 | } |
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 2999 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3000 | 3000 | /** |
| 3001 | 3001 | * Return list of suppliers prices for a product |
| 3002 | 3002 | * |
@@ -3005,9 +3005,9 @@ discard block |
||
| 3005 | 3005 | * @param int $selected_supplier Pre-selected supplier if more than 1 result |
| 3006 | 3006 | * @return string |
| 3007 | 3007 | */ |
| 3008 | - public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') |
|
| 3008 | + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') |
|
| 3009 | 3009 | { |
| 3010 | - // phpcs:enable |
|
| 3010 | + // phpcs:enable |
|
| 3011 | 3011 | global $langs, $conf; |
| 3012 | 3012 | |
| 3013 | 3013 | $langs->load('stocks'); |
@@ -3103,7 +3103,7 @@ discard block |
||
| 3103 | 3103 | } |
| 3104 | 3104 | } |
| 3105 | 3105 | |
| 3106 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3106 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3107 | 3107 | /** |
| 3108 | 3108 | * Return list of delivery address |
| 3109 | 3109 | * |
@@ -3113,9 +3113,9 @@ discard block |
||
| 3113 | 3113 | * @param int $showempty Add an empty field |
| 3114 | 3114 | * @return integer|null |
| 3115 | 3115 | */ |
| 3116 | - public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) |
|
| 3116 | + public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) |
|
| 3117 | 3117 | { |
| 3118 | - // phpcs:enable |
|
| 3118 | + // phpcs:enable |
|
| 3119 | 3119 | // looking for users |
| 3120 | 3120 | $sql = "SELECT a.rowid, a.label"; |
| 3121 | 3121 | $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; |
@@ -3153,15 +3153,15 @@ discard block |
||
| 3153 | 3153 | } |
| 3154 | 3154 | |
| 3155 | 3155 | |
| 3156 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3156 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3157 | 3157 | /** |
| 3158 | 3158 | * Load into cache list of payment terms |
| 3159 | 3159 | * |
| 3160 | 3160 | * @return int Nb of lines loaded, <0 if KO |
| 3161 | 3161 | */ |
| 3162 | - public function load_cache_conditions_paiements() |
|
| 3162 | + public function load_cache_conditions_paiements() |
|
| 3163 | 3163 | { |
| 3164 | - // phpcs:enable |
|
| 3164 | + // phpcs:enable |
|
| 3165 | 3165 | global $langs; |
| 3166 | 3166 | |
| 3167 | 3167 | $num = count($this->cache_conditions_paiements); |
@@ -3200,15 +3200,15 @@ discard block |
||
| 3200 | 3200 | } |
| 3201 | 3201 | } |
| 3202 | 3202 | |
| 3203 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3203 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3204 | 3204 | /** |
| 3205 | 3205 | * Charge dans cache la liste des délais de livraison possibles |
| 3206 | 3206 | * |
| 3207 | 3207 | * @return int Nb of lines loaded, <0 if KO |
| 3208 | 3208 | */ |
| 3209 | - public function load_cache_availability() |
|
| 3209 | + public function load_cache_availability() |
|
| 3210 | 3210 | { |
| 3211 | - // phpcs:enable |
|
| 3211 | + // phpcs:enable |
|
| 3212 | 3212 | global $langs; |
| 3213 | 3213 | |
| 3214 | 3214 | $num = count($this->cache_availability); |
@@ -3256,7 +3256,7 @@ discard block |
||
| 3256 | 3256 | * @param int $addempty Add empty entry |
| 3257 | 3257 | * @return void |
| 3258 | 3258 | */ |
| 3259 | - public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) |
|
| 3259 | + public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) |
|
| 3260 | 3260 | { |
| 3261 | 3261 | global $langs, $user; |
| 3262 | 3262 | |
@@ -3286,7 +3286,7 @@ discard block |
||
| 3286 | 3286 | * |
| 3287 | 3287 | * @return int Nb of lines loaded, <0 if KO |
| 3288 | 3288 | */ |
| 3289 | - public function loadCacheInputReason() |
|
| 3289 | + public function loadCacheInputReason() |
|
| 3290 | 3290 | { |
| 3291 | 3291 | global $langs; |
| 3292 | 3292 | |
@@ -3338,7 +3338,7 @@ discard block |
||
| 3338 | 3338 | * @param int $addempty Add an empty entry |
| 3339 | 3339 | * @return void |
| 3340 | 3340 | */ |
| 3341 | - public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) |
|
| 3341 | + public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) |
|
| 3342 | 3342 | { |
| 3343 | 3343 | global $langs, $user; |
| 3344 | 3344 | |
@@ -3364,15 +3364,15 @@ discard block |
||
| 3364 | 3364 | if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
| 3365 | 3365 | } |
| 3366 | 3366 | |
| 3367 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3367 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3368 | 3368 | /** |
| 3369 | 3369 | * Charge dans cache la liste des types de paiements possibles |
| 3370 | 3370 | * |
| 3371 | 3371 | * @return int Nb of lines loaded, <0 if KO |
| 3372 | 3372 | */ |
| 3373 | - public function load_cache_types_paiements() |
|
| 3373 | + public function load_cache_types_paiements() |
|
| 3374 | 3374 | { |
| 3375 | - // phpcs:enable |
|
| 3375 | + // phpcs:enable |
|
| 3376 | 3376 | global $langs; |
| 3377 | 3377 | |
| 3378 | 3378 | $num = count($this->cache_types_paiements); |
@@ -3416,7 +3416,7 @@ discard block |
||
| 3416 | 3416 | } |
| 3417 | 3417 | |
| 3418 | 3418 | |
| 3419 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3419 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3420 | 3420 | /** |
| 3421 | 3421 | * Return list of payment modes. |
| 3422 | 3422 | * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. |
@@ -3430,9 +3430,9 @@ discard block |
||
| 3430 | 3430 | * @param string $morecss Add more CSS on select tag |
| 3431 | 3431 | * @return void |
| 3432 | 3432 | */ |
| 3433 | - public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') |
|
| 3433 | + public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') |
|
| 3434 | 3434 | { |
| 3435 | - // phpcs:enable |
|
| 3435 | + // phpcs:enable |
|
| 3436 | 3436 | global $langs, $user, $conf; |
| 3437 | 3437 | |
| 3438 | 3438 | dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); |
@@ -3460,7 +3460,7 @@ discard block |
||
| 3460 | 3460 | } |
| 3461 | 3461 | |
| 3462 | 3462 | |
| 3463 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3463 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3464 | 3464 | /** |
| 3465 | 3465 | * Return list of payment methods |
| 3466 | 3466 | * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. |
@@ -3476,9 +3476,9 @@ discard block |
||
| 3476 | 3476 | * @param string $morecss Add more CSS on select tag |
| 3477 | 3477 | * @return void |
| 3478 | 3478 | */ |
| 3479 | - public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') |
|
| 3479 | + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') |
|
| 3480 | 3480 | { |
| 3481 | - // phpcs:enable |
|
| 3481 | + // phpcs:enable |
|
| 3482 | 3482 | global $langs, $user, $conf; |
| 3483 | 3483 | |
| 3484 | 3484 | dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); |
@@ -3536,7 +3536,7 @@ discard block |
||
| 3536 | 3536 | * @param string $htmlname Nom de la zone select |
| 3537 | 3537 | * @return string Code of HTML select to chose tax or not |
| 3538 | 3538 | */ |
| 3539 | - public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') |
|
| 3539 | + public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') |
|
| 3540 | 3540 | { |
| 3541 | 3541 | global $langs; |
| 3542 | 3542 | |
@@ -3572,7 +3572,7 @@ discard block |
||
| 3572 | 3572 | * @param string $moreattrib To add more attribute on select |
| 3573 | 3573 | * @return void |
| 3574 | 3574 | */ |
| 3575 | - public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') |
|
| 3575 | + public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') |
|
| 3576 | 3576 | { |
| 3577 | 3577 | global $langs, $conf, $user; |
| 3578 | 3578 | |
@@ -3625,7 +3625,7 @@ discard block |
||
| 3625 | 3625 | * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. |
| 3626 | 3626 | * @return void |
| 3627 | 3627 | */ |
| 3628 | - public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) |
|
| 3628 | + public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) |
|
| 3629 | 3629 | { |
| 3630 | 3630 | global $langs, $db; |
| 3631 | 3631 | |
@@ -3656,7 +3656,7 @@ discard block |
||
| 3656 | 3656 | * |
| 3657 | 3657 | * @return string HTML select |
| 3658 | 3658 | */ |
| 3659 | - public function selectSituationInvoices($selected = '', $socid = 0) |
|
| 3659 | + public function selectSituationInvoices($selected = '', $socid = 0) |
|
| 3660 | 3660 | { |
| 3661 | 3661 | global $langs; |
| 3662 | 3662 | |
@@ -3677,17 +3677,17 @@ discard block |
||
| 3677 | 3677 | $ref = 0; |
| 3678 | 3678 | while ($obj = $this->db->fetch_object($resql)) { |
| 3679 | 3679 | //Same cycle ? |
| 3680 | - if ($obj->situation_cycle_ref != $ref) { |
|
| 3680 | + if ($obj->situation_cycle_ref != $ref) { |
|
| 3681 | 3681 | // Just seen this cycle |
| 3682 | - $ref = $obj->situation_cycle_ref; |
|
| 3682 | + $ref = $obj->situation_cycle_ref; |
|
| 3683 | 3683 | //not final ? |
| 3684 | - if ($obj->situation_final != 1) { |
|
| 3684 | + if ($obj->situation_final != 1) { |
|
| 3685 | 3685 | //Not prov? |
| 3686 | - if (substr($obj->ref, 1, 4) != 'PROV') { |
|
| 3687 | - if ($selected == $obj->rowid) { |
|
| 3688 | - $opt .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>'; |
|
| 3686 | + if (substr($obj->ref, 1, 4) != 'PROV') { |
|
| 3687 | + if ($selected == $obj->rowid) { |
|
| 3688 | + $opt .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>'; |
|
| 3689 | 3689 | } else { |
| 3690 | - $opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>'; |
|
| 3690 | + $opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>'; |
|
| 3691 | 3691 | } |
| 3692 | 3692 | } |
| 3693 | 3693 | } |
@@ -3711,7 +3711,7 @@ discard block |
||
| 3711 | 3711 | * @param int $showempty Add a nempty line |
| 3712 | 3712 | * @return string HTML select |
| 3713 | 3713 | */ |
| 3714 | - public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) |
|
| 3714 | + public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) |
|
| 3715 | 3715 | { |
| 3716 | 3716 | global $langs; |
| 3717 | 3717 | |
@@ -3729,17 +3729,17 @@ discard block |
||
| 3729 | 3729 | |
| 3730 | 3730 | while ($res = $this->db->fetch_object($resql)) |
| 3731 | 3731 | { |
| 3732 | - $unitLabel = $res->label; |
|
| 3733 | - if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before |
|
| 3734 | - { |
|
| 3735 | - $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; |
|
| 3736 | - } |
|
| 3732 | + $unitLabel = $res->label; |
|
| 3733 | + if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before |
|
| 3734 | + { |
|
| 3735 | + $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; |
|
| 3736 | + } |
|
| 3737 | 3737 | |
| 3738 | 3738 | if ($selected == $res->rowid) |
| 3739 | 3739 | { |
| 3740 | - $return .= '<option value="'.$res->rowid.'" selected>'.$unitLabel.'</option>'; |
|
| 3740 | + $return .= '<option value="'.$res->rowid.'" selected>'.$unitLabel.'</option>'; |
|
| 3741 | 3741 | } else { |
| 3742 | - $return .= '<option value="'.$res->rowid.'">'.$unitLabel.'</option>'; |
|
| 3742 | + $return .= '<option value="'.$res->rowid.'">'.$unitLabel.'</option>'; |
|
| 3743 | 3743 | } |
| 3744 | 3744 | } |
| 3745 | 3745 | $return .= '</select>'; |
@@ -3747,7 +3747,7 @@ discard block |
||
| 3747 | 3747 | return $return; |
| 3748 | 3748 | } |
| 3749 | 3749 | |
| 3750 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3750 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3751 | 3751 | /** |
| 3752 | 3752 | * Return a HTML select list of bank accounts |
| 3753 | 3753 | * |
@@ -3761,9 +3761,9 @@ discard block |
||
| 3761 | 3761 | * @param string $morecss More CSS |
| 3762 | 3762 | * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) |
| 3763 | 3763 | */ |
| 3764 | - public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') |
|
| 3764 | + public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') |
|
| 3765 | 3765 | { |
| 3766 | - // phpcs:enable |
|
| 3766 | + // phpcs:enable |
|
| 3767 | 3767 | global $langs, $conf; |
| 3768 | 3768 | |
| 3769 | 3769 | $langs->load("admin"); |
@@ -3830,7 +3830,7 @@ discard block |
||
| 3830 | 3830 | */ |
| 3831 | 3831 | public function selectEstablishments($selected = '', $htmlname = 'entity', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '') |
| 3832 | 3832 | { |
| 3833 | - // phpcs:enable |
|
| 3833 | + // phpcs:enable |
|
| 3834 | 3834 | global $langs, $conf; |
| 3835 | 3835 | |
| 3836 | 3836 | $langs->load("admin"); |
@@ -3890,7 +3890,7 @@ discard block |
||
| 3890 | 3890 | * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. |
| 3891 | 3891 | * @return void |
| 3892 | 3892 | */ |
| 3893 | - public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) |
|
| 3893 | + public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) |
|
| 3894 | 3894 | { |
| 3895 | 3895 | global $langs; |
| 3896 | 3896 | if ($htmlname != "none") { |
@@ -3914,7 +3914,7 @@ discard block |
||
| 3914 | 3914 | } |
| 3915 | 3915 | } |
| 3916 | 3916 | |
| 3917 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3917 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 3918 | 3918 | /** |
| 3919 | 3919 | * Return list of categories having choosed type |
| 3920 | 3920 | * |
@@ -3922,20 +3922,20 @@ discard block |
||
| 3922 | 3922 | * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element). Not used if $outputmode = 1. |
| 3923 | 3923 | * @param string $htmlname HTML field name |
| 3924 | 3924 | * @param int $maxlength Maximum length for labels |
| 3925 | - * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. |
|
| 3926 | - * $markafterid can be an : |
|
| 3927 | - * - int (id of category) |
|
| 3928 | - * - string (categories ids seprated by comma) |
|
| 3929 | - * - array (list of categories ids) |
|
| 3925 | + * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. |
|
| 3926 | + * $markafterid can be an : |
|
| 3927 | + * - int (id of category) |
|
| 3928 | + * - string (categories ids seprated by comma) |
|
| 3929 | + * - array (list of categories ids) |
|
| 3930 | 3930 | * @param int $outputmode 0=HTML select string, 1=Array |
| 3931 | - * @param int $include [=0] Removed or 1=Keep only |
|
| 3932 | - * @param string $morecss More CSS |
|
| 3931 | + * @param int $include [=0] Removed or 1=Keep only |
|
| 3932 | + * @param string $morecss More CSS |
|
| 3933 | 3933 | * @return string |
| 3934 | 3934 | * @see select_categories() |
| 3935 | 3935 | */ |
| 3936 | - public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') |
|
| 3936 | + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') |
|
| 3937 | 3937 | { |
| 3938 | - // phpcs:enable |
|
| 3938 | + // phpcs:enable |
|
| 3939 | 3939 | global $conf, $langs; |
| 3940 | 3940 | $langs->load("categories"); |
| 3941 | 3941 | |
@@ -3970,7 +3970,7 @@ discard block |
||
| 3970 | 3970 | } else dol_print_error($this->db); |
| 3971 | 3971 | } else { |
| 3972 | 3972 | $cat = new Categorie($this->db); |
| 3973 | - $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); |
|
| 3973 | + $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); |
|
| 3974 | 3974 | } |
| 3975 | 3975 | |
| 3976 | 3976 | $output = '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
@@ -4001,7 +4001,7 @@ discard block |
||
| 4001 | 4001 | return $output; |
| 4002 | 4002 | } |
| 4003 | 4003 | |
| 4004 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4004 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4005 | 4005 | /** |
| 4006 | 4006 | * Show a confirmation HTML form or AJAX popup |
| 4007 | 4007 | * |
@@ -4018,10 +4018,10 @@ discard block |
||
| 4018 | 4018 | * @deprecated |
| 4019 | 4019 | * @see formconfirm() |
| 4020 | 4020 | */ |
| 4021 | - public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) |
|
| 4021 | + public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) |
|
| 4022 | 4022 | { |
| 4023 | - // phpcs:enable |
|
| 4024 | - dol_syslog(__METHOD__.': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); |
|
| 4023 | + // phpcs:enable |
|
| 4024 | + dol_syslog(__METHOD__.': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); |
|
| 4025 | 4025 | print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); |
| 4026 | 4026 | } |
| 4027 | 4027 | |
@@ -4049,7 +4049,7 @@ discard block |
||
| 4049 | 4049 | * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section. |
| 4050 | 4050 | * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form |
| 4051 | 4051 | */ |
| 4052 | - public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) |
|
| 4052 | + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) |
|
| 4053 | 4053 | { |
| 4054 | 4054 | global $langs, $conf; |
| 4055 | 4055 | |
@@ -4321,7 +4321,7 @@ discard block |
||
| 4321 | 4321 | } |
| 4322 | 4322 | |
| 4323 | 4323 | |
| 4324 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4324 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4325 | 4325 | /** |
| 4326 | 4326 | * Show a form to select a project |
| 4327 | 4327 | * |
@@ -4335,9 +4335,9 @@ discard block |
||
| 4335 | 4335 | * @param int $nooutput No print is done. String is returned. |
| 4336 | 4336 | * @return string Return html content |
| 4337 | 4337 | */ |
| 4338 | - public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) |
|
| 4338 | + public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) |
|
| 4339 | 4339 | { |
| 4340 | - // phpcs:enable |
|
| 4340 | + // phpcs:enable |
|
| 4341 | 4341 | global $langs; |
| 4342 | 4342 | |
| 4343 | 4343 | require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; |
@@ -4377,7 +4377,7 @@ discard block |
||
| 4377 | 4377 | return $out; |
| 4378 | 4378 | } |
| 4379 | 4379 | |
| 4380 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4380 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4381 | 4381 | /** |
| 4382 | 4382 | * Show a form to select payment conditions |
| 4383 | 4383 | * |
@@ -4387,9 +4387,9 @@ discard block |
||
| 4387 | 4387 | * @param int $addempty Add empty entry |
| 4388 | 4388 | * @return void |
| 4389 | 4389 | */ |
| 4390 | - public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) |
|
| 4390 | + public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) |
|
| 4391 | 4391 | { |
| 4392 | - // phpcs:enable |
|
| 4392 | + // phpcs:enable |
|
| 4393 | 4393 | global $langs; |
| 4394 | 4394 | if ($htmlname != "none") |
| 4395 | 4395 | { |
@@ -4410,7 +4410,7 @@ discard block |
||
| 4410 | 4410 | } |
| 4411 | 4411 | } |
| 4412 | 4412 | |
| 4413 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4413 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4414 | 4414 | /** |
| 4415 | 4415 | * Show a form to select a delivery delay |
| 4416 | 4416 | * |
@@ -4420,9 +4420,9 @@ discard block |
||
| 4420 | 4420 | * @param int $addempty Ajoute entree vide |
| 4421 | 4421 | * @return void |
| 4422 | 4422 | */ |
| 4423 | - public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) |
|
| 4423 | + public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) |
|
| 4424 | 4424 | { |
| 4425 | - // phpcs:enable |
|
| 4425 | + // phpcs:enable |
|
| 4426 | 4426 | global $langs; |
| 4427 | 4427 | if ($htmlname != "none") |
| 4428 | 4428 | { |
@@ -4452,9 +4452,9 @@ discard block |
||
| 4452 | 4452 | * @param string $htmlname Name of select html field |
| 4453 | 4453 | * @param int $addempty Add empty entry |
| 4454 | 4454 | * @return void |
| 4455 | - */ |
|
| 4456 | - public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) |
|
| 4457 | - { |
|
| 4455 | + */ |
|
| 4456 | + public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) |
|
| 4457 | + { |
|
| 4458 | 4458 | global $langs; |
| 4459 | 4459 | if ($htmlname != "none") |
| 4460 | 4460 | { |
@@ -4482,7 +4482,7 @@ discard block |
||
| 4482 | 4482 | } |
| 4483 | 4483 | } |
| 4484 | 4484 | |
| 4485 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4485 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4486 | 4486 | /** |
| 4487 | 4487 | * Show a form + html select a date |
| 4488 | 4488 | * |
@@ -4495,9 +4495,9 @@ discard block |
||
| 4495 | 4495 | * @return string |
| 4496 | 4496 | * @see selectDate() |
| 4497 | 4497 | */ |
| 4498 | - public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) |
|
| 4498 | + public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) |
|
| 4499 | 4499 | { |
| 4500 | - // phpcs:enable |
|
| 4500 | + // phpcs:enable |
|
| 4501 | 4501 | global $langs; |
| 4502 | 4502 | |
| 4503 | 4503 | $ret = ''; |
@@ -4523,7 +4523,7 @@ discard block |
||
| 4523 | 4523 | } |
| 4524 | 4524 | |
| 4525 | 4525 | |
| 4526 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4526 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4527 | 4527 | /** |
| 4528 | 4528 | * Show a select form to choose a user |
| 4529 | 4529 | * |
@@ -4534,9 +4534,9 @@ discard block |
||
| 4534 | 4534 | * @param array $include List of users id to include |
| 4535 | 4535 | * @return void |
| 4536 | 4536 | */ |
| 4537 | - public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') |
|
| 4537 | + public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') |
|
| 4538 | 4538 | { |
| 4539 | - // phpcs:enable |
|
| 4539 | + // phpcs:enable |
|
| 4540 | 4540 | global $langs; |
| 4541 | 4541 | |
| 4542 | 4542 | if ($htmlname != "none") |
@@ -4561,7 +4561,7 @@ discard block |
||
| 4561 | 4561 | } |
| 4562 | 4562 | |
| 4563 | 4563 | |
| 4564 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4564 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4565 | 4565 | /** |
| 4566 | 4566 | * Show form with payment mode |
| 4567 | 4567 | * |
@@ -4573,9 +4573,9 @@ discard block |
||
| 4573 | 4573 | * @param int $addempty 1=Add empty entry |
| 4574 | 4574 | * @return void |
| 4575 | 4575 | */ |
| 4576 | - public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) |
|
| 4576 | + public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) |
|
| 4577 | 4577 | { |
| 4578 | - // phpcs:enable |
|
| 4578 | + // phpcs:enable |
|
| 4579 | 4579 | global $langs; |
| 4580 | 4580 | if ($htmlname != "none") |
| 4581 | 4581 | { |
@@ -4596,7 +4596,7 @@ discard block |
||
| 4596 | 4596 | } |
| 4597 | 4597 | } |
| 4598 | 4598 | |
| 4599 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4599 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4600 | 4600 | /** |
| 4601 | 4601 | * Show form with multicurrency code |
| 4602 | 4602 | * |
@@ -4605,9 +4605,9 @@ discard block |
||
| 4605 | 4605 | * @param string $htmlname Name of select html field |
| 4606 | 4606 | * @return void |
| 4607 | 4607 | */ |
| 4608 | - public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') |
|
| 4608 | + public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') |
|
| 4609 | 4609 | { |
| 4610 | - // phpcs:enable |
|
| 4610 | + // phpcs:enable |
|
| 4611 | 4611 | global $langs; |
| 4612 | 4612 | if ($htmlname != "none") |
| 4613 | 4613 | { |
@@ -4623,7 +4623,7 @@ discard block |
||
| 4623 | 4623 | } |
| 4624 | 4624 | } |
| 4625 | 4625 | |
| 4626 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4626 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4627 | 4627 | /** |
| 4628 | 4628 | * Show form with multicurrency rate |
| 4629 | 4629 | * |
@@ -4633,9 +4633,9 @@ discard block |
||
| 4633 | 4633 | * @param string $currency Currency code to explain the rate |
| 4634 | 4634 | * @return void |
| 4635 | 4635 | */ |
| 4636 | - public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') |
|
| 4636 | + public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') |
|
| 4637 | 4637 | { |
| 4638 | - // phpcs:enable |
|
| 4638 | + // phpcs:enable |
|
| 4639 | 4639 | global $langs, $mysoc, $conf; |
| 4640 | 4640 | |
| 4641 | 4641 | if ($htmlname != "none") |
@@ -4662,7 +4662,7 @@ discard block |
||
| 4662 | 4662 | } |
| 4663 | 4663 | |
| 4664 | 4664 | |
| 4665 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4665 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4666 | 4666 | /** |
| 4667 | 4667 | * Show a select box with available absolute discounts |
| 4668 | 4668 | * |
@@ -4678,9 +4678,9 @@ discard block |
||
| 4678 | 4678 | * @param int $discount_type 0 => customer discount, 1 => supplier discount |
| 4679 | 4679 | * @return void |
| 4680 | 4680 | */ |
| 4681 | - public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) |
|
| 4681 | + public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) |
|
| 4682 | 4682 | { |
| 4683 | - // phpcs:enable |
|
| 4683 | + // phpcs:enable |
|
| 4684 | 4684 | global $conf, $langs; |
| 4685 | 4685 | if ($htmlname != "none") |
| 4686 | 4686 | { |
@@ -4751,19 +4751,19 @@ discard block |
||
| 4751 | 4751 | } |
| 4752 | 4752 | |
| 4753 | 4753 | |
| 4754 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4755 | - /** |
|
| 4756 | - * Show forms to select a contact |
|
| 4757 | - * |
|
| 4758 | - * @param string $page Page |
|
| 4759 | - * @param Societe $societe Filter on third party |
|
| 4760 | - * @param int $selected Id contact pre-selectionne |
|
| 4761 | - * @param string $htmlname Name of HTML select. If 'none', we just show contact link. |
|
| 4762 | - * @return void |
|
| 4763 | - */ |
|
| 4764 | - public function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') |
|
| 4765 | - { |
|
| 4766 | - // phpcs:enable |
|
| 4754 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4755 | + /** |
|
| 4756 | + * Show forms to select a contact |
|
| 4757 | + * |
|
| 4758 | + * @param string $page Page |
|
| 4759 | + * @param Societe $societe Filter on third party |
|
| 4760 | + * @param int $selected Id contact pre-selectionne |
|
| 4761 | + * @param string $htmlname Name of HTML select. If 'none', we just show contact link. |
|
| 4762 | + * @return void |
|
| 4763 | + */ |
|
| 4764 | + public function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') |
|
| 4765 | + { |
|
| 4766 | + // phpcs:enable |
|
| 4767 | 4767 | global $langs, $conf; |
| 4768 | 4768 | |
| 4769 | 4769 | if ($htmlname != "none") |
@@ -4795,7 +4795,7 @@ discard block |
||
| 4795 | 4795 | } |
| 4796 | 4796 | } |
| 4797 | 4797 | |
| 4798 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4798 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4799 | 4799 | /** |
| 4800 | 4800 | * Output html select to select thirdparty |
| 4801 | 4801 | * |
@@ -4810,9 +4810,9 @@ discard block |
||
| 4810 | 4810 | * @param int $nooutput No print output. Return it only. |
| 4811 | 4811 | * @return void|string |
| 4812 | 4812 | */ |
| 4813 | - public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) |
|
| 4813 | + public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) |
|
| 4814 | 4814 | { |
| 4815 | - // phpcs:enable |
|
| 4815 | + // phpcs:enable |
|
| 4816 | 4816 | global $langs; |
| 4817 | 4817 | |
| 4818 | 4818 | $out = ''; |
@@ -4840,18 +4840,18 @@ discard block |
||
| 4840 | 4840 | else print $out; |
| 4841 | 4841 | } |
| 4842 | 4842 | |
| 4843 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4843 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4844 | 4844 | /** |
| 4845 | 4845 | * Retourne la liste des devises, dans la langue de l'utilisateur |
| 4846 | 4846 | * |
| 4847 | 4847 | * @param string $selected preselected currency code |
| 4848 | 4848 | * @param string $htmlname name of HTML select list |
| 4849 | - * @deprecated |
|
| 4849 | + * @deprecated |
|
| 4850 | 4850 | * @return void |
| 4851 | 4851 | */ |
| 4852 | - public function select_currency($selected = '', $htmlname = 'currency_id') |
|
| 4852 | + public function select_currency($selected = '', $htmlname = 'currency_id') |
|
| 4853 | 4853 | { |
| 4854 | - // phpcs:enable |
|
| 4854 | + // phpcs:enable |
|
| 4855 | 4855 | print $this->selectCurrency($selected, $htmlname); |
| 4856 | 4856 | } |
| 4857 | 4857 | |
@@ -4863,7 +4863,7 @@ discard block |
||
| 4863 | 4863 | * @param string $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code |
| 4864 | 4864 | * @return string |
| 4865 | 4865 | */ |
| 4866 | - public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0) |
|
| 4866 | + public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0) |
|
| 4867 | 4867 | { |
| 4868 | 4868 | global $conf, $langs, $user; |
| 4869 | 4869 | |
@@ -4885,9 +4885,9 @@ discard block |
||
| 4885 | 4885 | $out .= $currency['label']; |
| 4886 | 4886 | if ($mode == 1) |
| 4887 | 4887 | { |
| 4888 | - $out .= ' ('.$code_iso.')'; |
|
| 4888 | + $out .= ' ('.$code_iso.')'; |
|
| 4889 | 4889 | } else { |
| 4890 | - $out .= ' ('.$langs->getCurrencySymbol($code_iso).')'; |
|
| 4890 | + $out .= ' ('.$langs->getCurrencySymbol($code_iso).')'; |
|
| 4891 | 4891 | } |
| 4892 | 4892 | $out .= '</option>'; |
| 4893 | 4893 | } |
@@ -4909,7 +4909,7 @@ discard block |
||
| 4909 | 4909 | * @param integer $useempty 1=Add empty line |
| 4910 | 4910 | * @return string |
| 4911 | 4911 | */ |
| 4912 | - public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) |
|
| 4912 | + public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) |
|
| 4913 | 4913 | { |
| 4914 | 4914 | global $db, $conf, $langs, $user; |
| 4915 | 4915 | |
@@ -4957,16 +4957,16 @@ discard block |
||
| 4957 | 4957 | return $out; |
| 4958 | 4958 | } |
| 4959 | 4959 | |
| 4960 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4960 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 4961 | 4961 | /** |
| 4962 | 4962 | * Load into the cache vat rates of a country |
| 4963 | 4963 | * |
| 4964 | 4964 | * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'") |
| 4965 | 4965 | * @return int Nb of loaded lines, 0 if already loaded, <0 if KO |
| 4966 | 4966 | */ |
| 4967 | - public function load_cache_vatrates($country_code) |
|
| 4967 | + public function load_cache_vatrates($country_code) |
|
| 4968 | 4968 | { |
| 4969 | - // phpcs:enable |
|
| 4969 | + // phpcs:enable |
|
| 4970 | 4970 | global $langs; |
| 4971 | 4971 | |
| 4972 | 4972 | $num = count($this->cache_vatrates); |
@@ -5020,7 +5020,7 @@ discard block |
||
| 5020 | 5020 | } |
| 5021 | 5021 | } |
| 5022 | 5022 | |
| 5023 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5023 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5024 | 5024 | /** |
| 5025 | 5025 | * Output an HTML select vat rate. |
| 5026 | 5026 | * The name of this function should be selectVat. We keep bad name for compatibility purpose. |
@@ -5042,9 +5042,9 @@ discard block |
||
| 5042 | 5042 | * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key |
| 5043 | 5043 | * @return string |
| 5044 | 5044 | */ |
| 5045 | - public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) |
|
| 5045 | + public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) |
|
| 5046 | 5046 | { |
| 5047 | - // phpcs:enable |
|
| 5047 | + // phpcs:enable |
|
| 5048 | 5048 | global $langs, $conf, $mysoc; |
| 5049 | 5049 | |
| 5050 | 5050 | $langs->load('errors'); |
@@ -5124,10 +5124,10 @@ discard block |
||
| 5124 | 5124 | $tmpthirdparty = new Societe($this->db); |
| 5125 | 5125 | $defaulttx = get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod); |
| 5126 | 5126 | $defaultnpr = get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod); |
| 5127 | - if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { |
|
| 5128 | - $defaultcode = $reg[1]; |
|
| 5129 | - $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); |
|
| 5130 | - } |
|
| 5127 | + if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { |
|
| 5128 | + $defaultcode = $reg[1]; |
|
| 5129 | + $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); |
|
| 5130 | + } |
|
| 5131 | 5131 | if (empty($defaulttx)) $defaultnpr = 0; |
| 5132 | 5132 | } |
| 5133 | 5133 | |
@@ -5206,9 +5206,9 @@ discard block |
||
| 5206 | 5206 | } |
| 5207 | 5207 | |
| 5208 | 5208 | |
| 5209 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5210 | - /** |
|
| 5211 | - * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. |
|
| 5209 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5210 | + /** |
|
| 5211 | + * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. |
|
| 5212 | 5212 | * Fields are preselected with : |
| 5213 | 5213 | * - set_time date (must be a local PHP server timestamp or string date with format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM') |
| 5214 | 5214 | * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) |
@@ -5228,22 +5228,22 @@ discard block |
||
| 5228 | 5228 | * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. |
| 5229 | 5229 | * @param datetime $adddateof Add a link "Date of invoice" using the following date. |
| 5230 | 5230 | * @return string|void Nothing or string if nooutput is 1 |
| 5231 | - * @deprecated |
|
| 5231 | + * @deprecated |
|
| 5232 | 5232 | * @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek() |
| 5233 | 5233 | */ |
| 5234 | - public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') |
|
| 5235 | - { |
|
| 5236 | - // phpcs:enable |
|
| 5237 | - $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); |
|
| 5238 | - if (!empty($nooutput)) { |
|
| 5239 | - return $retstring; |
|
| 5240 | - } |
|
| 5241 | - print $retstring; |
|
| 5242 | - return; |
|
| 5243 | - } |
|
| 5244 | - |
|
| 5245 | - /** |
|
| 5246 | - * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. |
|
| 5234 | + public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') |
|
| 5235 | + { |
|
| 5236 | + // phpcs:enable |
|
| 5237 | + $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); |
|
| 5238 | + if (!empty($nooutput)) { |
|
| 5239 | + return $retstring; |
|
| 5240 | + } |
|
| 5241 | + print $retstring; |
|
| 5242 | + return; |
|
| 5243 | + } |
|
| 5244 | + |
|
| 5245 | + /** |
|
| 5246 | + * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. |
|
| 5247 | 5247 | * Fields are preselected with : |
| 5248 | 5248 | * - set_time date (must be a local PHP server timestamp or string date with format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM') |
| 5249 | 5249 | * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) |
@@ -5261,13 +5261,13 @@ discard block |
||
| 5261 | 5261 | * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 |
| 5262 | 5262 | * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. |
| 5263 | 5263 | * @param datetime $adddateof Add a link "Date of ..." using the following date. See also $labeladddateof for the label used. |
| 5264 | - * @param string $openinghours Specify hour start and hour end for the select ex 8,20 |
|
| 5265 | - * @param int $stepminutes Specify step for minutes between 1 and 30 |
|
| 5266 | - * @param string $labeladddateof Label to use for the $adddateof parameter. |
|
| 5264 | + * @param string $openinghours Specify hour start and hour end for the select ex 8,20 |
|
| 5265 | + * @param int $stepminutes Specify step for minutes between 1 and 30 |
|
| 5266 | + * @param string $labeladddateof Label to use for the $adddateof parameter. |
|
| 5267 | 5267 | * @return string Html for selectDate |
| 5268 | 5268 | * @see form_date(), select_month(), select_year(), select_dayofweek() |
| 5269 | 5269 | */ |
| 5270 | - public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '') |
|
| 5270 | + public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '') |
|
| 5271 | 5271 | { |
| 5272 | 5272 | global $conf, $langs; |
| 5273 | 5273 | |
@@ -5278,7 +5278,7 @@ discard block |
||
| 5278 | 5278 | if ($m == '') $m = 0; |
| 5279 | 5279 | $emptydate = 0; |
| 5280 | 5280 | $emptyhours = 0; |
| 5281 | - if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1; |
|
| 5281 | + if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1; |
|
| 5282 | 5282 | if ($empty == 1) { $emptydate = 1; $emptyhours = 1; } |
| 5283 | 5283 | if ($empty == 2) { $emptydate = 0; $emptyhours = 1; } |
| 5284 | 5284 | $orig_set_time = $set_time; |
@@ -5525,31 +5525,31 @@ discard block |
||
| 5525 | 5525 | { |
| 5526 | 5526 | // Script which will be inserted in the onClick of the "Now" link |
| 5527 | 5527 | $reset_scripts = ""; |
| 5528 | - if ($addnowlink == 2) // local computer time |
|
| 5529 | - { |
|
| 5530 | - // pad add leading 0 on numbers |
|
| 5531 | - $reset_scripts .= "Number.prototype.pad = function(size) { |
|
| 5528 | + if ($addnowlink == 2) // local computer time |
|
| 5529 | + { |
|
| 5530 | + // pad add leading 0 on numbers |
|
| 5531 | + $reset_scripts .= "Number.prototype.pad = function(size) { |
|
| 5532 | 5532 | var s = String(this); |
| 5533 | 5533 | while (s.length < (size || 2)) {s = '0' + s;} |
| 5534 | 5534 | return s; |
| 5535 | 5535 | }; |
| 5536 | 5536 | var d = new Date();"; |
| 5537 | - } |
|
| 5537 | + } |
|
| 5538 | 5538 | |
| 5539 | 5539 | // Generate the date part, depending on the use or not of the javascript calendar |
| 5540 | - if ($addnowlink == 1) // server time expressed in user time setup |
|
| 5541 | - { |
|
| 5542 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; |
|
| 5543 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; |
|
| 5544 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; |
|
| 5545 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; |
|
| 5546 | - } elseif ($addnowlink == 2) |
|
| 5547 | - { |
|
| 5548 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; |
|
| 5549 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; |
|
| 5550 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; |
|
| 5551 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; |
|
| 5552 | - } |
|
| 5540 | + if ($addnowlink == 1) // server time expressed in user time setup |
|
| 5541 | + { |
|
| 5542 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; |
|
| 5543 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; |
|
| 5544 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; |
|
| 5545 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; |
|
| 5546 | + } elseif ($addnowlink == 2) |
|
| 5547 | + { |
|
| 5548 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; |
|
| 5549 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; |
|
| 5550 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; |
|
| 5551 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; |
|
| 5552 | + } |
|
| 5553 | 5553 | /*if ($usecalendar == "eldy") |
| 5554 | 5554 | { |
| 5555 | 5555 | $base=DOL_URL_ROOT.'/core/'; |
@@ -5566,13 +5566,13 @@ discard block |
||
| 5566 | 5566 | { |
| 5567 | 5567 | if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
| 5568 | 5568 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; |
| 5569 | - if ($addnowlink == 1) |
|
| 5570 | - { |
|
| 5571 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; |
|
| 5572 | - } elseif ($addnowlink == 2) |
|
| 5573 | - { |
|
| 5574 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; |
|
| 5575 | - } |
|
| 5569 | + if ($addnowlink == 1) |
|
| 5570 | + { |
|
| 5571 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; |
|
| 5572 | + } elseif ($addnowlink == 2) |
|
| 5573 | + { |
|
| 5574 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; |
|
| 5575 | + } |
|
| 5576 | 5576 | |
| 5577 | 5577 | if ($fullday) $reset_scripts .= ' } '; |
| 5578 | 5578 | } |
@@ -5581,13 +5581,13 @@ discard block |
||
| 5581 | 5581 | { |
| 5582 | 5582 | if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
| 5583 | 5583 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; |
| 5584 | - if ($addnowlink == 1) |
|
| 5585 | - { |
|
| 5586 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; |
|
| 5587 | - } elseif ($addnowlink == 2) |
|
| 5588 | - { |
|
| 5589 | - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; |
|
| 5590 | - } |
|
| 5584 | + if ($addnowlink == 1) |
|
| 5585 | + { |
|
| 5586 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; |
|
| 5587 | + } elseif ($addnowlink == 2) |
|
| 5588 | + { |
|
| 5589 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; |
|
| 5590 | + } |
|
| 5591 | 5591 | if ($fullday) $reset_scripts .= ' } '; |
| 5592 | 5592 | } |
| 5593 | 5593 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick |
@@ -5644,9 +5644,9 @@ discard block |
||
| 5644 | 5644 | return $retstring; |
| 5645 | 5645 | } |
| 5646 | 5646 | |
| 5647 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5648 | - /** |
|
| 5649 | - * Function to show a form to select a duration on a page |
|
| 5647 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 5648 | + /** |
|
| 5649 | + * Function to show a form to select a duration on a page |
|
| 5650 | 5650 | * |
| 5651 | 5651 | * @param string $prefix Prefix for input fields |
| 5652 | 5652 | * @param int $iSecond Default preselected duration (number of seconds or '') |
@@ -5658,9 +5658,9 @@ discard block |
||
| 5658 | 5658 | * @param int $nooutput Do not output html string but return it |
| 5659 | 5659 | * @return string|void |
| 5660 | 5660 | */ |
| 5661 | - public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) |
|
| 5661 | + public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) |
|
| 5662 | 5662 | { |
| 5663 | - // phpcs:enable |
|
| 5663 | + // phpcs:enable |
|
| 5664 | 5664 | global $langs; |
| 5665 | 5665 | |
| 5666 | 5666 | $retstring = ''; |
@@ -5788,16 +5788,16 @@ discard block |
||
| 5788 | 5788 | $out = ''; |
| 5789 | 5789 | if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) |
| 5790 | 5790 | { |
| 5791 | - // No immediate load of all database |
|
| 5792 | - $placeholder = ''; |
|
| 5793 | - if ($preselectedvalue && empty($selected_input_value)) |
|
| 5794 | - { |
|
| 5795 | - $objecttmp->fetch($preselectedvalue); |
|
| 5796 | - $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref); |
|
| 5797 | - //unset($objecttmp); |
|
| 5798 | - } |
|
| 5791 | + // No immediate load of all database |
|
| 5792 | + $placeholder = ''; |
|
| 5793 | + if ($preselectedvalue && empty($selected_input_value)) |
|
| 5794 | + { |
|
| 5795 | + $objecttmp->fetch($preselectedvalue); |
|
| 5796 | + $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref); |
|
| 5797 | + //unset($objecttmp); |
|
| 5798 | + } |
|
| 5799 | 5799 | |
| 5800 | - $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; |
|
| 5800 | + $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; |
|
| 5801 | 5801 | $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; |
| 5802 | 5802 | |
| 5803 | 5803 | // No immediate load of all database |
@@ -5859,7 +5859,7 @@ discard block |
||
| 5859 | 5859 | * @return string|array Return HTML string |
| 5860 | 5860 | * @see selectForForms() |
| 5861 | 5861 | */ |
| 5862 | - public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) |
|
| 5862 | + public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) |
|
| 5863 | 5863 | { |
| 5864 | 5864 | global $conf, $langs, $user; |
| 5865 | 5865 | |
@@ -5880,7 +5880,7 @@ discard block |
||
| 5880 | 5880 | } else { |
| 5881 | 5881 | // For backward compatibility |
| 5882 | 5882 | $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1); |
| 5883 | - } |
|
| 5883 | + } |
|
| 5884 | 5884 | |
| 5885 | 5885 | if (empty($fieldstoshow)) |
| 5886 | 5886 | { |
@@ -6064,8 +6064,8 @@ discard block |
||
| 6064 | 6064 | { |
| 6065 | 6065 | foreach ($array as $key => $value) |
| 6066 | 6066 | { |
| 6067 | - if (!is_array($value)) $array[$key] = $langs->trans($value); |
|
| 6068 | - else $array[$key]['label'] = $langs->trans($value['label']); |
|
| 6067 | + if (!is_array($value)) $array[$key] = $langs->trans($value); |
|
| 6068 | + else $array[$key]['label'] = $langs->trans($value['label']); |
|
| 6069 | 6069 | } |
| 6070 | 6070 | } |
| 6071 | 6071 | |
@@ -6075,14 +6075,14 @@ discard block |
||
| 6075 | 6075 | |
| 6076 | 6076 | foreach ($array as $key => $tmpvalue) |
| 6077 | 6077 | { |
| 6078 | - if (is_array($tmpvalue)) $value = $tmpvalue['label']; |
|
| 6079 | - else $value = $tmpvalue; |
|
| 6078 | + if (is_array($tmpvalue)) $value = $tmpvalue['label']; |
|
| 6079 | + else $value = $tmpvalue; |
|
| 6080 | 6080 | |
| 6081 | 6081 | $disabled = ''; $style = ''; |
| 6082 | 6082 | if (!empty($disablebademail)) |
| 6083 | 6083 | { |
| 6084 | - if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) |
|
| 6085 | - || ($disablebademail == 2 && preg_match('/---/', $value))) |
|
| 6084 | + if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) |
|
| 6085 | + || ($disablebademail == 2 && preg_match('/---/', $value))) |
|
| 6086 | 6086 | { |
| 6087 | 6087 | $disabled = ' disabled'; |
| 6088 | 6088 | $style = ' class="warning"'; |
@@ -6110,10 +6110,10 @@ discard block |
||
| 6110 | 6110 | if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; |
| 6111 | 6111 | if (is_array($tmpvalue)) |
| 6112 | 6112 | { |
| 6113 | - foreach ($tmpvalue as $keyforvalue => $valueforvalue) |
|
| 6114 | - { |
|
| 6115 | - if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; |
|
| 6116 | - } |
|
| 6113 | + foreach ($tmpvalue as $keyforvalue => $valueforvalue) |
|
| 6114 | + { |
|
| 6115 | + if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; |
|
| 6116 | + } |
|
| 6117 | 6117 | } |
| 6118 | 6118 | $out .= '>'; |
| 6119 | 6119 | //var_dump($selectOptionValue); |
@@ -6227,11 +6227,11 @@ discard block |
||
| 6227 | 6227 | return $out; |
| 6228 | 6228 | } |
| 6229 | 6229 | |
| 6230 | - /** |
|
| 6231 | - * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. |
|
| 6232 | - * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. |
|
| 6233 | - * |
|
| 6234 | - * @param string $htmlname Name of html select area |
|
| 6230 | + /** |
|
| 6231 | + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. |
|
| 6232 | + * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. |
|
| 6233 | + * |
|
| 6234 | + * @param string $htmlname Name of html select area |
|
| 6235 | 6235 | * @param string $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...) |
| 6236 | 6236 | * @param string $id Preselected key |
| 6237 | 6237 | * @param string $moreparam Add more parameters onto the select tag |
@@ -6368,8 +6368,8 @@ discard block |
||
| 6368 | 6368 | $out = ''; |
| 6369 | 6369 | |
| 6370 | 6370 | if ($addjscombo < 0) { |
| 6371 | - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; |
|
| 6372 | - else $addjscombo = 0; |
|
| 6371 | + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; |
|
| 6372 | + else $addjscombo = 0; |
|
| 6373 | 6373 | } |
| 6374 | 6374 | |
| 6375 | 6375 | // Add code for jquery to use multiselect |
@@ -6437,7 +6437,7 @@ discard block |
||
| 6437 | 6437 | foreach ($array as $key => $value) |
| 6438 | 6438 | { |
| 6439 | 6439 | $out .= '<option value="'.$key.'"'; |
| 6440 | - if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) |
|
| 6440 | + if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) |
|
| 6441 | 6441 | { |
| 6442 | 6442 | $out .= ' selected'; |
| 6443 | 6443 | } |
@@ -6489,19 +6489,19 @@ discard block |
||
| 6489 | 6489 | |
| 6490 | 6490 | foreach ($array as $key => $val) |
| 6491 | 6491 | { |
| 6492 | - /* var_dump($val); |
|
| 6492 | + /* var_dump($val); |
|
| 6493 | 6493 | var_dump(array_key_exists('enabled', $val)); |
| 6494 | 6494 | var_dump(!$val['enabled']);*/ |
| 6495 | - if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) |
|
| 6496 | - { |
|
| 6497 | - unset($array[$key]); // We don't want this field |
|
| 6498 | - continue; |
|
| 6499 | - } |
|
| 6500 | - if ($val['label']) |
|
| 6501 | - { |
|
| 6502 | - $lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>'; |
|
| 6503 | - $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); |
|
| 6504 | - } |
|
| 6495 | + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) |
|
| 6496 | + { |
|
| 6497 | + unset($array[$key]); // We don't want this field |
|
| 6498 | + continue; |
|
| 6499 | + } |
|
| 6500 | + if ($val['label']) |
|
| 6501 | + { |
|
| 6502 | + $lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>'; |
|
| 6503 | + $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); |
|
| 6504 | + } |
|
| 6505 | 6505 | } |
| 6506 | 6506 | |
| 6507 | 6507 | $out = '<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' --> |
@@ -6557,7 +6557,7 @@ discard block |
||
| 6557 | 6557 | * @param int $nolink 1=Do not add html links |
| 6558 | 6558 | * @return string String with categories |
| 6559 | 6559 | */ |
| 6560 | - public function showCategories($id, $type, $rendermode = 0, $nolink = 0) |
|
| 6560 | + public function showCategories($id, $type, $rendermode = 0, $nolink = 0) |
|
| 6561 | 6561 | { |
| 6562 | 6562 | global $db; |
| 6563 | 6563 | |
@@ -6602,7 +6602,7 @@ discard block |
||
| 6602 | 6602 | * @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action |
| 6603 | 6603 | * @return int <0 if KO, >=0 if OK |
| 6604 | 6604 | */ |
| 6605 | - public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false) |
|
| 6605 | + public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false) |
|
| 6606 | 6606 | { |
| 6607 | 6607 | global $conf, $langs, $hookmanager; |
| 6608 | 6608 | global $bc, $action; |
@@ -6613,7 +6613,7 @@ discard block |
||
| 6613 | 6613 | $hookmanager->initHooks(array('commonobject')); |
| 6614 | 6614 | $parameters = array( |
| 6615 | 6615 | 'morehtmlright' => $morehtmlright, |
| 6616 | - 'compatibleImportElementsList' => &$compatibleImportElementsList, |
|
| 6616 | + 'compatibleImportElementsList' => &$compatibleImportElementsList, |
|
| 6617 | 6617 | ); |
| 6618 | 6618 | $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
| 6619 | 6619 | |
@@ -6647,7 +6647,7 @@ discard block |
||
| 6647 | 6647 | // to display inport button on tpl |
| 6648 | 6648 | $showImportButton = false; |
| 6649 | 6649 | if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) { |
| 6650 | - $showImportButton = true; |
|
| 6650 | + $showImportButton = true; |
|
| 6651 | 6651 | } |
| 6652 | 6652 | |
| 6653 | 6653 | $regs = array(); |
@@ -6676,9 +6676,9 @@ discard block |
||
| 6676 | 6676 | $tplpath = 'expedition'; |
| 6677 | 6677 | if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled |
| 6678 | 6678 | } elseif ($objecttype == 'reception') { |
| 6679 | - $tplpath = 'reception'; |
|
| 6680 | - if (empty($conf->reception->enabled)) continue; // Do not show if module disabled |
|
| 6681 | - } elseif ($objecttype == 'delivery') { |
|
| 6679 | + $tplpath = 'reception'; |
|
| 6680 | + if (empty($conf->reception->enabled)) continue; // Do not show if module disabled |
|
| 6681 | + } elseif ($objecttype == 'delivery') { |
|
| 6682 | 6682 | $tplpath = 'livraison'; |
| 6683 | 6683 | if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled |
| 6684 | 6684 | } elseif ($objecttype == 'invoice_supplier') { |
@@ -6723,7 +6723,7 @@ discard block |
||
| 6723 | 6723 | |
| 6724 | 6724 | if (!empty($compatibleImportElementsList)) |
| 6725 | 6725 | { |
| 6726 | - $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); |
|
| 6726 | + $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); |
|
| 6727 | 6727 | } |
| 6728 | 6728 | |
| 6729 | 6729 | |
@@ -6741,7 +6741,7 @@ discard block |
||
| 6741 | 6741 | * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. |
| 6742 | 6742 | * @return string <0 if KO, >0 if OK |
| 6743 | 6743 | */ |
| 6744 | - public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) |
|
| 6744 | + public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) |
|
| 6745 | 6745 | { |
| 6746 | 6746 | global $conf, $langs, $hookmanager; |
| 6747 | 6747 | global $bc, $action; |
@@ -6787,7 +6787,7 @@ discard block |
||
| 6787 | 6787 | |
| 6788 | 6788 | if (!empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the object we can link to |
| 6789 | 6789 | { |
| 6790 | - $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 6790 | + $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 6791 | 6791 | } |
| 6792 | 6792 | |
| 6793 | 6793 | if (empty($reshook)) |
@@ -6889,7 +6889,7 @@ discard block |
||
| 6889 | 6889 | |
| 6890 | 6890 | if (!empty($conf->use_javascript_ajax)) |
| 6891 | 6891 | { |
| 6892 | - print '<!-- Add js to show linkto box --> |
|
| 6892 | + print '<!-- Add js to show linkto box --> |
|
| 6893 | 6893 | <script> |
| 6894 | 6894 | jQuery(document).ready(function() { |
| 6895 | 6895 | jQuery(".linkto").click(function() { |
@@ -6914,7 +6914,7 @@ discard block |
||
| 6914 | 6914 | * @param int $useempty 1=Add empty line |
| 6915 | 6915 | * @return string See option |
| 6916 | 6916 | */ |
| 6917 | - public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) |
|
| 6917 | + public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) |
|
| 6918 | 6918 | { |
| 6919 | 6919 | global $langs; |
| 6920 | 6920 | |
@@ -6942,7 +6942,7 @@ discard block |
||
| 6942 | 6942 | return $resultyesno; |
| 6943 | 6943 | } |
| 6944 | 6944 | |
| 6945 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 6945 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 6946 | 6946 | /** |
| 6947 | 6947 | * Return list of export templates |
| 6948 | 6948 | * |
@@ -6952,9 +6952,9 @@ discard block |
||
| 6952 | 6952 | * @param int $useempty Affiche valeur vide dans liste |
| 6953 | 6953 | * @return void |
| 6954 | 6954 | */ |
| 6955 | - public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0) |
|
| 6955 | + public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0) |
|
| 6956 | 6956 | { |
| 6957 | - // phpcs:enable |
|
| 6957 | + // phpcs:enable |
|
| 6958 | 6958 | $sql = "SELECT rowid, label"; |
| 6959 | 6959 | $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; |
| 6960 | 6960 | $sql .= " WHERE type = '".$type."'"; |
@@ -7007,7 +7007,7 @@ discard block |
||
| 7007 | 7007 | * @param string $morehtmlright More html code to show after ref. |
| 7008 | 7008 | * @return string Portion HTML with ref + navigation buttons |
| 7009 | 7009 | */ |
| 7010 | - public function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '') |
|
| 7010 | + public function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '') |
|
| 7011 | 7011 | { |
| 7012 | 7012 | global $langs, $conf, $hookmanager, $extralanguages; |
| 7013 | 7013 | |
@@ -7032,11 +7032,11 @@ discard block |
||
| 7032 | 7032 | // Special case for project/task page |
| 7033 | 7033 | if ($paramid == 'project_ref') |
| 7034 | 7034 | { |
| 7035 | - if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl)) // TODO Remove this when nav with project_ref on task pages are ok |
|
| 7036 | - { |
|
| 7037 | - $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/', '/tasks.php', $navurl); |
|
| 7038 | - $paramid = 'ref'; |
|
| 7039 | - } |
|
| 7035 | + if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl)) // TODO Remove this when nav with project_ref on task pages are ok |
|
| 7036 | + { |
|
| 7037 | + $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/', '/tasks.php', $navurl); |
|
| 7038 | + $paramid = 'ref'; |
|
| 7039 | + } |
|
| 7040 | 7040 | } |
| 7041 | 7041 | |
| 7042 | 7042 | // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox |
@@ -7187,7 +7187,7 @@ discard block |
||
| 7187 | 7187 | * @param int $width Width of photo |
| 7188 | 7188 | * @return string HTML code to output barcode |
| 7189 | 7189 | */ |
| 7190 | - public function showbarcode(&$object, $width = 100) |
|
| 7190 | + public function showbarcode(&$object, $width = 100) |
|
| 7191 | 7191 | { |
| 7192 | 7192 | global $conf; |
| 7193 | 7193 | |
@@ -7360,7 +7360,7 @@ discard block |
||
| 7360 | 7360 | return $ret; |
| 7361 | 7361 | } |
| 7362 | 7362 | |
| 7363 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 7363 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 7364 | 7364 | /** |
| 7365 | 7365 | * Return select list of groups |
| 7366 | 7366 | * |
@@ -7377,9 +7377,9 @@ discard block |
||
| 7377 | 7377 | * @return string |
| 7378 | 7378 | * @see select_dolusers() |
| 7379 | 7379 | */ |
| 7380 | - public function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $multiple = false, $morecss = '') |
|
| 7380 | + public function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $multiple = false, $morecss = '') |
|
| 7381 | 7381 | { |
| 7382 | - // phpcs:enable |
|
| 7382 | + // phpcs:enable |
|
| 7383 | 7383 | global $conf, $user, $langs; |
| 7384 | 7384 | |
| 7385 | 7385 | // Permettre l'exclusion de groupes |
@@ -7467,7 +7467,7 @@ discard block |
||
| 7467 | 7467 | * |
| 7468 | 7468 | * @return string |
| 7469 | 7469 | */ |
| 7470 | - public function showFilterButtons() |
|
| 7470 | + public function showFilterButtons() |
|
| 7471 | 7471 | { |
| 7472 | 7472 | $out = '<div class="nowrap">'; |
| 7473 | 7473 | $out .= '<button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>'; |
@@ -7482,16 +7482,16 @@ discard block |
||
| 7482 | 7482 | * |
| 7483 | 7483 | * @param string $cssclass CSS class |
| 7484 | 7484 | * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes |
| 7485 | - * @param string $massactionname Mass action button name that will launch an action on the selected items |
|
| 7485 | + * @param string $massactionname Mass action button name that will launch an action on the selected items |
|
| 7486 | 7486 | * @return string |
| 7487 | 7487 | */ |
| 7488 | - public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") |
|
| 7488 | + public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") |
|
| 7489 | 7489 | { |
| 7490 | 7490 | global $conf, $langs; |
| 7491 | 7491 | |
| 7492 | 7492 | $out = ''; |
| 7493 | 7493 | $id = uniqid(); |
| 7494 | - if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass . 's" name="' . $cssclass . 's" class="checkallactions"></div>'; |
|
| 7494 | + if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass . 's" name="' . $cssclass . 's" class="checkallactions"></div>'; |
|
| 7495 | 7495 | $out .= '<script> |
| 7496 | 7496 | $(document).ready(function() { |
| 7497 | 7497 | $("#' . $cssclass . 's").click(function() { |
@@ -7504,7 +7504,7 @@ discard block |
||
| 7504 | 7504 | console.log("We uncheck all"); |
| 7505 | 7505 | $(".'.$cssclass.'").prop(\'checked\', false).trigger(\'change\'); |
| 7506 | 7506 | }'."\n"; |
| 7507 | - if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname . '", "' . $cssclass . '"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; |
|
| 7507 | + if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname . '", "' . $cssclass . '"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; |
|
| 7508 | 7508 | $out .= ' }); |
| 7509 | 7509 | |
| 7510 | 7510 | $(".' . $cssclass . '").change(function() { |
@@ -7523,10 +7523,10 @@ discard block |
||
| 7523 | 7523 | * @param int $addcheckuncheckall Add the check all/uncheck all checkbox (use javascript) and code to manage this |
| 7524 | 7524 | * @param string $cssclass CSS class |
| 7525 | 7525 | * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes |
| 7526 | - * @param string $massactionname Mass action name |
|
| 7526 | + * @param string $massactionname Mass action name |
|
| 7527 | 7527 | * @return string |
| 7528 | 7528 | */ |
| 7529 | - public function showFilterAndCheckAddButtons($addcheckuncheckall = 0, $cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") |
|
| 7529 | + public function showFilterAndCheckAddButtons($addcheckuncheckall = 0, $cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") |
|
| 7530 | 7530 | { |
| 7531 | 7531 | $out = $this->showFilterButtons(); |
| 7532 | 7532 | if ($addcheckuncheckall) |
@@ -7548,12 +7548,12 @@ discard block |
||
| 7548 | 7548 | * @param array $params param to give |
| 7549 | 7549 | * @return string |
| 7550 | 7550 | */ |
| 7551 | - public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) |
|
| 7551 | + public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) |
|
| 7552 | 7552 | { |
| 7553 | 7553 | global $db, $conf, $langs, $user; |
| 7554 | 7554 | |
| 7555 | - $out = ''; |
|
| 7556 | - $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; |
|
| 7555 | + $out = ''; |
|
| 7556 | + $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; |
|
| 7557 | 7557 | $sql .= ' AND entity IN (0,'.getEntity('exp_tax_cat').')'; |
| 7558 | 7558 | if (!empty($excludeid)) $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')'; |
| 7559 | 7559 | $sql .= ' ORDER BY label'; |
@@ -7636,11 +7636,11 @@ discard block |
||
| 7636 | 7636 | * @param integer $useempty 1=Add empty line |
| 7637 | 7637 | * @return string |
| 7638 | 7638 | */ |
| 7639 | - public function selectExpenseRanges($selected = '', $htmlname = 'fk_range', $useempty = 0) |
|
| 7639 | + public function selectExpenseRanges($selected = '', $htmlname = 'fk_range', $useempty = 0) |
|
| 7640 | 7640 | { |
| 7641 | 7641 | global $db, $conf, $langs; |
| 7642 | 7642 | |
| 7643 | - $out = ''; |
|
| 7643 | + $out = ''; |
|
| 7644 | 7644 | $sql = 'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.'c_exp_tax_range'; |
| 7645 | 7645 | $sql .= ' WHERE entity = '.$conf->entity.' AND active = 1'; |
| 7646 | 7646 | |
@@ -7672,11 +7672,11 @@ discard block |
||
| 7672 | 7672 | * @param integer $useid 0=use 'code' as key, 1=use 'id' as key |
| 7673 | 7673 | * @return string |
| 7674 | 7674 | */ |
| 7675 | - public function selectExpense($selected = '', $htmlname = 'fk_c_type_fees', $useempty = 0, $allchoice = 1, $useid = 0) |
|
| 7675 | + public function selectExpense($selected = '', $htmlname = 'fk_c_type_fees', $useempty = 0, $allchoice = 1, $useid = 0) |
|
| 7676 | 7676 | { |
| 7677 | 7677 | global $db, $langs; |
| 7678 | 7678 | |
| 7679 | - $out = ''; |
|
| 7679 | + $out = ''; |
|
| 7680 | 7680 | $sql = 'SELECT id, code, label FROM '.MAIN_DB_PREFIX.'c_type_fees'; |
| 7681 | 7681 | $sql .= ' WHERE active = 1'; |
| 7682 | 7682 | |
@@ -7700,8 +7700,8 @@ discard block |
||
| 7700 | 7700 | dol_print_error($db); |
| 7701 | 7701 | } |
| 7702 | 7702 | |
| 7703 | - return $out; |
|
| 7704 | - } |
|
| 7703 | + return $out; |
|
| 7704 | + } |
|
| 7705 | 7705 | |
| 7706 | 7706 | /** |
| 7707 | 7707 | * Output a combo list with invoices qualified for a third party |
@@ -7713,15 +7713,15 @@ discard block |
||
| 7713 | 7713 | * @param int $option_only Return only html options lines without the select tag |
| 7714 | 7714 | * @param string $show_empty Add an empty line ('1' or string to show for empty line) |
| 7715 | 7715 | * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) |
| 7716 | - * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 7717 | - * @param int $disabled Disabled |
|
| 7716 | + * @param int $forcefocus Force focus on field (works with javascript only) |
|
| 7717 | + * @param int $disabled Disabled |
|
| 7718 | 7718 | * @param string $morecss More css added to the select component |
| 7719 | 7719 | * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. |
| 7720 | 7720 | * @param string $showproject 'all' = Show project info, ''=Hide project info |
| 7721 | 7721 | * @param User $usertofilter User object to use for filtering |
| 7722 | 7722 | * @return int Nbr of project if OK, <0 if KO |
| 7723 | 7723 | */ |
| 7724 | - public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) |
|
| 7724 | + public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) |
|
| 7725 | 7725 | { |
| 7726 | 7726 | global $user, $conf, $langs; |
| 7727 | 7727 | |
@@ -7747,7 +7747,7 @@ discard block |
||
| 7747 | 7747 | } |
| 7748 | 7748 | |
| 7749 | 7749 | // Search all projects |
| 7750 | - $sql = 'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref, |
|
| 7750 | + $sql = 'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref, |
|
| 7751 | 7751 | p.title, p.fk_soc, p.fk_statut, p.public,'; |
| 7752 | 7752 | $sql .= ' s.nom as name'; |
| 7753 | 7753 | $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p'; |
@@ -7767,9 +7767,9 @@ discard block |
||
| 7767 | 7767 | if (!empty($conf->use_javascript_ajax)) |
| 7768 | 7768 | { |
| 7769 | 7769 | include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
| 7770 | - $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
|
| 7771 | - $out .= $comboenhancement; |
|
| 7772 | - $morecss = 'minwidth200imp maxwidth500'; |
|
| 7770 | + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
|
| 7771 | + $out .= $comboenhancement; |
|
| 7772 | + $morecss = 'minwidth200imp maxwidth500'; |
|
| 7773 | 7773 | } |
| 7774 | 7774 | |
| 7775 | 7775 | if (empty($option_only)) { |
@@ -7870,7 +7870,7 @@ discard block |
||
| 7870 | 7870 | */ |
| 7871 | 7871 | public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array()) |
| 7872 | 7872 | { |
| 7873 | - global $conf, $langs; |
|
| 7873 | + global $conf, $langs; |
|
| 7874 | 7874 | |
| 7875 | 7875 | $ret = ''; |
| 7876 | 7876 | |
@@ -7889,24 +7889,24 @@ discard block |
||
| 7889 | 7889 | $ret .= '<input type="hidden" name="search_component_params_hidden" class="search_component_params_hidden" value="'.GETPOST("search_component_params_hidden").'">'; |
| 7890 | 7890 | // For compatibility with forms that show themself the search criteria in addition of this component, we output the fields |
| 7891 | 7891 | foreach ($arrayofcriterias as $criterias) { |
| 7892 | - foreach ($criterias as $criteriafamilykey => $criteriafamilyval) { |
|
| 7893 | - if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; |
|
| 7894 | - if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; |
|
| 7895 | - if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { |
|
| 7896 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_start">'; |
|
| 7897 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startyear">'; |
|
| 7898 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startmonth">'; |
|
| 7899 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startday">'; |
|
| 7900 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_end">'; |
|
| 7901 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endyear">'; |
|
| 7902 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endmonth">'; |
|
| 7903 | - $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endday">'; |
|
| 7904 | - } else { |
|
| 7892 | + foreach ($criterias as $criteriafamilykey => $criteriafamilyval) { |
|
| 7893 | + if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; |
|
| 7894 | + if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; |
|
| 7895 | + if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { |
|
| 7896 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_start">'; |
|
| 7897 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startyear">'; |
|
| 7898 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startmonth">'; |
|
| 7899 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startday">'; |
|
| 7900 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_end">'; |
|
| 7901 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endyear">'; |
|
| 7902 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endmonth">'; |
|
| 7903 | + $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_endday">'; |
|
| 7904 | + } else { |
|
| 7905 | 7905 | $ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'">'; |
| 7906 | - } |
|
| 7907 | - } |
|
| 7906 | + } |
|
| 7907 | + } |
|
| 7908 | 7908 | } |
| 7909 | - $ret .= '</div>'; |
|
| 7909 | + $ret .= '</div>'; |
|
| 7910 | 7910 | |
| 7911 | 7911 | |
| 7912 | 7912 | return $ret; |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | $id = GETPOST('id', 'int'); |
| 32 | 32 | |
| 33 | 33 | if (!$id) { |
| 34 | - print json_encode(array( |
|
| 35 | - 'error' => 'ID not set' |
|
| 36 | - )); |
|
| 37 | - exit(); |
|
| 34 | + print json_encode(array( |
|
| 35 | + 'error' => 'ID not set' |
|
| 36 | + )); |
|
| 37 | + exit(); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $prodattr = new ProductAttribute($db); |
| 41 | 41 | |
| 42 | 42 | if ($prodattr->fetch($id) < 0) { |
| 43 | - print json_encode(array( |
|
| 44 | - 'error' => 'Attribute not found' |
|
| 45 | - )); |
|
| 46 | - exit(); |
|
| 43 | + print json_encode(array( |
|
| 44 | + 'error' => 'Attribute not found' |
|
| 45 | + )); |
|
| 46 | + exit(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $prodattrval = new ProductAttributeValue($db); |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $res = $prodattrval->fetchAllByProductAttribute($id); |
| 52 | 52 | |
| 53 | 53 | if ($res == -1) { |
| 54 | - print json_encode(array( |
|
| 55 | - 'error' => 'Internal error' |
|
| 56 | - )); |
|
| 57 | - exit(); |
|
| 54 | + print json_encode(array( |
|
| 55 | + 'error' => 'Internal error' |
|
| 56 | + )); |
|
| 57 | + exit(); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | print json_encode($res); |
@@ -409,13 +409,13 @@ discard block |
||
| 409 | 409 | $error++; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); |
|
| 413 | - $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); |
|
| 414 | - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) |
|
| 415 | - { |
|
| 416 | - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); |
|
| 417 | - $error++; |
|
| 418 | - } |
|
| 412 | + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); |
|
| 413 | + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); |
|
| 414 | + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) |
|
| 415 | + { |
|
| 416 | + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); |
|
| 417 | + $error++; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | // Extrafields |
| 421 | 421 | $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | $objectline->pa_ht = $pa_ht; |
| 684 | 684 | |
| 685 | 685 | if ($fk_unit > 0) { |
| 686 | - $objectline->fk_unit = GETPOST('unit'); |
|
| 686 | + $objectline->fk_unit = GETPOST('unit'); |
|
| 687 | 687 | } else { |
| 688 | - $objectline->fk_unit = null; |
|
| 688 | + $objectline->fk_unit = null; |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | // Extrafields |
@@ -876,11 +876,11 @@ discard block |
||
| 876 | 876 | |
| 877 | 877 | $old_ref = $object->ref; |
| 878 | 878 | |
| 879 | - $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); |
|
| 880 | - if ($result < 0) { |
|
| 881 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 882 | - $action = 'editref'; |
|
| 883 | - } else { |
|
| 879 | + $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); |
|
| 880 | + if ($result < 0) { |
|
| 881 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 882 | + $action = 'editref'; |
|
| 883 | + } else { |
|
| 884 | 884 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 885 | 885 | $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); |
| 886 | 886 | $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); |
@@ -895,13 +895,13 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 899 | - exit; |
|
| 900 | - } |
|
| 901 | - } else { |
|
| 902 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); |
|
| 903 | - exit; |
|
| 904 | - } |
|
| 898 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 899 | + exit; |
|
| 900 | + } |
|
| 901 | + } else { |
|
| 902 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); |
|
| 903 | + exit; |
|
| 904 | + } |
|
| 905 | 905 | } elseif ($action == 'setdate_contrat') |
| 906 | 906 | { |
| 907 | 907 | $cancelbutton = GETPOST('cancel', 'alpha'); |
@@ -1232,8 +1232,8 @@ discard block |
||
| 1232 | 1232 | |
| 1233 | 1233 | $result = $object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed |
| 1234 | 1234 | if ($result < 0) { |
| 1235 | - dol_print_error($db, $object->error); |
|
| 1236 | - } |
|
| 1235 | + dol_print_error($db, $object->error); |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | 1238 | $nbofservices = count($object->lines); |
| 1239 | 1239 | |
@@ -1248,55 +1248,55 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | $head = contract_prepare_head($object); |
| 1250 | 1250 | |
| 1251 | - $hselected = 0; |
|
| 1252 | - $formconfirm = ''; |
|
| 1253 | - |
|
| 1254 | - dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); |
|
| 1255 | - |
|
| 1256 | - |
|
| 1257 | - if ($action == 'delete') { |
|
| 1258 | - //Confirmation de la suppression du contrat |
|
| 1259 | - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); |
|
| 1260 | - } elseif ($action == 'valid') { |
|
| 1261 | - //Confirmation de la validation |
|
| 1262 | - $ref = substr($object->ref, 1, 4); |
|
| 1263 | - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { |
|
| 1264 | - $numref = $object->getNextNumRef($object->thirdparty); |
|
| 1265 | - } else { |
|
| 1266 | - $numref = $object->ref; |
|
| 1267 | - } |
|
| 1268 | - $text = $langs->trans('ConfirmValidateContract', $numref); |
|
| 1269 | - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); |
|
| 1270 | - } elseif ($action == 'close') { |
|
| 1271 | - // Confirmation de la fermeture |
|
| 1272 | - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); |
|
| 1273 | - } elseif ($action == 'activate') { |
|
| 1274 | - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); |
|
| 1275 | - } elseif ($action == 'clone') { |
|
| 1276 | - // Clone confirmation |
|
| 1277 | - $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); |
|
| 1278 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - |
|
| 1282 | - // Call Hook formConfirm |
|
| 1283 | - $parameters = array( |
|
| 1284 | - 'formConfirm' => $formconfirm, |
|
| 1285 | - 'id' => $id, |
|
| 1286 | - //'lineid' => $lineid, |
|
| 1287 | - ); |
|
| 1288 | - // Note that $action and $object may have been modified by hook |
|
| 1289 | - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); |
|
| 1290 | - if (empty($reshook)) { |
|
| 1291 | - $formconfirm .= $hookmanager->resPrint; |
|
| 1292 | - } elseif ($reshook > 0) { |
|
| 1293 | - $formconfirm = $hookmanager->resPrint; |
|
| 1294 | - } |
|
| 1295 | - |
|
| 1296 | - // Print form confirm |
|
| 1297 | - print $formconfirm; |
|
| 1298 | - |
|
| 1299 | - /* |
|
| 1251 | + $hselected = 0; |
|
| 1252 | + $formconfirm = ''; |
|
| 1253 | + |
|
| 1254 | + dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); |
|
| 1255 | + |
|
| 1256 | + |
|
| 1257 | + if ($action == 'delete') { |
|
| 1258 | + //Confirmation de la suppression du contrat |
|
| 1259 | + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); |
|
| 1260 | + } elseif ($action == 'valid') { |
|
| 1261 | + //Confirmation de la validation |
|
| 1262 | + $ref = substr($object->ref, 1, 4); |
|
| 1263 | + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { |
|
| 1264 | + $numref = $object->getNextNumRef($object->thirdparty); |
|
| 1265 | + } else { |
|
| 1266 | + $numref = $object->ref; |
|
| 1267 | + } |
|
| 1268 | + $text = $langs->trans('ConfirmValidateContract', $numref); |
|
| 1269 | + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); |
|
| 1270 | + } elseif ($action == 'close') { |
|
| 1271 | + // Confirmation de la fermeture |
|
| 1272 | + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); |
|
| 1273 | + } elseif ($action == 'activate') { |
|
| 1274 | + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); |
|
| 1275 | + } elseif ($action == 'clone') { |
|
| 1276 | + // Clone confirmation |
|
| 1277 | + $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); |
|
| 1278 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + |
|
| 1282 | + // Call Hook formConfirm |
|
| 1283 | + $parameters = array( |
|
| 1284 | + 'formConfirm' => $formconfirm, |
|
| 1285 | + 'id' => $id, |
|
| 1286 | + //'lineid' => $lineid, |
|
| 1287 | + ); |
|
| 1288 | + // Note that $action and $object may have been modified by hook |
|
| 1289 | + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); |
|
| 1290 | + if (empty($reshook)) { |
|
| 1291 | + $formconfirm .= $hookmanager->resPrint; |
|
| 1292 | + } elseif ($reshook > 0) { |
|
| 1293 | + $formconfirm = $hookmanager->resPrint; |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + // Print form confirm |
|
| 1297 | + print $formconfirm; |
|
| 1298 | + |
|
| 1299 | + /* |
|
| 1300 | 1300 | * Contrat |
| 1301 | 1301 | */ |
| 1302 | 1302 | if (!empty($object->brouillon) && $user->rights->contrat->creer) |
@@ -1490,8 +1490,8 @@ discard block |
||
| 1490 | 1490 | // Line in view mode |
| 1491 | 1491 | if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) |
| 1492 | 1492 | { |
| 1493 | - $moreparam = ''; |
|
| 1494 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1493 | + $moreparam = ''; |
|
| 1494 | + if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1495 | 1495 | print '<tr class="tdtop oddeven" '.$moreparam.'>'; |
| 1496 | 1496 | // Label |
| 1497 | 1497 | if ($objp->fk_product > 0) |
@@ -1723,8 +1723,8 @@ discard block |
||
| 1723 | 1723 | |
| 1724 | 1724 | if ($object->statut > 0) |
| 1725 | 1725 | { |
| 1726 | - $moreparam = ''; |
|
| 1727 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1726 | + $moreparam = ''; |
|
| 1727 | + if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1728 | 1728 | print '<tr class="oddeven" '.$moreparam.'>'; |
| 1729 | 1729 | print '<td class="tdhrthin" colspan="'.($conf->margin->enabled ? 7 : 6).'"><hr class="opacitymedium tdhrthin"></td>'; |
| 1730 | 1730 | print "</tr>\n"; |
@@ -1840,12 +1840,12 @@ discard block |
||
| 1840 | 1840 | // Si active et en cours |
| 1841 | 1841 | if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { |
| 1842 | 1842 | print $langs->trans("DateStartReal").': '; |
| 1843 | - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1843 | + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1844 | 1844 | } |
| 1845 | 1845 | // Si desactive |
| 1846 | 1846 | if ($objp->date_debut_reelle && $objp->date_fin_reelle) { |
| 1847 | 1847 | print $langs->trans("DateStartReal").': '; |
| 1848 | - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1848 | + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1849 | 1849 | print ' - '; |
| 1850 | 1850 | print $langs->trans("DateEndReal").': '; |
| 1851 | 1851 | print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); |
@@ -2086,11 +2086,11 @@ discard block |
||
| 2086 | 2086 | // print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("CloseRefusedBecauseOneServiceActive").'">'.$langs->trans("Close").'</a></div>'; |
| 2087 | 2087 | //} |
| 2088 | 2088 | } |
| 2089 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) |
|
| 2090 | - { |
|
| 2091 | - if ($action == 'showclosedlines') print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>'; |
|
| 2092 | - else print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>'; |
|
| 2093 | - } |
|
| 2089 | + if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) |
|
| 2090 | + { |
|
| 2091 | + if ($action == 'showclosedlines') print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>'; |
|
| 2092 | + else print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>'; |
|
| 2093 | + } |
|
| 2094 | 2094 | // On peut supprimer entite si |
| 2095 | 2095 | // - Droit de creer + mode brouillon (erreur creation) |
| 2096 | 2096 | // - Droit de supprimer |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) |
| 1492 | 1492 | { |
| 1493 | 1493 | $moreparam = ''; |
| 1494 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1494 | + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1495 | 1495 | print '<tr class="tdtop oddeven" '.$moreparam.'>'; |
| 1496 | 1496 | // Label |
| 1497 | 1497 | if ($objp->fk_product > 0) |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | $line = new ContratLigne($db); |
| 1625 | 1625 | $line->id = $objp->rowid; |
| 1626 | 1626 | $line->fetch_optionals(); |
| 1627 | - print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven','style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); |
|
| 1627 | + print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven', 'style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | // Line in mode update |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | if ($object->statut > 0) |
| 1725 | 1725 | { |
| 1726 | 1726 | $moreparam = ''; |
| 1727 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1727 | + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1728 | 1728 | print '<tr class="oddeven" '.$moreparam.'>'; |
| 1729 | 1729 | print '<td class="tdhrthin" colspan="'.($conf->margin->enabled ? 7 : 6).'"><hr class="opacitymedium tdhrthin"></td>'; |
| 1730 | 1730 | print "</tr>\n"; |
@@ -2086,7 +2086,7 @@ discard block |
||
| 2086 | 2086 | // print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("CloseRefusedBecauseOneServiceActive").'">'.$langs->trans("Close").'</a></div>'; |
| 2087 | 2087 | //} |
| 2088 | 2088 | } |
| 2089 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) |
|
| 2089 | + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) |
|
| 2090 | 2090 | { |
| 2091 | 2091 | if ($action == 'showclosedlines') print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>'; |
| 2092 | 2092 | else print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>'; |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 41 | 41 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 42 | 42 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 43 | -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 43 | +if (!empty($conf->propal->enabled)) { |
|
| 44 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 45 | +} |
|
| 44 | 46 | if (!empty($conf->projet->enabled)) { |
| 45 | 47 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 46 | 48 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
@@ -62,7 +64,9 @@ discard block |
||
| 62 | 64 | $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); |
| 63 | 65 | |
| 64 | 66 | // Security check |
| 65 | -if ($user->socid) $socid = $user->socid; |
|
| 67 | +if ($user->socid) { |
|
| 68 | + $socid = $user->socid; |
|
| 69 | +} |
|
| 66 | 70 | $result = restrictedArea($user, 'contrat', $id); |
| 67 | 71 | |
| 68 | 72 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
@@ -74,11 +78,13 @@ discard block |
||
| 74 | 78 | // Load object |
| 75 | 79 | if ($id > 0 || !empty($ref) && $action != 'add') { |
| 76 | 80 | $ret = $object->fetch($id, $ref); |
| 77 | - if ($ret > 0) |
|
| 78 | - $ret = $object->fetch_thirdparty(); |
|
| 79 | - if ($ret < 0) |
|
| 80 | - dol_print_error('', $object->error); |
|
| 81 | -} |
|
| 81 | + if ($ret > 0) { |
|
| 82 | + $ret = $object->fetch_thirdparty(); |
|
| 83 | + } |
|
| 84 | + if ($ret < 0) { |
|
| 85 | + dol_print_error('', $object->error); |
|
| 86 | + } |
|
| 87 | + } |
|
| 82 | 88 | |
| 83 | 89 | // fetch optionals attributes and labels |
| 84 | 90 | $extrafields->fetch_name_optionals_label($object->table_element); |
@@ -97,7 +103,9 @@ discard block |
||
| 97 | 103 | |
| 98 | 104 | $parameters = array('socid' => $socid); |
| 99 | 105 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 100 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 106 | +if ($reshook < 0) { |
|
| 107 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 108 | +} |
|
| 101 | 109 | if (empty($reshook)) |
| 102 | 110 | { |
| 103 | 111 | include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
@@ -288,8 +296,12 @@ discard block |
||
| 288 | 296 | |
| 289 | 297 | $outputlangs = $langs; |
| 290 | 298 | $newlang = ''; |
| 291 | - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 292 | - if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; |
|
| 299 | + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
|
| 300 | + $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 301 | + } |
|
| 302 | + if (empty($newlang)) { |
|
| 303 | + $newlang = $srcobject->thirdparty->default_lang; |
|
| 304 | + } |
|
| 293 | 305 | if (!empty($newlang)) |
| 294 | 306 | { |
| 295 | 307 | $outputlangs = new Translate("", $conf); |
@@ -355,8 +367,9 @@ discard block |
||
| 355 | 367 | $parameters = array('objFrom' => $srcobject); |
| 356 | 368 | $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been |
| 357 | 369 | // modified by hook |
| 358 | - if ($reshook < 0) |
|
| 359 | - $error++; |
|
| 370 | + if ($reshook < 0) { |
|
| 371 | + $error++; |
|
| 372 | + } |
|
| 360 | 373 | } else { |
| 361 | 374 | setEventMessages($object->error, $object->errors, 'errors'); |
| 362 | 375 | $error++; |
@@ -447,7 +460,9 @@ discard block |
||
| 447 | 460 | // Update if prices fields are defined |
| 448 | 461 | $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); |
| 449 | 462 | $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); |
| 450 | - if (empty($tva_tx)) $tva_npr = 0; |
|
| 463 | + if (empty($tva_tx)) { |
|
| 464 | + $tva_npr = 0; |
|
| 465 | + } |
|
| 451 | 466 | |
| 452 | 467 | $pu_ht = $prod->price; |
| 453 | 468 | $pu_ttc = $prod->price_ttc; |
@@ -476,9 +491,13 @@ discard block |
||
| 476 | 491 | $pu_ttc = price($prodcustprice->lines [0]->price_ttc); |
| 477 | 492 | $price_base_type = $prodcustprice->lines [0]->price_base_type; |
| 478 | 493 | $tva_tx = $prodcustprice->lines [0]->tva_tx; |
| 479 | - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
| 494 | + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { |
|
| 495 | + $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
| 496 | + } |
|
| 480 | 497 | $tva_npr = $prodcustprice->lines[0]->recuperableonly; |
| 481 | - if (empty($tva_tx)) $tva_npr = 0; |
|
| 498 | + if (empty($tva_tx)) { |
|
| 499 | + $tva_npr = 0; |
|
| 500 | + } |
|
| 482 | 501 | } |
| 483 | 502 | } |
| 484 | 503 | } |
@@ -499,8 +518,11 @@ discard block |
||
| 499 | 518 | } |
| 500 | 519 | |
| 501 | 520 | $desc = $prod->description; |
| 502 | - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; |
|
| 503 | - else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); |
|
| 521 | + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { |
|
| 522 | + $desc = $product_desc; |
|
| 523 | + } else { |
|
| 524 | + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); |
|
| 525 | + } |
|
| 504 | 526 | |
| 505 | 527 | $fk_unit = $prod->fk_unit; |
| 506 | 528 | } else { |
@@ -517,12 +539,16 @@ discard block |
||
| 517 | 539 | |
| 518 | 540 | // ajout prix achat |
| 519 | 541 | $fk_fournprice = $_POST['fournprice']; |
| 520 | - if (!empty($_POST['buying_price'])) |
|
| 521 | - $pa_ht = $_POST['buying_price']; |
|
| 522 | - else $pa_ht = null; |
|
| 542 | + if (!empty($_POST['buying_price'])) { |
|
| 543 | + $pa_ht = $_POST['buying_price']; |
|
| 544 | + } else { |
|
| 545 | + $pa_ht = null; |
|
| 546 | + } |
|
| 523 | 547 | |
| 524 | 548 | $info_bits = 0; |
| 525 | - if ($tva_npr) $info_bits |= 0x01; |
|
| 549 | + if ($tva_npr) { |
|
| 550 | + $info_bits |= 0x01; |
|
| 551 | + } |
|
| 526 | 552 | |
| 527 | 553 | if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) |
| 528 | 554 | || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
@@ -555,12 +581,18 @@ discard block |
||
| 555 | 581 | if ($result > 0) |
| 556 | 582 | { |
| 557 | 583 | // Define output language |
| 558 | - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) // No generation if default type not defined |
|
| 584 | + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) { |
|
| 585 | + // No generation if default type not defined |
|
| 559 | 586 | { |
| 560 | 587 | $outputlangs = $langs; |
| 588 | + } |
|
| 561 | 589 | $newlang = ''; |
| 562 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 563 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
| 590 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
|
| 591 | + $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 592 | + } |
|
| 593 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
| 594 | + $newlang = $object->thirdparty->default_lang; |
|
| 595 | + } |
|
| 564 | 596 | if (!empty($newlang)) { |
| 565 | 597 | $outputlangs = new Translate("", $conf); |
| 566 | 598 | $outputlangs->setDefaultLang($newlang); |
@@ -632,14 +664,19 @@ discard block |
||
| 632 | 664 | |
| 633 | 665 | if (!$error) |
| 634 | 666 | { |
| 635 | - if ($date_start_real_update == '') $date_start_real_update = $objectline->date_ouverture; |
|
| 636 | - if ($date_end_real_update == '') $date_end_real_update = $objectline->date_cloture; |
|
| 667 | + if ($date_start_real_update == '') { |
|
| 668 | + $date_start_real_update = $objectline->date_ouverture; |
|
| 669 | + } |
|
| 670 | + if ($date_end_real_update == '') { |
|
| 671 | + $date_end_real_update = $objectline->date_cloture; |
|
| 672 | + } |
|
| 637 | 673 | |
| 638 | 674 | $vat_rate = GETPOST('eltva_tx'); |
| 639 | 675 | // Define info_bits |
| 640 | 676 | $info_bits = 0; |
| 641 | - if (preg_match('/\*/', $vat_rate)) |
|
| 642 | - $info_bits |= 0x01; |
|
| 677 | + if (preg_match('/\*/', $vat_rate)) { |
|
| 678 | + $info_bits |= 0x01; |
|
| 679 | + } |
|
| 643 | 680 | |
| 644 | 681 | // Define vat_rate |
| 645 | 682 | $vat_rate = str_replace('*', '', $vat_rate); |
@@ -659,9 +696,11 @@ discard block |
||
| 659 | 696 | |
| 660 | 697 | // ajout prix d'achat |
| 661 | 698 | $fk_fournprice = $_POST['fournprice']; |
| 662 | - if (!empty($_POST['buying_price'])) |
|
| 663 | - $pa_ht = $_POST['buying_price']; |
|
| 664 | - else $pa_ht = null; |
|
| 699 | + if (!empty($_POST['buying_price'])) { |
|
| 700 | + $pa_ht = $_POST['buying_price']; |
|
| 701 | + } else { |
|
| 702 | + $pa_ht = null; |
|
| 703 | + } |
|
| 665 | 704 | |
| 666 | 705 | $fk_unit = GETPOST('unit', 'alpha'); |
| 667 | 706 | |
@@ -737,8 +776,12 @@ discard block |
||
| 737 | 776 | { |
| 738 | 777 | $outputlangs = $langs; |
| 739 | 778 | $newlang = ''; |
| 740 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 741 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
| 779 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
|
| 780 | + $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 781 | + } |
|
| 782 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
| 783 | + $newlang = $object->thirdparty->default_lang; |
|
| 784 | + } |
|
| 742 | 785 | if (!empty($newlang)) { |
| 743 | 786 | $outputlangs = new Translate("", $conf); |
| 744 | 787 | $outputlangs->setDefaultLang($newlang); |
@@ -812,7 +855,9 @@ discard block |
||
| 812 | 855 | |
| 813 | 856 | // Fill array 'array_options' with data from update form |
| 814 | 857 | $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); |
| 815 | - if ($ret < 0) $error++; |
|
| 858 | + if ($ret < 0) { |
|
| 859 | + $error++; |
|
| 860 | + } |
|
| 816 | 861 | |
| 817 | 862 | if (!$error) { |
| 818 | 863 | $result = $object->insertExtraFields('CONTRACT_MODIFY'); |
@@ -888,7 +933,9 @@ discard block |
||
| 888 | 933 | $files = dol_dir_list($old_filedir); |
| 889 | 934 | if (!empty($files)) |
| 890 | 935 | { |
| 891 | - if (!is_dir($new_filedir)) dol_mkdir($new_filedir); |
|
| 936 | + if (!is_dir($new_filedir)) { |
|
| 937 | + dol_mkdir($new_filedir); |
|
| 938 | + } |
|
| 892 | 939 | foreach ($files as $file) |
| 893 | 940 | { |
| 894 | 941 | dol_move($file['fullname'], $new_filedir.'/'.$file['name']); |
@@ -996,7 +1043,9 @@ discard block |
||
| 996 | 1043 | header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); |
| 997 | 1044 | exit(); |
| 998 | 1045 | } else { |
| 999 | - if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 1046 | + if (count($object->errors) > 0) { |
|
| 1047 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 1048 | + } |
|
| 1000 | 1049 | $action = ''; |
| 1001 | 1050 | } |
| 1002 | 1051 | } |
@@ -1013,7 +1062,9 @@ discard block |
||
| 1013 | 1062 | |
| 1014 | 1063 | $form = new Form($db); |
| 1015 | 1064 | $formfile = new FormFile($db); |
| 1016 | -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); |
|
| 1065 | +if (!empty($conf->projet->enabled)) { |
|
| 1066 | + $formproject = new FormProjets($db); |
|
| 1067 | +} |
|
| 1017 | 1068 | |
| 1018 | 1069 | // Load object modContract |
| 1019 | 1070 | $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); |
@@ -1033,7 +1084,9 @@ discard block |
||
| 1033 | 1084 | print load_fiche_titre($langs->trans('AddContract'), '', 'contract'); |
| 1034 | 1085 | |
| 1035 | 1086 | $soc = new Societe($db); |
| 1036 | - if ($socid > 0) $soc->fetch($socid); |
|
| 1087 | + if ($socid > 0) { |
|
| 1088 | + $soc->fetch($socid); |
|
| 1089 | + } |
|
| 1037 | 1090 | |
| 1038 | 1091 | if (GETPOST('origin') && GETPOST('originid')) |
| 1039 | 1092 | { |
@@ -1059,7 +1112,9 @@ discard block |
||
| 1059 | 1112 | $classname = ucfirst($subelement); |
| 1060 | 1113 | $objectsrc = new $classname($db); |
| 1061 | 1114 | $objectsrc->fetch($originid); |
| 1062 | - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) $objectsrc->fetch_lines(); |
|
| 1115 | + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { |
|
| 1116 | + $objectsrc->fetch_lines(); |
|
| 1117 | + } |
|
| 1063 | 1118 | $objectsrc->fetch_thirdparty(); |
| 1064 | 1119 | |
| 1065 | 1120 | // Replicate extrafields |
@@ -1134,12 +1189,18 @@ discard block |
||
| 1134 | 1189 | { |
| 1135 | 1190 | // Ligne info remises tiers |
| 1136 | 1191 | print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; |
| 1137 | - if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); |
|
| 1138 | - else print $langs->trans("CompanyHasNoRelativeDiscount"); |
|
| 1192 | + if ($soc->remise_percent) { |
|
| 1193 | + print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); |
|
| 1194 | + } else { |
|
| 1195 | + print $langs->trans("CompanyHasNoRelativeDiscount"); |
|
| 1196 | + } |
|
| 1139 | 1197 | print '. '; |
| 1140 | 1198 | $absolute_discount = $soc->getAvailableDiscounts(); |
| 1141 | - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); |
|
| 1142 | - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); |
|
| 1199 | + if ($absolute_discount) { |
|
| 1200 | + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); |
|
| 1201 | + } else { |
|
| 1202 | + print $langs->trans("CompanyHasNoAbsoluteDiscount"); |
|
| 1203 | + } |
|
| 1143 | 1204 | print '.'; |
| 1144 | 1205 | print '</td></tr>'; |
| 1145 | 1206 | } |
@@ -1329,7 +1390,9 @@ discard block |
||
| 1329 | 1390 | $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); |
| 1330 | 1391 | // Thirdparty |
| 1331 | 1392 | $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); |
| 1332 | - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)'; |
|
| 1393 | + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { |
|
| 1394 | + $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)'; |
|
| 1395 | + } |
|
| 1333 | 1396 | // Project |
| 1334 | 1397 | if (!empty($conf->projet->enabled)) |
| 1335 | 1398 | { |
@@ -1377,12 +1440,18 @@ discard block |
||
| 1377 | 1440 | |
| 1378 | 1441 | // Line info of thirdparty discounts |
| 1379 | 1442 | print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">'; |
| 1380 | - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); |
|
| 1381 | - else print $langs->trans("CompanyHasNoRelativeDiscount"); |
|
| 1443 | + if ($object->thirdparty->remise_percent) { |
|
| 1444 | + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); |
|
| 1445 | + } else { |
|
| 1446 | + print $langs->trans("CompanyHasNoRelativeDiscount"); |
|
| 1447 | + } |
|
| 1382 | 1448 | $absolute_discount = $object->thirdparty->getAvailableDiscounts(); |
| 1383 | 1449 | print '. '; |
| 1384 | - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); |
|
| 1385 | - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); |
|
| 1450 | + if ($absolute_discount) { |
|
| 1451 | + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); |
|
| 1452 | + } else { |
|
| 1453 | + print $langs->trans("CompanyHasNoAbsoluteDiscount"); |
|
| 1454 | + } |
|
| 1386 | 1455 | print '.'; |
| 1387 | 1456 | print '</td></tr>'; |
| 1388 | 1457 | |
@@ -1434,7 +1503,9 @@ discard block |
||
| 1434 | 1503 | $productstatic = new Product($db); |
| 1435 | 1504 | |
| 1436 | 1505 | $usemargins = 0; |
| 1437 | - if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) $usemargins = 1; |
|
| 1506 | + if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { |
|
| 1507 | + $usemargins = 1; |
|
| 1508 | + } |
|
| 1438 | 1509 | |
| 1439 | 1510 | $var = false; |
| 1440 | 1511 | |
@@ -1479,9 +1550,13 @@ discard block |
||
| 1479 | 1550 | // print '<td width="80" class="right">'.$langs->trans("PriceUHTCurrency").'</td>'; |
| 1480 | 1551 | //} |
| 1481 | 1552 | print '<td width="30" class="center">'.$langs->trans("Qty").'</td>'; |
| 1482 | - if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" class="left">'.$langs->trans("Unit").'</td>'; |
|
| 1553 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 1554 | + print '<td width="30" class="left">'.$langs->trans("Unit").'</td>'; |
|
| 1555 | + } |
|
| 1483 | 1556 | print '<td width="50" class="right">'.$langs->trans("ReductionShort").'</td>'; |
| 1484 | - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print '<td width="50" class="right">'.$langs->trans("BuyingPrice").'</td>'; |
|
| 1557 | + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { |
|
| 1558 | + print '<td width="50" class="right">'.$langs->trans("BuyingPrice").'</td>'; |
|
| 1559 | + } |
|
| 1485 | 1560 | print '<td width="30"> </td>'; |
| 1486 | 1561 | print "</tr>\n"; |
| 1487 | 1562 | |
@@ -1491,7 +1566,9 @@ discard block |
||
| 1491 | 1566 | if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) |
| 1492 | 1567 | { |
| 1493 | 1568 | $moreparam = ''; |
| 1494 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1569 | + if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { |
|
| 1570 | + $moreparam = 'style="display: none;"'; |
|
| 1571 | + } |
|
| 1495 | 1572 | print '<tr class="tdtop oddeven" '.$moreparam.'>'; |
| 1496 | 1573 | // Label |
| 1497 | 1574 | if ($objp->fk_product > 0) |
@@ -1540,7 +1617,9 @@ discard block |
||
| 1540 | 1617 | // Quantity |
| 1541 | 1618 | print '<td class="center">'.$objp->qty.'</td>'; |
| 1542 | 1619 | // Unit |
| 1543 | - if ($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>'; |
|
| 1620 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 1621 | + print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>'; |
|
| 1622 | + } |
|
| 1544 | 1623 | // Discount |
| 1545 | 1624 | if ($objp->remise_percent > 0) |
| 1546 | 1625 | { |
@@ -1550,7 +1629,9 @@ discard block |
||
| 1550 | 1629 | } |
| 1551 | 1630 | |
| 1552 | 1631 | // Margin |
| 1553 | - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print '<td class="right nowrap">'.price($objp->pa_ht).'</td>'; |
|
| 1632 | + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { |
|
| 1633 | + print '<td class="right nowrap">'.price($objp->pa_ht).'</td>'; |
|
| 1634 | + } |
|
| 1554 | 1635 | |
| 1555 | 1636 | // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) |
| 1556 | 1637 | print '<td class="nowrap right">'; |
@@ -1602,7 +1683,9 @@ discard block |
||
| 1602 | 1683 | $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); |
| 1603 | 1684 | print " ".img_warning($textlate); |
| 1604 | 1685 | } |
| 1605 | - } else print $langs->trans("Unknown"); |
|
| 1686 | + } else { |
|
| 1687 | + print $langs->trans("Unknown"); |
|
| 1688 | + } |
|
| 1606 | 1689 | print ' - '; |
| 1607 | 1690 | print $langs->trans("DateEndPlanned").': '; |
| 1608 | 1691 | if ($objp->date_fin) |
@@ -1613,7 +1696,9 @@ discard block |
||
| 1613 | 1696 | $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); |
| 1614 | 1697 | print " ".img_warning($textlate); |
| 1615 | 1698 | } |
| 1616 | - } else print $langs->trans("Unknown"); |
|
| 1699 | + } else { |
|
| 1700 | + print $langs->trans("Unknown"); |
|
| 1701 | + } |
|
| 1617 | 1702 | |
| 1618 | 1703 | print '</td>'; |
| 1619 | 1704 | print '</tr>'; |
@@ -1648,7 +1733,9 @@ discard block |
||
| 1648 | 1733 | // editeur wysiwyg |
| 1649 | 1734 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 1650 | 1735 | $nbrows = ROWS_2; |
| 1651 | - if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 1736 | + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
| 1737 | + $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 1738 | + } |
|
| 1652 | 1739 | $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); |
| 1653 | 1740 | $doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); |
| 1654 | 1741 | $doleditor->Create(); |
@@ -1685,7 +1772,9 @@ discard block |
||
| 1685 | 1772 | if (!empty($usemargins)) |
| 1686 | 1773 | { |
| 1687 | 1774 | print '<td class="right">'; |
| 1688 | - if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>'; |
|
| 1775 | + if ($objp->fk_product) { |
|
| 1776 | + print '<select id="fournprice" name="fournprice"></select>'; |
|
| 1777 | + } |
|
| 1689 | 1778 | print '<input id="buying_price" type="text" size="5" name="buying_price" value="'.price($objp->pa_ht, 0, '', 0).'"></td>'; |
| 1690 | 1779 | } |
| 1691 | 1780 | print '<td class="center">'; |
@@ -1695,8 +1784,12 @@ discard block |
||
| 1695 | 1784 | print '</tr>'; |
| 1696 | 1785 | |
| 1697 | 1786 | $colspan = 6; |
| 1698 | - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++; |
|
| 1699 | - if ($conf->global->PRODUCT_USE_UNITS) $colspan++; |
|
| 1787 | + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { |
|
| 1788 | + $colspan++; |
|
| 1789 | + } |
|
| 1790 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 1791 | + $colspan++; |
|
| 1792 | + } |
|
| 1700 | 1793 | |
| 1701 | 1794 | // Ligne dates prevues |
| 1702 | 1795 | print '<tr class="oddeven">'; |
@@ -1724,7 +1817,9 @@ discard block |
||
| 1724 | 1817 | if ($object->statut > 0) |
| 1725 | 1818 | { |
| 1726 | 1819 | $moreparam = ''; |
| 1727 | - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; |
|
| 1820 | + if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { |
|
| 1821 | + $moreparam = 'style="display: none;"'; |
|
| 1822 | + } |
|
| 1728 | 1823 | print '<tr class="oddeven" '.$moreparam.'>'; |
| 1729 | 1824 | print '<td class="tdhrthin" colspan="'.($conf->margin->enabled ? 7 : 6).'"><hr class="opacitymedium tdhrthin"></td>'; |
| 1730 | 1825 | print "</tr>\n"; |
@@ -1742,7 +1837,9 @@ discard block |
||
| 1742 | 1837 | if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) |
| 1743 | 1838 | { |
| 1744 | 1839 | print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1); |
| 1745 | - if ($ret == 'html') print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>'; |
|
| 1840 | + if ($ret == 'html') { |
|
| 1841 | + print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>'; |
|
| 1842 | + } |
|
| 1746 | 1843 | } |
| 1747 | 1844 | |
| 1748 | 1845 | /* |
@@ -1834,8 +1931,11 @@ discard block |
||
| 1834 | 1931 | // Si pas encore active |
| 1835 | 1932 | if (!$objp->date_debut_reelle) { |
| 1836 | 1933 | print $langs->trans("DateStartReal").': '; |
| 1837 | - if ($objp->date_debut_reelle) print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1838 | - else print $langs->trans("ContractStatusNotRunning"); |
|
| 1934 | + if ($objp->date_debut_reelle) { |
|
| 1935 | + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); |
|
| 1936 | + } else { |
|
| 1937 | + print $langs->trans("ContractStatusNotRunning"); |
|
| 1938 | + } |
|
| 1839 | 1939 | } |
| 1840 | 1940 | // Si active et en cours |
| 1841 | 1941 | if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { |
@@ -1850,7 +1950,9 @@ discard block |
||
| 1850 | 1950 | print $langs->trans("DateEndReal").': '; |
| 1851 | 1951 | print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); |
| 1852 | 1952 | } |
| 1853 | - if (!empty($objp->comment)) print " - ".$objp->comment; |
|
| 1953 | + if (!empty($objp->comment)) { |
|
| 1954 | + print " - ".$objp->comment; |
|
| 1955 | + } |
|
| 1854 | 1956 | print '</td>'; |
| 1855 | 1957 | |
| 1856 | 1958 | print '<td class="center"> </td>'; |
@@ -1869,12 +1971,16 @@ discard block |
||
| 1869 | 1971 | |
| 1870 | 1972 | // Definie date debut et fin par defaut |
| 1871 | 1973 | $dateactstart = $objp->date_debut; |
| 1872 | - if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); |
|
| 1873 | - elseif (!$dateactstart) $dateactstart = time(); |
|
| 1974 | + if (GETPOST('remonth')) { |
|
| 1975 | + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); |
|
| 1976 | + } elseif (!$dateactstart) { |
|
| 1977 | + $dateactstart = time(); |
|
| 1978 | + } |
|
| 1874 | 1979 | |
| 1875 | 1980 | $dateactend = $objp->date_fin; |
| 1876 | - if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); |
|
| 1877 | - elseif (!$dateactend) |
|
| 1981 | + if (GETPOST('endmonth')) { |
|
| 1982 | + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); |
|
| 1983 | + } elseif (!$dateactend) |
|
| 1878 | 1984 | { |
| 1879 | 1985 | if ($objp->fk_product > 0) |
| 1880 | 1986 | { |
@@ -1924,12 +2030,16 @@ discard block |
||
| 1924 | 2030 | |
| 1925 | 2031 | // Definie date debut et fin par defaut |
| 1926 | 2032 | $dateactstart = $objp->date_debut_reelle; |
| 1927 | - if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); |
|
| 1928 | - elseif (!$dateactstart) $dateactstart = time(); |
|
| 2033 | + if (GETPOST('remonth')) { |
|
| 2034 | + $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); |
|
| 2035 | + } elseif (!$dateactstart) { |
|
| 2036 | + $dateactstart = time(); |
|
| 2037 | + } |
|
| 1929 | 2038 | |
| 1930 | 2039 | $dateactend = $objp->date_fin_reelle; |
| 1931 | - if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); |
|
| 1932 | - elseif (!$dateactend) |
|
| 2040 | + if (GETPOST('endmonth')) { |
|
| 2041 | + $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); |
|
| 2042 | + } elseif (!$dateactend) |
|
| 1933 | 2043 | { |
| 1934 | 2044 | if ($objp->fk_product > 0) |
| 1935 | 2045 | { |
@@ -1939,7 +2049,9 @@ discard block |
||
| 1939 | 2049 | } |
| 1940 | 2050 | } |
| 1941 | 2051 | $now = dol_now(); |
| 1942 | - if ($dateactend > $now) $dateactend = $now; |
|
| 2052 | + if ($dateactend > $now) { |
|
| 2053 | + $dateactend = $now; |
|
| 2054 | + } |
|
| 1943 | 2055 | |
| 1944 | 2056 | print '<tr class="oddeven"><td colspan="2" class="nohover">'; |
| 1945 | 2057 | if ($objp->statut >= 4) |
@@ -1991,7 +2103,10 @@ discard block |
||
| 1991 | 2103 | if ($action != 'editline') |
| 1992 | 2104 | { |
| 1993 | 2105 | $forcetoshowtitlelines = 1; |
| 1994 | - if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts |
|
| 2106 | + if (empty($object->multicurrency_code)) { |
|
| 2107 | + $object->multicurrency_code = $conf->currency; |
|
| 2108 | + } |
|
| 2109 | + // TODO Remove this when multicurrency supported on contracts |
|
| 1995 | 2110 | |
| 1996 | 2111 | // Add free products/services |
| 1997 | 2112 | $object->formAddObjectLine(1, $mysoc, $soc); |
@@ -2026,33 +2141,47 @@ discard block |
||
| 2026 | 2141 | if ($object->statut == 1) { |
| 2027 | 2142 | if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { |
| 2028 | 2143 | print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; |
| 2029 | - } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; |
|
| 2144 | + } else { |
|
| 2145 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; |
|
| 2146 | + } |
|
| 2030 | 2147 | } |
| 2031 | 2148 | } |
| 2032 | 2149 | |
| 2033 | 2150 | if ($object->statut == 0 && $nbofservices) |
| 2034 | 2151 | { |
| 2035 | - if ($user->rights->contrat->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a></div>'; |
|
| 2036 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a></div>'; |
|
| 2152 | + if ($user->rights->contrat->creer) { |
|
| 2153 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a></div>'; |
|
| 2154 | + } else { |
|
| 2155 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a></div>'; |
|
| 2156 | + } |
|
| 2037 | 2157 | } |
| 2038 | 2158 | if ($object->statut == 1) |
| 2039 | 2159 | { |
| 2040 | - if ($user->rights->contrat->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Modify").'</a></div>'; |
|
| 2041 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>'; |
|
| 2160 | + if ($user->rights->contrat->creer) { |
|
| 2161 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Modify").'</a></div>'; |
|
| 2162 | + } else { |
|
| 2163 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>'; |
|
| 2164 | + } |
|
| 2042 | 2165 | } |
| 2043 | 2166 | |
| 2044 | 2167 | if (!empty($conf->facture->enabled) && $object->statut > 0) |
| 2045 | 2168 | { |
| 2046 | 2169 | $langs->load("bills"); |
| 2047 | - if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateBill").'</a></div>'; |
|
| 2048 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>'; |
|
| 2170 | + if ($user->rights->facture->creer) { |
|
| 2171 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateBill").'</a></div>'; |
|
| 2172 | + } else { |
|
| 2173 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>'; |
|
| 2174 | + } |
|
| 2049 | 2175 | } |
| 2050 | 2176 | |
| 2051 | 2177 | if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) |
| 2052 | 2178 | { |
| 2053 | 2179 | $langs->load("orders"); |
| 2054 | - if ($user->rights->commande->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>'; |
|
| 2055 | - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>'; |
|
| 2180 | + if ($user->rights->commande->creer) { |
|
| 2181 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>'; |
|
| 2182 | + } else { |
|
| 2183 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>'; |
|
| 2184 | + } |
|
| 2056 | 2185 | } |
| 2057 | 2186 | |
| 2058 | 2187 | // Clone |
@@ -2088,8 +2217,11 @@ discard block |
||
| 2088 | 2217 | } |
| 2089 | 2218 | if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) |
| 2090 | 2219 | { |
| 2091 | - if ($action == 'showclosedlines') print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>'; |
|
| 2092 | - else print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>'; |
|
| 2220 | + if ($action == 'showclosedlines') { |
|
| 2221 | + print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>'; |
|
| 2222 | + } else { |
|
| 2223 | + print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>'; |
|
| 2224 | + } |
|
| 2093 | 2225 | } |
| 2094 | 2226 | // On peut supprimer entite si |
| 2095 | 2227 | // - Droit de creer + mode brouillon (erreur creation) |
@@ -201,8 +201,7 @@ discard block |
||
| 201 | 201 | if ($result <= 0) { |
| 202 | 202 | throw new RestException(500, 'Error generating document'); |
| 203 | 203 | } |
| 204 | - } |
|
| 205 | - elseif ($modulepart == 'commande' || $modulepart == 'order') |
|
| 204 | + } elseif ($modulepart == 'commande' || $modulepart == 'order') |
|
| 206 | 205 | { |
| 207 | 206 | require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 208 | 207 | $this->order = new Commande($this->db); |
@@ -215,8 +214,7 @@ discard block |
||
| 215 | 214 | if ($result <= 0) { |
| 216 | 215 | throw new RestException(500, 'Error generating document'); |
| 217 | 216 | } |
| 218 | - } |
|
| 219 | - elseif ($modulepart == 'propal' || $modulepart == 'proposal') |
|
| 217 | + } elseif ($modulepart == 'propal' || $modulepart == 'proposal') |
|
| 220 | 218 | { |
| 221 | 219 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 222 | 220 | $this->propal = new Propal($this->db); |
@@ -229,8 +227,7 @@ discard block |
||
| 229 | 227 | if ($result <= 0) { |
| 230 | 228 | throw new RestException(500, 'Error generating document'); |
| 231 | 229 | } |
| 232 | - } |
|
| 233 | - else |
|
| 230 | + } else |
|
| 234 | 231 | { |
| 235 | 232 | throw new RestException(403, 'Generation not available for this modulepart'); |
| 236 | 233 | } |
@@ -293,8 +290,7 @@ discard block |
||
| 293 | 290 | } |
| 294 | 291 | |
| 295 | 292 | $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; |
| 296 | - } |
|
| 297 | - elseif ($modulepart == 'user') |
|
| 293 | + } elseif ($modulepart == 'user') |
|
| 298 | 294 | { |
| 299 | 295 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
| 300 | 296 | |
@@ -310,8 +306,7 @@ discard block |
||
| 310 | 306 | } |
| 311 | 307 | |
| 312 | 308 | $upload_dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id; |
| 313 | - } |
|
| 314 | - elseif ($modulepart == 'adherent' || $modulepart == 'member') |
|
| 309 | + } elseif ($modulepart == 'adherent' || $modulepart == 'member') |
|
| 315 | 310 | { |
| 316 | 311 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
| 317 | 312 | |
@@ -326,8 +321,7 @@ discard block |
||
| 326 | 321 | } |
| 327 | 322 | |
| 328 | 323 | $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member'); |
| 329 | - } |
|
| 330 | - elseif ($modulepart == 'propal' || $modulepart == 'proposal') |
|
| 324 | + } elseif ($modulepart == 'propal' || $modulepart == 'proposal') |
|
| 331 | 325 | { |
| 332 | 326 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 333 | 327 | |
@@ -342,8 +336,7 @@ discard block |
||
| 342 | 336 | } |
| 343 | 337 | |
| 344 | 338 | $upload_dir = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); |
| 345 | - } |
|
| 346 | - elseif ($modulepart == 'commande' || $modulepart == 'order') |
|
| 339 | + } elseif ($modulepart == 'commande' || $modulepart == 'order') |
|
| 347 | 340 | { |
| 348 | 341 | require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 349 | 342 | |
@@ -358,8 +351,7 @@ discard block |
||
| 358 | 351 | } |
| 359 | 352 | |
| 360 | 353 | $upload_dir = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); |
| 361 | - } |
|
| 362 | - elseif ($modulepart == 'shipment' || $modulepart == 'expedition') |
|
| 354 | + } elseif ($modulepart == 'shipment' || $modulepart == 'expedition') |
|
| 363 | 355 | { |
| 364 | 356 | require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; |
| 365 | 357 | |
@@ -374,8 +366,7 @@ discard block |
||
| 374 | 366 | } |
| 375 | 367 | |
| 376 | 368 | $upload_dir = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment'); |
| 377 | - } |
|
| 378 | - elseif ($modulepart == 'facture' || $modulepart == 'invoice') |
|
| 369 | + } elseif ($modulepart == 'facture' || $modulepart == 'invoice') |
|
| 379 | 370 | { |
| 380 | 371 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 381 | 372 | |
@@ -390,8 +381,7 @@ discard block |
||
| 390 | 381 | } |
| 391 | 382 | |
| 392 | 383 | $upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); |
| 393 | - } |
|
| 394 | - elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') |
|
| 384 | + } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') |
|
| 395 | 385 | { |
| 396 | 386 | $modulepart = 'supplier_invoice'; |
| 397 | 387 | |
@@ -408,8 +398,7 @@ discard block |
||
| 408 | 398 | } |
| 409 | 399 | |
| 410 | 400 | $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); |
| 411 | - } |
|
| 412 | - elseif ($modulepart == 'produit' || $modulepart == 'product') |
|
| 401 | + } elseif ($modulepart == 'produit' || $modulepart == 'product') |
|
| 413 | 402 | { |
| 414 | 403 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 415 | 404 | |
@@ -424,8 +413,7 @@ discard block |
||
| 424 | 413 | } |
| 425 | 414 | |
| 426 | 415 | $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
| 427 | - } |
|
| 428 | - elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') |
|
| 416 | + } elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') |
|
| 429 | 417 | { |
| 430 | 418 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 431 | 419 | |
@@ -440,8 +428,7 @@ discard block |
||
| 440 | 428 | } |
| 441 | 429 | |
| 442 | 430 | $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); |
| 443 | - } |
|
| 444 | - elseif ($modulepart == 'expensereport') |
|
| 431 | + } elseif ($modulepart == 'expensereport') |
|
| 445 | 432 | { |
| 446 | 433 | require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
| 447 | 434 | |
@@ -456,8 +443,7 @@ discard block |
||
| 456 | 443 | } |
| 457 | 444 | |
| 458 | 445 | $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); |
| 459 | - } |
|
| 460 | - elseif ($modulepart == 'categorie' || $modulepart == 'category') |
|
| 446 | + } elseif ($modulepart == 'categorie' || $modulepart == 'category') |
|
| 461 | 447 | { |
| 462 | 448 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 463 | 449 | |
@@ -472,8 +458,7 @@ discard block |
||
| 472 | 458 | } |
| 473 | 459 | |
| 474 | 460 | $upload_dir = $conf->categorie->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/".dol_sanitizeFileName($object->ref); |
| 475 | - } |
|
| 476 | - else |
|
| 461 | + } else |
|
| 477 | 462 | { |
| 478 | 463 | throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); |
| 479 | 464 | } |
@@ -543,8 +528,12 @@ discard block |
||
| 543 | 528 | } |
| 544 | 529 | |
| 545 | 530 | $newfilecontent = ''; |
| 546 | - if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
| 547 | - if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
| 531 | + if (empty($fileencoding)) { |
|
| 532 | + $newfilecontent = $filecontent; |
|
| 533 | + } |
|
| 534 | + if ($fileencoding == 'base64') { |
|
| 535 | + $newfilecontent = base64_decode($filecontent); |
|
| 536 | + } |
|
| 548 | 537 | |
| 549 | 538 | $original_file = dol_sanitizeFileName($filename); |
| 550 | 539 | |
@@ -561,20 +550,17 @@ discard block |
||
| 561 | 550 | |
| 562 | 551 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 563 | 552 | $object = new Facture($this->db); |
| 564 | - } |
|
| 565 | - elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') |
|
| 553 | + } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') |
|
| 566 | 554 | { |
| 567 | 555 | $modulepart = 'supplier_invoice'; |
| 568 | 556 | |
| 569 | 557 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
| 570 | 558 | $object = new FactureFournisseur($this->db); |
| 571 | - } |
|
| 572 | - elseif ($modulepart == 'project') |
|
| 559 | + } elseif ($modulepart == 'project') |
|
| 573 | 560 | { |
| 574 | 561 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 575 | 562 | $object = new Project($this->db); |
| 576 | - } |
|
| 577 | - elseif ($modulepart == 'task' || $modulepart == 'project_task') |
|
| 563 | + } elseif ($modulepart == 'task' || $modulepart == 'project_task') |
|
| 578 | 564 | { |
| 579 | 565 | $modulepart = 'project_task'; |
| 580 | 566 | |
@@ -592,23 +578,19 @@ discard block |
||
| 592 | 578 | { |
| 593 | 579 | $tmpreldir = dol_sanitizeFileName($object->project->ref).'/'; |
| 594 | 580 | } |
| 595 | - } |
|
| 596 | - else |
|
| 581 | + } else |
|
| 597 | 582 | { |
| 598 | 583 | throw new RestException(500, 'Error while fetching Task '.$ref); |
| 599 | 584 | } |
| 600 | - } |
|
| 601 | - elseif ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') |
|
| 585 | + } elseif ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') |
|
| 602 | 586 | { |
| 603 | 587 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 604 | 588 | $object = new Product($this->db); |
| 605 | - } |
|
| 606 | - elseif ($modulepart == 'expensereport') |
|
| 589 | + } elseif ($modulepart == 'expensereport') |
|
| 607 | 590 | { |
| 608 | 591 | require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
| 609 | 592 | $object = new ExpenseReport($this->db); |
| 610 | - } |
|
| 611 | - elseif ($modulepart == 'adherent' || $modulepart == 'member') |
|
| 593 | + } elseif ($modulepart == 'adherent' || $modulepart == 'member') |
|
| 612 | 594 | { |
| 613 | 595 | $modulepart = 'adherent'; |
| 614 | 596 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
@@ -627,8 +609,7 @@ discard block |
||
| 627 | 609 | if ($result == 0) |
| 628 | 610 | { |
| 629 | 611 | throw new RestException(404, "Object with ref '".$ref."' was not found."); |
| 630 | - } |
|
| 631 | - elseif ($result < 0) |
|
| 612 | + } elseif ($result < 0) |
|
| 632 | 613 | { |
| 633 | 614 | throw new RestException(500, 'Error while fetching object.'); |
| 634 | 615 | } |
@@ -654,11 +635,14 @@ discard block |
||
| 654 | 635 | { |
| 655 | 636 | throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
| 656 | 637 | } |
| 657 | - } |
|
| 658 | - else |
|
| 638 | + } else |
|
| 659 | 639 | { |
| 660 | - if ($modulepart == 'invoice') $modulepart = 'facture'; |
|
| 661 | - if ($modulepart == 'member') $modulepart = 'adherent'; |
|
| 640 | + if ($modulepart == 'invoice') { |
|
| 641 | + $modulepart = 'facture'; |
|
| 642 | + } |
|
| 643 | + if ($modulepart == 'member') { |
|
| 644 | + $modulepart = 'adherent'; |
|
| 645 | + } |
|
| 662 | 646 | |
| 663 | 647 | $relativefile = $subdir; |
| 664 | 648 | |
@@ -674,10 +658,12 @@ discard block |
||
| 674 | 658 | |
| 675 | 659 | $upload_dir = dol_sanitizePathName($upload_dir); |
| 676 | 660 | |
| 677 | - if (dol_mkdir($upload_dir) < 0) // needed by products |
|
| 661 | + if (dol_mkdir($upload_dir) < 0) { |
|
| 662 | + // needed by products |
|
| 678 | 663 | { |
| 679 | 664 | throw new RestException(500, 'Error while trying to create directory.'); |
| 680 | 665 | } |
| 666 | + } |
|
| 681 | 667 | |
| 682 | 668 | $destfile = $upload_dir.'/'.$original_file; |
| 683 | 669 | $destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file; |
@@ -699,8 +685,7 @@ discard block |
||
| 699 | 685 | $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
| 700 | 686 | fclose($fhandle); |
| 701 | 687 | @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
| 702 | - } |
|
| 703 | - else |
|
| 688 | + } else |
|
| 704 | 689 | { |
| 705 | 690 | throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
| 706 | 691 | } |
@@ -798,8 +783,9 @@ discard block |
||
| 798 | 783 | // phpcs:enable |
| 799 | 784 | $result = array(); |
| 800 | 785 | foreach (Documents::$DOCUMENT_FIELDS as $field) { |
| 801 | - if (!isset($data[$field])) |
|
| 802 | - throw new RestException(400, "$field field missing"); |
|
| 786 | + if (!isset($data[$field])) { |
|
| 787 | + throw new RestException(400, "$field field missing"); |
|
| 788 | + } |
|
| 803 | 789 | $result[$field] = $data[$field]; |
| 804 | 790 | } |
| 805 | 791 | return $result; |
@@ -24,9 +24,16 @@ |
||
| 24 | 24 | * \brief File to calculate loan monthly payments |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
| 28 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
| 29 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 27 | +if (!defined('NOTOKENRENEWAL')) { |
|
| 28 | + define('NOTOKENRENEWAL', '1'); |
|
| 29 | +} |
|
| 30 | +// Disables token renewal |
|
| 31 | +if (!defined('NOREQUIREMENU')) { |
|
| 32 | + define('NOREQUIREMENU', '1'); |
|
| 33 | +} |
|
| 34 | +if (!defined('NOREQUIREAJAX')) { |
|
| 35 | + define('NOREQUIREAJAX', '1'); |
|
| 36 | +} |
|
| 30 | 37 | |
| 31 | 38 | require '../main.inc.php'; |
| 32 | 39 | require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; |
@@ -55,69 +55,69 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | |
| 57 | 57 | if ($action == 'createecheancier' && empty($pay_without_schedule)) { |
| 58 | - $db->begin(); |
|
| 59 | - $i = 1; |
|
| 60 | - while ($i < $object->nbterm + 1) { |
|
| 61 | - $date = GETPOST('hi_date'.$i, 'int'); |
|
| 62 | - $mens = price2num(GETPOST('mens'.$i)); |
|
| 63 | - $int = price2num(GETPOST('hi_interets'.$i)); |
|
| 64 | - $insurance = price2num(GETPOST('hi_insurance'.$i)); |
|
| 65 | - |
|
| 66 | - $new_echeance = new LoanSchedule($db); |
|
| 67 | - |
|
| 68 | - $new_echeance->fk_loan = $object->id; |
|
| 69 | - $new_echeance->datec = dol_now(); |
|
| 70 | - $new_echeance->tms = dol_now(); |
|
| 71 | - $new_echeance->datep = $date; |
|
| 72 | - $new_echeance->amount_capital = $mens - $int; |
|
| 73 | - $new_echeance->amount_insurance = $insurance; |
|
| 74 | - $new_echeance->amount_interest = $int; |
|
| 75 | - $new_echeance->fk_typepayment = 3; |
|
| 76 | - $new_echeance->fk_bank = 0; |
|
| 77 | - $new_echeance->fk_user_creat = $user->id; |
|
| 78 | - $new_echeance->fk_user_modif = $user->id; |
|
| 79 | - $result = $new_echeance->create($user); |
|
| 80 | - if ($result < 0) { |
|
| 81 | - setEventMessages($new_echeance->error, $echeance->errors, 'errors'); |
|
| 82 | - $db->rollback(); |
|
| 83 | - unset($echeances->lines); |
|
| 84 | - break; |
|
| 85 | - } |
|
| 86 | - $echeances->lines[] = $new_echeance; |
|
| 87 | - $i++; |
|
| 88 | - } |
|
| 89 | - var_dump($result); |
|
| 90 | - if ($result > 0) $db->commit(); |
|
| 58 | + $db->begin(); |
|
| 59 | + $i = 1; |
|
| 60 | + while ($i < $object->nbterm + 1) { |
|
| 61 | + $date = GETPOST('hi_date'.$i, 'int'); |
|
| 62 | + $mens = price2num(GETPOST('mens'.$i)); |
|
| 63 | + $int = price2num(GETPOST('hi_interets'.$i)); |
|
| 64 | + $insurance = price2num(GETPOST('hi_insurance'.$i)); |
|
| 65 | + |
|
| 66 | + $new_echeance = new LoanSchedule($db); |
|
| 67 | + |
|
| 68 | + $new_echeance->fk_loan = $object->id; |
|
| 69 | + $new_echeance->datec = dol_now(); |
|
| 70 | + $new_echeance->tms = dol_now(); |
|
| 71 | + $new_echeance->datep = $date; |
|
| 72 | + $new_echeance->amount_capital = $mens - $int; |
|
| 73 | + $new_echeance->amount_insurance = $insurance; |
|
| 74 | + $new_echeance->amount_interest = $int; |
|
| 75 | + $new_echeance->fk_typepayment = 3; |
|
| 76 | + $new_echeance->fk_bank = 0; |
|
| 77 | + $new_echeance->fk_user_creat = $user->id; |
|
| 78 | + $new_echeance->fk_user_modif = $user->id; |
|
| 79 | + $result = $new_echeance->create($user); |
|
| 80 | + if ($result < 0) { |
|
| 81 | + setEventMessages($new_echeance->error, $echeance->errors, 'errors'); |
|
| 82 | + $db->rollback(); |
|
| 83 | + unset($echeances->lines); |
|
| 84 | + break; |
|
| 85 | + } |
|
| 86 | + $echeances->lines[] = $new_echeance; |
|
| 87 | + $i++; |
|
| 88 | + } |
|
| 89 | + var_dump($result); |
|
| 90 | + if ($result > 0) $db->commit(); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ($action == 'updateecheancier' && empty($pay_without_schedule)) { |
| 94 | - $db->begin(); |
|
| 95 | - $i = 1; |
|
| 96 | - while ($i < $object->nbterm + 1) { |
|
| 97 | - $mens = price2num(GETPOST('mens'.$i)); |
|
| 98 | - $int = price2num(GETPOST('hi_interets'.$i)); |
|
| 99 | - $id = GETPOST('hi_rowid'.$i); |
|
| 100 | - $insurance = price2num(GETPOST('hi_insurance'.$i)); |
|
| 101 | - |
|
| 102 | - $new_echeance = new LoanSchedule($db); |
|
| 103 | - $new_echeance->fetch($id); |
|
| 104 | - $new_echeance->tms = dol_now(); |
|
| 105 | - $new_echeance->amount_capital = $mens - $int; |
|
| 106 | - $new_echeance->amount_insurance = $insurance; |
|
| 107 | - $new_echeance->amount_interest = $int; |
|
| 108 | - $new_echeance->fk_user_modif = $user->id; |
|
| 109 | - $result = $new_echeance->update($user, 0); |
|
| 110 | - if ($result < 0) { |
|
| 111 | - setEventMessages(null, $new_echeance->errors, 'errors'); |
|
| 112 | - $db->rollback(); |
|
| 113 | - $echeances->fetchAll($object->id); |
|
| 114 | - break; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - $echeances->lines[$i-1] = $new_echeance; |
|
| 118 | - $i++; |
|
| 119 | - } |
|
| 120 | - if ($result > 0) $db->commit(); |
|
| 94 | + $db->begin(); |
|
| 95 | + $i = 1; |
|
| 96 | + while ($i < $object->nbterm + 1) { |
|
| 97 | + $mens = price2num(GETPOST('mens'.$i)); |
|
| 98 | + $int = price2num(GETPOST('hi_interets'.$i)); |
|
| 99 | + $id = GETPOST('hi_rowid'.$i); |
|
| 100 | + $insurance = price2num(GETPOST('hi_insurance'.$i)); |
|
| 101 | + |
|
| 102 | + $new_echeance = new LoanSchedule($db); |
|
| 103 | + $new_echeance->fetch($id); |
|
| 104 | + $new_echeance->tms = dol_now(); |
|
| 105 | + $new_echeance->amount_capital = $mens - $int; |
|
| 106 | + $new_echeance->amount_insurance = $insurance; |
|
| 107 | + $new_echeance->amount_interest = $int; |
|
| 108 | + $new_echeance->fk_user_modif = $user->id; |
|
| 109 | + $result = $new_echeance->update($user, 0); |
|
| 110 | + if ($result < 0) { |
|
| 111 | + setEventMessages(null, $new_echeance->errors, 'errors'); |
|
| 112 | + $db->rollback(); |
|
| 113 | + $echeances->fetchAll($object->id); |
|
| 114 | + break; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + $echeances->lines[$i-1] = $new_echeance; |
|
| 118 | + $i++; |
|
| 119 | + } |
|
| 120 | + if ($result > 0) $db->commit(); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /* |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | <?php |
| 211 | 211 | |
| 212 | 212 | if ($pay_without_schedule == 1) |
| 213 | - print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n"; |
|
| 213 | + print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n"; |
|
| 214 | 214 | |
| 215 | 215 | print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
| 216 | 216 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | print '<td class="center" id="capital'.$i.'">'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">'; |
| 299 | 299 | print '<td class="center">'; |
| 300 | 300 | if (!empty($line->fk_bank)) |
| 301 | - { |
|
| 302 | - print $langs->trans('Paid'); |
|
| 303 | - if (!empty($line->fk_payment_loan)) |
|
| 304 | - print ' <a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>'; |
|
| 305 | - } |
|
| 301 | + { |
|
| 302 | + print $langs->trans('Paid'); |
|
| 303 | + if (!empty($line->fk_payment_loan)) |
|
| 304 | + print ' <a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>'; |
|
| 305 | + } |
|
| 306 | 306 | elseif (!$printed) |
| 307 | 307 | { |
| 308 | - print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a>'; |
|
| 309 | - $printed = true; |
|
| 308 | + print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a>'; |
|
| 309 | + $printed = true; |
|
| 310 | 310 | } |
| 311 | 311 | print '</td>'; |
| 312 | 312 | print '</tr>'."\n"; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // Security check |
| 37 | 37 | $socid = 0; |
| 38 | 38 | if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); |
| 39 | -if ($user->socid) $socid=$user->socid; |
|
| 39 | +if ($user->socid) $socid = $user->socid; |
|
| 40 | 40 | if (empty($user->rights->loan->calc)) accessforbidden(); |
| 41 | 41 | |
| 42 | 42 | // Load translation files required by the page |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $echeances->lines[$i-1] = $new_echeance; |
|
| 117 | + $echeances->lines[$i - 1] = $new_echeance; |
|
| 118 | 118 | $i++; |
| 119 | 119 | } |
| 120 | 120 | if ($result > 0) $db->commit(); |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | if (count($echeances->lines) == 0) $label = $langs->trans("Create"); |
| 324 | 324 | else $label = $langs->trans("Save"); |
| 325 | -print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1)?'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"':'').'title=""></div>'; |
|
| 325 | +print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1) ? 'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"' : '').'title=""></div>'; |
|
| 326 | 326 | print '</form>'; |
| 327 | 327 | |
| 328 | 328 | // End of page |
@@ -35,9 +35,15 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // Security check |
| 37 | 37 | $socid = 0; |
| 38 | -if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); |
|
| 39 | -if ($user->socid) $socid=$user->socid; |
|
| 40 | -if (empty($user->rights->loan->calc)) accessforbidden(); |
|
| 38 | +if (GETPOSTISSET('socid')) { |
|
| 39 | + $socid = GETPOST('socid', 'int'); |
|
| 40 | +} |
|
| 41 | +if ($user->socid) { |
|
| 42 | + $socid=$user->socid; |
|
| 43 | +} |
|
| 44 | +if (empty($user->rights->loan->calc)) { |
|
| 45 | + accessforbidden(); |
|
| 46 | +} |
|
| 41 | 47 | |
| 42 | 48 | // Load translation files required by the page |
| 43 | 49 | $langs->loadLangs(array("compta", "bills", "loan")); |
@@ -48,7 +54,9 @@ discard block |
||
| 48 | 54 | $echeances = new LoanSchedule($db); |
| 49 | 55 | $echeances->fetchAll($object->id); |
| 50 | 56 | |
| 51 | -if ($object->paid > 0 && count($echeances->lines) == 0) $pay_without_schedule = 1; |
|
| 57 | +if ($object->paid > 0 && count($echeances->lines) == 0) { |
|
| 58 | + $pay_without_schedule = 1; |
|
| 59 | +} |
|
| 52 | 60 | |
| 53 | 61 | /* |
| 54 | 62 | * Actions |
@@ -87,8 +95,10 @@ discard block |
||
| 87 | 95 | $i++; |
| 88 | 96 | } |
| 89 | 97 | var_dump($result); |
| 90 | - if ($result > 0) $db->commit(); |
|
| 91 | -} |
|
| 98 | + if ($result > 0) { |
|
| 99 | + $db->commit(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 92 | 102 | |
| 93 | 103 | if ($action == 'updateecheancier' && empty($pay_without_schedule)) { |
| 94 | 104 | $db->begin(); |
@@ -117,8 +127,10 @@ discard block |
||
| 117 | 127 | $echeances->lines[$i-1] = $new_echeance; |
| 118 | 128 | $i++; |
| 119 | 129 | } |
| 120 | - if ($result > 0) $db->commit(); |
|
| 121 | -} |
|
| 130 | + if ($result > 0) { |
|
| 131 | + $db->commit(); |
|
| 132 | + } |
|
| 133 | + } |
|
| 122 | 134 | |
| 123 | 135 | /* |
| 124 | 136 | * View |
@@ -144,11 +156,12 @@ discard block |
||
| 144 | 156 | $morehtmlref .= '<br>'.$langs->trans('Project').' : '; |
| 145 | 157 | if ($user->rights->loan->write) |
| 146 | 158 | { |
| 147 | - if ($action != 'classify') |
|
| 148 | - //$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; |
|
| 159 | + if ($action != 'classify') { |
|
| 160 | + //$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; |
|
| 149 | 161 | if ($action == 'classify') { |
| 150 | 162 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 151 | 163 | $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
| 164 | + } |
|
| 152 | 165 | $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
| 153 | 166 | $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; |
| 154 | 167 | $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
@@ -209,8 +222,9 @@ discard block |
||
| 209 | 222 | </script> |
| 210 | 223 | <?php |
| 211 | 224 | |
| 212 | -if ($pay_without_schedule == 1) |
|
| 225 | +if ($pay_without_schedule == 1) { |
|
| 213 | 226 | print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n"; |
| 227 | +} |
|
| 214 | 228 | |
| 215 | 229 | print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
| 216 | 230 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
@@ -226,7 +240,9 @@ discard block |
||
| 226 | 240 | print '<table class="border centpercent">'; |
| 227 | 241 | print '<tr class="liste_titre">'; |
| 228 | 242 | $colspan = 6; |
| 229 | -if (count($echeances->lines) > 0) $colspan++; |
|
| 243 | +if (count($echeances->lines) > 0) { |
|
| 244 | + $colspan++; |
|
| 245 | +} |
|
| 230 | 246 | print '<th class="center" colspan="'.$colspan.'">'; |
| 231 | 247 | print $langs->trans("FinancialCommitment"); |
| 232 | 248 | print '</th>'; |
@@ -242,7 +258,9 @@ discard block |
||
| 242 | 258 | print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; |
| 243 | 259 | print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; |
| 244 | 260 | print '</th>'; |
| 245 | -if (count($echeances->lines) > 0) print '<th class="center">'.$langs->trans('DoPayment').'</th>'; |
|
| 261 | +if (count($echeances->lines) > 0) { |
|
| 262 | + print '<th class="center">'.$langs->trans('DoPayment').'</th>'; |
|
| 263 | +} |
|
| 246 | 264 | print '</tr>'."\n"; |
| 247 | 265 | |
| 248 | 266 | if ($object->nbterm > 0 && count($echeances->lines) == 0) |
@@ -300,10 +318,10 @@ discard block |
||
| 300 | 318 | if (!empty($line->fk_bank)) |
| 301 | 319 | { |
| 302 | 320 | print $langs->trans('Paid'); |
| 303 | - if (!empty($line->fk_payment_loan)) |
|
| 304 | - print ' <a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>'; |
|
| 305 | - } |
|
| 306 | - elseif (!$printed) |
|
| 321 | + if (!empty($line->fk_payment_loan)) { |
|
| 322 | + print ' <a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>'; |
|
| 323 | + } |
|
| 324 | + } elseif (!$printed) |
|
| 307 | 325 | { |
| 308 | 326 | print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a>'; |
| 309 | 327 | $printed = true; |
@@ -320,8 +338,11 @@ discard block |
||
| 320 | 338 | |
| 321 | 339 | print '</br>'; |
| 322 | 340 | |
| 323 | -if (count($echeances->lines) == 0) $label = $langs->trans("Create"); |
|
| 324 | -else $label = $langs->trans("Save"); |
|
| 341 | +if (count($echeances->lines) == 0) { |
|
| 342 | + $label = $langs->trans("Create"); |
|
| 343 | +} else { |
|
| 344 | + $label = $langs->trans("Save"); |
|
| 345 | +} |
|
| 325 | 346 | print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1)?'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"':'').'title=""></div>'; |
| 326 | 347 | print '</form>'; |
| 327 | 348 | |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | public $datestart; |
| 55 | 55 | public $dateend; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var string Loan label |
|
| 59 | - */ |
|
| 60 | - public $label; |
|
| 57 | + /** |
|
| 58 | + * @var string Loan label |
|
| 59 | + */ |
|
| 60 | + public $label; |
|
| 61 | 61 | |
| 62 | 62 | public $capital; |
| 63 | 63 | public $nbterm; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | public $account_interest; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @var integer|string date_creation |
|
| 72 | - */ |
|
| 71 | + * @var integer|string date_creation |
|
| 72 | + */ |
|
| 73 | 73 | public $date_creation; |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -85,29 +85,29 @@ discard block |
||
| 85 | 85 | public $insurance_amount; |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * @var int Bank ID |
|
| 89 | - */ |
|
| 88 | + * @var int Bank ID |
|
| 89 | + */ |
|
| 90 | 90 | public $fk_bank; |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * @var int ID |
|
| 94 | - */ |
|
| 93 | + * @var int ID |
|
| 94 | + */ |
|
| 95 | 95 | public $fk_user_creat; |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * @var int ID |
|
| 99 | - */ |
|
| 98 | + * @var int ID |
|
| 99 | + */ |
|
| 100 | 100 | public $fk_user_modif; |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | - * @var int ID |
|
| 104 | - */ |
|
| 103 | + * @var int ID |
|
| 104 | + */ |
|
| 105 | 105 | public $fk_project; |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | const STATUS_UNPAID = 0; |
| 109 | 109 | const STATUS_PAID = 1; |
| 110 | - const STATUS_STARTED = 2; |
|
| 110 | + const STATUS_STARTED = 2; |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 378 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 379 | 379 | /** |
| 380 | 380 | * Tag loan as payed completely |
| 381 | 381 | * |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function set_paid($user) |
| 386 | 386 | { |
| 387 | - // phpcs:enable |
|
| 387 | + // phpcs:enable |
|
| 388 | 388 | $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; |
| 389 | 389 | $sql .= " paid = ".$this::STATUS_PAID; |
| 390 | 390 | $sql .= " WHERE rowid = ".$this->id; |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 400 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 401 | 401 | /** |
| 402 | 402 | * Tag loan as payement started |
| 403 | 403 | * |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | public function set_started($user) |
| 408 | 408 | { |
| 409 | - // phpcs:enable |
|
| 409 | + // phpcs:enable |
|
| 410 | 410 | $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; |
| 411 | 411 | $sql .= " paid = ".$this::STATUS_STARTED; |
| 412 | 412 | $sql .= " WHERE rowid = ".$this->id; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 422 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 423 | 423 | /** |
| 424 | 424 | * Tag loan as payement as unpaid |
| 425 | 425 | * |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | */ |
| 429 | 429 | public function set_unpaid($user) |
| 430 | 430 | { |
| 431 | - // phpcs:enable |
|
| 431 | + // phpcs:enable |
|
| 432 | 432 | $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; |
| 433 | 433 | $sql .= " paid = ".$this::STATUS_UNPAID; |
| 434 | 434 | $sql .= " WHERE rowid = ".$this->id; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | return $this->LibStatut($this->paid, $mode, $alreadypaid); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 456 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 457 | 457 | /** |
| 458 | 458 | * Return label for given status |
| 459 | 459 | * |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | global $langs; |
| 477 | 477 | $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); |
| 478 | 478 | $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); |
| 479 | - $this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
|
| 479 | + $this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
|
| 480 | 480 | if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
| 481 | 481 | $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); |
| 482 | 482 | $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); |
| 483 | - $this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
|
| 483 | + $this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
|
| 484 | 484 | if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
| 485 | 485 | } |
| 486 | 486 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * |
| 498 | 498 | * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
| 499 | 499 | * @param int $maxlen Label max length |
| 500 | - * @param string $option On what the link point to ('nolink', ...) |
|
| 501 | - * @param int $notooltip 1=Disable tooltip |
|
| 502 | - * @param string $morecss Add more css on link |
|
| 503 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 500 | + * @param string $option On what the link point to ('nolink', ...) |
|
| 501 | + * @param int $notooltip 1=Disable tooltip |
|
| 502 | + * @param string $morecss Add more css on link |
|
| 503 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 504 | 504 | * @return string Chaine with URL |
| 505 | 505 | */ |
| 506 | 506 | public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) |
@@ -560,25 +560,25 @@ discard block |
||
| 560 | 560 | */ |
| 561 | 561 | public function initAsSpecimen() |
| 562 | 562 | { |
| 563 | - global $user, $langs, $conf; |
|
| 564 | - |
|
| 565 | - $now = dol_now(); |
|
| 566 | - |
|
| 567 | - // Initialise parameters |
|
| 568 | - $this->id = 0; |
|
| 569 | - $this->fk_bank = 1; |
|
| 570 | - $this->label = 'SPECIMEN'; |
|
| 571 | - $this->specimen = 1; |
|
| 572 | - $this->socid = 1; |
|
| 573 | - $this->account_capital = 16; |
|
| 574 | - $this->account_insurance = 616; |
|
| 575 | - $this->account_interest = 518; |
|
| 576 | - $this->datestart = $now; |
|
| 577 | - $this->dateend = $now + (3600 * 24 * 365); |
|
| 578 | - $this->note_public = 'SPECIMEN'; |
|
| 579 | - $this->capital = 20000; |
|
| 580 | - $this->nbterm = 48; |
|
| 581 | - $this->rate = 4.3; |
|
| 563 | + global $user, $langs, $conf; |
|
| 564 | + |
|
| 565 | + $now = dol_now(); |
|
| 566 | + |
|
| 567 | + // Initialise parameters |
|
| 568 | + $this->id = 0; |
|
| 569 | + $this->fk_bank = 1; |
|
| 570 | + $this->label = 'SPECIMEN'; |
|
| 571 | + $this->specimen = 1; |
|
| 572 | + $this->socid = 1; |
|
| 573 | + $this->account_capital = 16; |
|
| 574 | + $this->account_insurance = 616; |
|
| 575 | + $this->account_interest = 518; |
|
| 576 | + $this->datestart = $now; |
|
| 577 | + $this->dateend = $now + (3600 * 24 * 365); |
|
| 578 | + $this->note_public = 'SPECIMEN'; |
|
| 579 | + $this->capital = 20000; |
|
| 580 | + $this->nbterm = 48; |
|
| 581 | + $this->rate = 4.3; |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -659,5 +659,5 @@ discard block |
||
| 659 | 659 | $this->error = $this->db->lasterror(); |
| 660 | 660 | return -1; |
| 661 | 661 | } |
| 662 | - } |
|
| 662 | + } |
|
| 663 | 663 | } |
@@ -188,17 +188,37 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | // clean parameters |
| 190 | 190 | $newcapital = price2num($this->capital, 'MT'); |
| 191 | - if (empty($this->insurance_amount)) $this->insurance_amount = 0; |
|
| 191 | + if (empty($this->insurance_amount)) { |
|
| 192 | + $this->insurance_amount = 0; |
|
| 193 | + } |
|
| 192 | 194 | $newinsuranceamount = price2num($this->insurance_amount, 'MT'); |
| 193 | - if (isset($this->note_private)) $this->note_private = trim($this->note_private); |
|
| 194 | - if (isset($this->note_public)) $this->note_public = trim($this->note_public); |
|
| 195 | - if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital); |
|
| 196 | - if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance); |
|
| 197 | - if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest); |
|
| 198 | - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; |
|
| 199 | - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 200 | - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 201 | - if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project; |
|
| 195 | + if (isset($this->note_private)) { |
|
| 196 | + $this->note_private = trim($this->note_private); |
|
| 197 | + } |
|
| 198 | + if (isset($this->note_public)) { |
|
| 199 | + $this->note_public = trim($this->note_public); |
|
| 200 | + } |
|
| 201 | + if (isset($this->account_capital)) { |
|
| 202 | + $this->account_capital = trim($this->account_capital); |
|
| 203 | + } |
|
| 204 | + if (isset($this->account_insurance)) { |
|
| 205 | + $this->account_insurance = trim($this->account_insurance); |
|
| 206 | + } |
|
| 207 | + if (isset($this->account_interest)) { |
|
| 208 | + $this->account_interest = trim($this->account_interest); |
|
| 209 | + } |
|
| 210 | + if (isset($this->fk_bank)) { |
|
| 211 | + $this->fk_bank = (int) $this->fk_bank; |
|
| 212 | + } |
|
| 213 | + if (isset($this->fk_user_creat)) { |
|
| 214 | + $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 215 | + } |
|
| 216 | + if (isset($this->fk_user_modif)) { |
|
| 217 | + $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 218 | + } |
|
| 219 | + if (isset($this->fk_project)) { |
|
| 220 | + $this->fk_project = (int) $this->fk_project; |
|
| 221 | + } |
|
| 202 | 222 | |
| 203 | 223 | // Check parameters |
| 204 | 224 | if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) |
@@ -477,16 +497,24 @@ discard block |
||
| 477 | 497 | $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); |
| 478 | 498 | $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); |
| 479 | 499 | $this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
| 480 | - if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
|
| 500 | + if ($status == 0 && $alreadypaid > 0) { |
|
| 501 | + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
|
| 502 | + } |
|
| 481 | 503 | $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); |
| 482 | 504 | $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); |
| 483 | 505 | $this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); |
| 484 | - if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
|
| 506 | + if ($status == 0 && $alreadypaid > 0) { |
|
| 507 | + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); |
|
| 508 | + } |
|
| 485 | 509 | } |
| 486 | 510 | |
| 487 | 511 | $statusType = 'status1'; |
| 488 | - if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) $statusType = 'status3'; |
|
| 489 | - if ($status == 1) $statusType = 'status6'; |
|
| 512 | + if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) { |
|
| 513 | + $statusType = 'status3'; |
|
| 514 | + } |
|
| 515 | + if ($status == 1) { |
|
| 516 | + $statusType = 'status6'; |
|
| 517 | + } |
|
| 490 | 518 | |
| 491 | 519 | return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); |
| 492 | 520 | } |
@@ -523,8 +551,12 @@ discard block |
||
| 523 | 551 | { |
| 524 | 552 | // Add param to save lastsearch_values or not |
| 525 | 553 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
| 526 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 527 | - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 554 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
| 555 | + $add_save_lastsearch_values = 1; |
|
| 556 | + } |
|
| 557 | + if ($add_save_lastsearch_values) { |
|
| 558 | + $url .= '&save_lastsearch_values=1'; |
|
| 559 | + } |
|
| 528 | 560 | } |
| 529 | 561 | |
| 530 | 562 | $linkclose = ''; |
@@ -537,15 +569,21 @@ discard block |
||
| 537 | 569 | } |
| 538 | 570 | $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
| 539 | 571 | $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
| 540 | - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 572 | + } else { |
|
| 573 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 574 | + } |
|
| 541 | 575 | |
| 542 | 576 | $linkstart = '<a href="'.$url.'"'; |
| 543 | 577 | $linkstart .= $linkclose.'>'; |
| 544 | 578 | $linkend = '</a>'; |
| 545 | 579 | |
| 546 | 580 | $result .= $linkstart; |
| 547 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 548 | - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); |
|
| 581 | + if ($withpicto) { |
|
| 582 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 583 | + } |
|
| 584 | + if ($withpicto != 2) { |
|
| 585 | + $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); |
|
| 586 | + } |
|
| 549 | 587 | $result .= $linkend; |
| 550 | 588 | |
| 551 | 589 | return $result; |
@@ -602,7 +640,9 @@ discard block |
||
| 602 | 640 | $amount = 0; |
| 603 | 641 | |
| 604 | 642 | $obj = $this->db->fetch_object($resql); |
| 605 | - if ($obj) $amount = $obj->amount ? $obj->amount : 0; |
|
| 643 | + if ($obj) { |
|
| 644 | + $amount = $obj->amount ? $obj->amount : 0; |
|
| 645 | + } |
|
| 606 | 646 | |
| 607 | 647 | $this->db->free($resql); |
| 608 | 648 | return $amount; |
@@ -646,7 +686,9 @@ discard block |
||
| 646 | 686 | $this->user_modification = $muser; |
| 647 | 687 | } |
| 648 | 688 | $this->date_creation = $this->db->jdate($obj->datec); |
| 649 | - if (empty($obj->fk_user_modif)) $obj->tms = ""; |
|
| 689 | + if (empty($obj->fk_user_modif)) { |
|
| 690 | + $obj->tms = ""; |
|
| 691 | + } |
|
| 650 | 692 | $this->date_modification = $this->db->jdate($obj->tms); |
| 651 | 693 | |
| 652 | 694 | $this->db->free($result); |
@@ -41,63 +41,63 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public $table_element = 'payment_loan'; |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var string String with name of icon for PaymentLoan |
|
| 46 | - */ |
|
| 47 | - public $picto = 'money-bill-alt'; |
|
| 44 | + /** |
|
| 45 | + * @var string String with name of icon for PaymentLoan |
|
| 46 | + */ |
|
| 47 | + public $picto = 'money-bill-alt'; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var int Loan ID |
|
| 51 | - */ |
|
| 52 | - public $fk_loan; |
|
| 49 | + /** |
|
| 50 | + * @var int Loan ID |
|
| 51 | + */ |
|
| 52 | + public $fk_loan; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var string Create date |
|
| 56 | - */ |
|
| 57 | - public $datec = ''; |
|
| 54 | + /** |
|
| 55 | + * @var string Create date |
|
| 56 | + */ |
|
| 57 | + public $datec = ''; |
|
| 58 | 58 | |
| 59 | - public $tms = ''; |
|
| 59 | + public $tms = ''; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var string Payment date |
|
| 63 | - */ |
|
| 64 | - public $datep = ''; |
|
| 61 | + /** |
|
| 62 | + * @var string Payment date |
|
| 63 | + */ |
|
| 64 | + public $datep = ''; |
|
| 65 | 65 | |
| 66 | - public $amounts = array(); // Array of amounts |
|
| 66 | + public $amounts = array(); // Array of amounts |
|
| 67 | 67 | |
| 68 | - public $amount_capital; // Total amount of payment |
|
| 68 | + public $amount_capital; // Total amount of payment |
|
| 69 | 69 | |
| 70 | - public $amount_insurance; |
|
| 70 | + public $amount_insurance; |
|
| 71 | 71 | |
| 72 | - public $amount_interest; |
|
| 72 | + public $amount_interest; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var int Payment type ID |
|
| 76 | - */ |
|
| 77 | - public $fk_typepayment; |
|
| 74 | + /** |
|
| 75 | + * @var int Payment type ID |
|
| 76 | + */ |
|
| 77 | + public $fk_typepayment; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @var int Payment ID |
|
| 81 | - */ |
|
| 82 | - public $num_payment; |
|
| 79 | + /** |
|
| 80 | + * @var int Payment ID |
|
| 81 | + */ |
|
| 82 | + public $num_payment; |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @var int Bank ID |
|
| 86 | - */ |
|
| 87 | - public $fk_bank; |
|
| 84 | + /** |
|
| 85 | + * @var int Bank ID |
|
| 86 | + */ |
|
| 87 | + public $fk_bank; |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @var int User ID |
|
| 91 | - */ |
|
| 92 | - public $fk_user_creat; |
|
| 89 | + /** |
|
| 90 | + * @var int User ID |
|
| 91 | + */ |
|
| 92 | + public $fk_user_creat; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @var int user ID |
|
| 96 | - */ |
|
| 97 | - public $fk_user_modif; |
|
| 94 | + /** |
|
| 95 | + * @var int user ID |
|
| 96 | + */ |
|
| 97 | + public $fk_user_modif; |
|
| 98 | 98 | |
| 99 | - public $type_code; |
|
| 100 | - public $type_label; |
|
| 99 | + public $type_code; |
|
| 100 | + public $type_label; |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -367,23 +367,23 @@ discard block |
||
| 367 | 367 | if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - // Set loan unpaid if loan has no other payment |
|
| 371 | - if (!$error) |
|
| 372 | - { |
|
| 373 | - require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
|
| 374 | - $loan = new Loan($this->db); |
|
| 375 | - $loan->fetch($this->fk_loan); |
|
| 376 | - $sum_payment = $loan->getSumPayment(); |
|
| 377 | - if ($sum_payment == 0) |
|
| 378 | - { |
|
| 379 | - dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); |
|
| 380 | - if ($loan->set_unpaid($user) < 1) |
|
| 381 | - { |
|
| 382 | - $error++; |
|
| 383 | - dol_print_error($this->db); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 370 | + // Set loan unpaid if loan has no other payment |
|
| 371 | + if (!$error) |
|
| 372 | + { |
|
| 373 | + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
|
| 374 | + $loan = new Loan($this->db); |
|
| 375 | + $loan->fetch($this->fk_loan); |
|
| 376 | + $sum_payment = $loan->getSumPayment(); |
|
| 377 | + if ($sum_payment == 0) |
|
| 378 | + { |
|
| 379 | + dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); |
|
| 380 | + if ($loan->set_unpaid($user) < 1) |
|
| 381 | + { |
|
| 382 | + $error++; |
|
| 383 | + dol_print_error($this->db); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | 388 | //if (! $error) |
| 389 | 389 | //{ |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | global $conf; |
| 436 | 436 | |
| 437 | 437 | $error = 0; |
| 438 | - $this->db->begin(); |
|
| 438 | + $this->db->begin(); |
|
| 439 | 439 | |
| 440 | 440 | if (!empty($conf->banque->enabled)) |
| 441 | 441 | { |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | if ($mode == 'payment_loan') $total = -$total; |
| 449 | 449 | |
| 450 | 450 | // Insert payment into llx_bank |
| 451 | - $bank_line_id = $acc->addline( |
|
| 451 | + $bank_line_id = $acc->addline( |
|
| 452 | 452 | $this->datep, |
| 453 | 453 | $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") |
| 454 | 454 | $label, |
@@ -498,36 +498,36 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | |
| 501 | - // Set loan payment started if no set |
|
| 502 | - if (!$error) |
|
| 503 | - { |
|
| 504 | - require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
|
| 505 | - $loan = new Loan($this->db); |
|
| 506 | - $loan->fetch($fk_loan); |
|
| 507 | - if ($loan->paid == $loan::STATUS_UNPAID) |
|
| 508 | - { |
|
| 509 | - dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); |
|
| 510 | - if ($loan->set_started($user) < 1) |
|
| 511 | - { |
|
| 512 | - $error++; |
|
| 513 | - dol_print_error($this->db); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - } |
|
| 501 | + // Set loan payment started if no set |
|
| 502 | + if (!$error) |
|
| 503 | + { |
|
| 504 | + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
|
| 505 | + $loan = new Loan($this->db); |
|
| 506 | + $loan->fetch($fk_loan); |
|
| 507 | + if ($loan->paid == $loan::STATUS_UNPAID) |
|
| 508 | + { |
|
| 509 | + dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); |
|
| 510 | + if ($loan->set_started($user) < 1) |
|
| 511 | + { |
|
| 512 | + $error++; |
|
| 513 | + dol_print_error($this->db); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | if (!$error) |
| 519 | 519 | { |
| 520 | - $this->db->commit(); |
|
| 520 | + $this->db->commit(); |
|
| 521 | 521 | return 1; |
| 522 | 522 | } |
| 523 | 523 | else { |
| 524 | - $this->db->rollback(); |
|
| 524 | + $this->db->rollback(); |
|
| 525 | 525 | return -1; |
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | |
| 530 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 530 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 531 | 531 | /** |
| 532 | 532 | * Update link between loan's payment and the line generate in llx_bank |
| 533 | 533 | * |
@@ -536,14 +536,14 @@ discard block |
||
| 536 | 536 | */ |
| 537 | 537 | public function update_fk_bank($id_bank) |
| 538 | 538 | { |
| 539 | - // phpcs:enable |
|
| 539 | + // phpcs:enable |
|
| 540 | 540 | $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; |
| 541 | 541 | |
| 542 | 542 | dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); |
| 543 | 543 | $result = $this->db->query($sql); |
| 544 | 544 | if ($result) |
| 545 | 545 | { |
| 546 | - $this->fk_bank = $id_bank; |
|
| 546 | + $this->fk_bank = $id_bank; |
|
| 547 | 547 | return 1; |
| 548 | 548 | } else { |
| 549 | 549 | $this->error = $this->db->error(); |
@@ -556,9 +556,9 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto |
| 558 | 558 | * @param int $maxlen Max length label |
| 559 | - * @param int $notooltip 1=Disable tooltip |
|
| 560 | - * @param string $moretitle Add more text to title tooltip |
|
| 561 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 559 | + * @param int $notooltip 1=Disable tooltip |
|
| 560 | + * @param string $moretitle Add more text to title tooltip |
|
| 561 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 562 | 562 | * @return string String with URL |
| 563 | 563 | */ |
| 564 | 564 | public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $moretitle = '', $save_lastsearch_value = -1) |
@@ -133,23 +133,48 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Clean parameters |
| 136 | - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; |
|
| 137 | - if (isset($this->amount_capital)) $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); |
|
| 138 | - if (isset($this->amount_insurance)) $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); |
|
| 139 | - if (isset($this->amount_interest)) $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); |
|
| 140 | - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; |
|
| 141 | - if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment; |
|
| 142 | - if (isset($this->note_private)) $this->note_private = trim($this->note_private); |
|
| 143 | - if (isset($this->note_public)) $this->note_public = trim($this->note_public); |
|
| 144 | - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; |
|
| 145 | - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 146 | - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 136 | + if (isset($this->fk_loan)) { |
|
| 137 | + $this->fk_loan = (int) $this->fk_loan; |
|
| 138 | + } |
|
| 139 | + if (isset($this->amount_capital)) { |
|
| 140 | + $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); |
|
| 141 | + } |
|
| 142 | + if (isset($this->amount_insurance)) { |
|
| 143 | + $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); |
|
| 144 | + } |
|
| 145 | + if (isset($this->amount_interest)) { |
|
| 146 | + $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); |
|
| 147 | + } |
|
| 148 | + if (isset($this->fk_typepayment)) { |
|
| 149 | + $this->fk_typepayment = (int) $this->fk_typepayment; |
|
| 150 | + } |
|
| 151 | + if (isset($this->num_payment)) { |
|
| 152 | + $this->num_payment = (int) $this->num_payment; |
|
| 153 | + } |
|
| 154 | + if (isset($this->note_private)) { |
|
| 155 | + $this->note_private = trim($this->note_private); |
|
| 156 | + } |
|
| 157 | + if (isset($this->note_public)) { |
|
| 158 | + $this->note_public = trim($this->note_public); |
|
| 159 | + } |
|
| 160 | + if (isset($this->fk_bank)) { |
|
| 161 | + $this->fk_bank = (int) $this->fk_bank; |
|
| 162 | + } |
|
| 163 | + if (isset($this->fk_user_creat)) { |
|
| 164 | + $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 165 | + } |
|
| 166 | + if (isset($this->fk_user_modif)) { |
|
| 167 | + $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 168 | + } |
|
| 147 | 169 | |
| 148 | 170 | $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; |
| 149 | 171 | $totalamount = price2num($totalamount); |
| 150 | 172 | |
| 151 | 173 | // Check parameters |
| 152 | - if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null |
|
| 174 | + if ($totalamount == 0) { |
|
| 175 | + return -1; |
|
| 176 | + } |
|
| 177 | + // Negative amounts are accepted for reject prelevement but not null |
|
| 153 | 178 | |
| 154 | 179 | |
| 155 | 180 | $this->db->begin(); |
@@ -276,17 +301,39 @@ discard block |
||
| 276 | 301 | $error = 0; |
| 277 | 302 | |
| 278 | 303 | // Clean parameters |
| 279 | - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; |
|
| 280 | - if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital); |
|
| 281 | - if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance); |
|
| 282 | - if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest); |
|
| 283 | - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; |
|
| 284 | - if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment; |
|
| 285 | - if (isset($this->note_private)) $this->note = trim($this->note_private); |
|
| 286 | - if (isset($this->note_public)) $this->note = trim($this->note_public); |
|
| 287 | - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; |
|
| 288 | - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 289 | - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 304 | + if (isset($this->fk_loan)) { |
|
| 305 | + $this->fk_loan = (int) $this->fk_loan; |
|
| 306 | + } |
|
| 307 | + if (isset($this->amount_capital)) { |
|
| 308 | + $this->amount_capital = trim($this->amount_capital); |
|
| 309 | + } |
|
| 310 | + if (isset($this->amount_insurance)) { |
|
| 311 | + $this->amount_insurance = trim($this->amount_insurance); |
|
| 312 | + } |
|
| 313 | + if (isset($this->amount_interest)) { |
|
| 314 | + $this->amount_interest = trim($this->amount_interest); |
|
| 315 | + } |
|
| 316 | + if (isset($this->fk_typepayment)) { |
|
| 317 | + $this->fk_typepayment = (int) $this->fk_typepayment; |
|
| 318 | + } |
|
| 319 | + if (isset($this->num_payment)) { |
|
| 320 | + $this->num_payment = (int) $this->num_payment; |
|
| 321 | + } |
|
| 322 | + if (isset($this->note_private)) { |
|
| 323 | + $this->note = trim($this->note_private); |
|
| 324 | + } |
|
| 325 | + if (isset($this->note_public)) { |
|
| 326 | + $this->note = trim($this->note_public); |
|
| 327 | + } |
|
| 328 | + if (isset($this->fk_bank)) { |
|
| 329 | + $this->fk_bank = (int) $this->fk_bank; |
|
| 330 | + } |
|
| 331 | + if (isset($this->fk_user_creat)) { |
|
| 332 | + $this->fk_user_creat = (int) $this->fk_user_creat; |
|
| 333 | + } |
|
| 334 | + if (isset($this->fk_user_modif)) { |
|
| 335 | + $this->fk_user_modif = (int) $this->fk_user_modif; |
|
| 336 | + } |
|
| 290 | 337 | |
| 291 | 338 | // Check parameters |
| 292 | 339 | |
@@ -445,7 +492,9 @@ discard block |
||
| 445 | 492 | $acc->fetch($accountid); |
| 446 | 493 | |
| 447 | 494 | $total = $this->amount_capital; |
| 448 | - if ($mode == 'payment_loan') $total = -$total; |
|
| 495 | + if ($mode == 'payment_loan') { |
|
| 496 | + $total = -$total; |
|
| 497 | + } |
|
| 449 | 498 | |
| 450 | 499 | // Insert payment into llx_bank |
| 451 | 500 | $bank_line_id = $acc->addline( |
@@ -473,7 +522,9 @@ discard block |
||
| 473 | 522 | |
| 474 | 523 | // Add link 'payment_loan' in bank_url between payment and bank transaction |
| 475 | 524 | $url = ''; |
| 476 | - if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; |
|
| 525 | + if ($mode == 'payment_loan') { |
|
| 526 | + $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; |
|
| 527 | + } |
|
| 477 | 528 | if ($url) |
| 478 | 529 | { |
| 479 | 530 | $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); |
@@ -489,7 +540,9 @@ discard block |
||
| 489 | 540 | if ($mode == 'payment_loan') |
| 490 | 541 | { |
| 491 | 542 | $result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan'); |
| 492 | - if ($result <= 0) dol_print_error($this->db); |
|
| 543 | + if ($result <= 0) { |
|
| 544 | + dol_print_error($this->db); |
|
| 545 | + } |
|
| 493 | 546 | } |
| 494 | 547 | } else { |
| 495 | 548 | $this->error = $acc->error; |
@@ -519,8 +572,7 @@ discard block |
||
| 519 | 572 | { |
| 520 | 573 | $this->db->commit(); |
| 521 | 574 | return 1; |
| 522 | - } |
|
| 523 | - else { |
|
| 575 | + } else { |
|
| 524 | 576 | $this->db->rollback(); |
| 525 | 577 | return -1; |
| 526 | 578 | } |
@@ -565,27 +617,40 @@ discard block |
||
| 565 | 617 | { |
| 566 | 618 | global $langs, $conf; |
| 567 | 619 | |
| 568 | - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 620 | + if (!empty($conf->dol_no_mouse_hover)) { |
|
| 621 | + $notooltip = 1; |
|
| 622 | + } |
|
| 623 | + // Force disable tooltips |
|
| 569 | 624 | |
| 570 | 625 | $result = ''; |
| 571 | 626 | $label = '<u>'.$langs->trans("Loan").'</u>'; |
| 572 | 627 | if (!empty($this->id)) { |
| 573 | 628 | $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id; |
| 574 | 629 | } |
| 575 | - if ($moretitle) $label .= ' - '.$moretitle; |
|
| 630 | + if ($moretitle) { |
|
| 631 | + $label .= ' - '.$moretitle; |
|
| 632 | + } |
|
| 576 | 633 | |
| 577 | 634 | $url = DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id; |
| 578 | 635 | |
| 579 | 636 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
| 580 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 581 | - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 637 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
| 638 | + $add_save_lastsearch_values = 1; |
|
| 639 | + } |
|
| 640 | + if ($add_save_lastsearch_values) { |
|
| 641 | + $url .= '&save_lastsearch_values=1'; |
|
| 642 | + } |
|
| 582 | 643 | |
| 583 | 644 | $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
| 584 | 645 | $linkend = '</a>'; |
| 585 | 646 | |
| 586 | 647 | $result .= $linkstart; |
| 587 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 588 | - if ($withpicto != 2) $result .= $this->ref; |
|
| 648 | + if ($withpicto) { |
|
| 649 | + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 650 | + } |
|
| 651 | + if ($withpicto != 2) { |
|
| 652 | + $result .= $this->ref; |
|
| 653 | + } |
|
| 589 | 654 | $result .= $linkend; |
| 590 | 655 | |
| 591 | 656 | return $result; |