@@ -31,170 +31,170 @@ discard block |
||
31 | 31 | class modSubtotal extends DolibarrModules |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
36 | - * |
|
37 | - * @param DoliDB $db Database handler |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
36 | + * |
|
37 | + * @param DoliDB $db Database handler |
|
38 | + */ |
|
39 | 39 | |
40 | - public function __construct($db) |
|
41 | - { |
|
42 | - global $langs, $conf; |
|
40 | + public function __construct($db) |
|
41 | + { |
|
42 | + global $langs, $conf; |
|
43 | 43 | |
44 | - $this->db = $db; |
|
44 | + $this->db = $db; |
|
45 | 45 | |
46 | 46 | $this->editor_name = 'ATM-Consulting'; |
47 | - // Id for module (must be unique). |
|
48 | - // Use a free id here |
|
49 | - // (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | - $this->numero = 104777; // 104000 to 104999 for ATM CONSULTING |
|
51 | - // Key text used to identify module (for permissions, menus, etc...) |
|
52 | - $this->rights_class = 'subtotal'; |
|
47 | + // Id for module (must be unique). |
|
48 | + // Use a free id here |
|
49 | + // (See in Home -> System information -> Dolibarr for list of used modules id). |
|
50 | + $this->numero = 104777; // 104000 to 104999 for ATM CONSULTING |
|
51 | + // Key text used to identify module (for permissions, menus, etc...) |
|
52 | + $this->rights_class = 'subtotal'; |
|
53 | 53 | |
54 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
55 | - // It is used to group modules in module setup page |
|
56 | - $this->family = "technic"; |
|
57 | - // Module label (no space allowed) |
|
58 | - // used if translation string 'ModuleXXXName' not found |
|
59 | - // (where XXX is value of numeric property 'numero' of module) |
|
60 | - $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
61 | - // Module description |
|
62 | - // used if translation string 'ModuleXXXDesc' not found |
|
63 | - // (where XXX is value of numeric property 'numero' of module) |
|
64 | - $this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre"; |
|
65 | - // Possible values for version are: 'development', 'experimental' or version |
|
66 | - $this->version = '3.0.1'; |
|
67 | - // Key used in llx_const table to save module status enabled/disabled |
|
68 | - // (where MYMODULE is value of property name of module in uppercase) |
|
69 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
70 | - // Where to store the module in setup page |
|
71 | - // (0=common,1=interface,2=others,3=very specific) |
|
72 | - $this->special = 2; |
|
73 | - // Name of image file used for this module. |
|
74 | - // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
|
75 | - // use this->picto='pictovalue' |
|
76 | - // If file is in module/img directory under name object_pictovalue.png |
|
77 | - // use this->picto='pictovalue@module' |
|
78 | - $this->picto = 'subtotal@subtotal'; // mypicto@titre |
|
79 | - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
80 | - // for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable) |
|
81 | - // for specific path of parts (eg: /titre/core/modules/barcode) |
|
82 | - // for specific css file (eg: /titre/css/titre.css.php) |
|
83 | - $this->module_parts = array( |
|
84 | - // Set this to 1 if module has its own trigger directory |
|
85 | - 'triggers' => 1, |
|
86 | - // Set this to 1 if module has its own login method directory |
|
87 | - //'login' => 0, |
|
88 | - // Set this to 1 if module has its own substitution function file |
|
89 | - //'substitutions' => 0, |
|
90 | - // Set this to 1 if module has its own menus handler directory |
|
91 | - //'menus' => 0, |
|
92 | - // Set this to 1 if module has its own barcode directory |
|
93 | - //'barcode' => 0, |
|
94 | - // Set this to 1 if module has its own models directory |
|
95 | - 'models' => 1, |
|
96 | - // Set this to relative path of css if module has its own css file |
|
97 | - //'css' => '/titre/css/mycss.css.php', |
|
98 | - // Set here all hooks context managed by module |
|
99 | - 'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard') |
|
100 | - // Set here all workflow context managed by module |
|
101 | - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) |
|
102 | - ); |
|
54 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
|
55 | + // It is used to group modules in module setup page |
|
56 | + $this->family = "technic"; |
|
57 | + // Module label (no space allowed) |
|
58 | + // used if translation string 'ModuleXXXName' not found |
|
59 | + // (where XXX is value of numeric property 'numero' of module) |
|
60 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
61 | + // Module description |
|
62 | + // used if translation string 'ModuleXXXDesc' not found |
|
63 | + // (where XXX is value of numeric property 'numero' of module) |
|
64 | + $this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre"; |
|
65 | + // Possible values for version are: 'development', 'experimental' or version |
|
66 | + $this->version = '3.0.1'; |
|
67 | + // Key used in llx_const table to save module status enabled/disabled |
|
68 | + // (where MYMODULE is value of property name of module in uppercase) |
|
69 | + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
70 | + // Where to store the module in setup page |
|
71 | + // (0=common,1=interface,2=others,3=very specific) |
|
72 | + $this->special = 2; |
|
73 | + // Name of image file used for this module. |
|
74 | + // If file is in theme/yourtheme/img directory under name object_pictovalue.png |
|
75 | + // use this->picto='pictovalue' |
|
76 | + // If file is in module/img directory under name object_pictovalue.png |
|
77 | + // use this->picto='pictovalue@module' |
|
78 | + $this->picto = 'subtotal@subtotal'; // mypicto@titre |
|
79 | + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
80 | + // for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable) |
|
81 | + // for specific path of parts (eg: /titre/core/modules/barcode) |
|
82 | + // for specific css file (eg: /titre/css/titre.css.php) |
|
83 | + $this->module_parts = array( |
|
84 | + // Set this to 1 if module has its own trigger directory |
|
85 | + 'triggers' => 1, |
|
86 | + // Set this to 1 if module has its own login method directory |
|
87 | + //'login' => 0, |
|
88 | + // Set this to 1 if module has its own substitution function file |
|
89 | + //'substitutions' => 0, |
|
90 | + // Set this to 1 if module has its own menus handler directory |
|
91 | + //'menus' => 0, |
|
92 | + // Set this to 1 if module has its own barcode directory |
|
93 | + //'barcode' => 0, |
|
94 | + // Set this to 1 if module has its own models directory |
|
95 | + 'models' => 1, |
|
96 | + // Set this to relative path of css if module has its own css file |
|
97 | + //'css' => '/titre/css/mycss.css.php', |
|
98 | + // Set here all hooks context managed by module |
|
99 | + 'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard') |
|
100 | + // Set here all workflow context managed by module |
|
101 | + //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) |
|
102 | + ); |
|
103 | 103 | |
104 | - // Data directories to create when module is enabled. |
|
105 | - // Example: this->dirs = array("/titre/temp"); |
|
106 | - $this->dirs = array(); |
|
104 | + // Data directories to create when module is enabled. |
|
105 | + // Example: this->dirs = array("/titre/temp"); |
|
106 | + $this->dirs = array(); |
|
107 | 107 | |
108 | - // Config pages. Put here list of php pages |
|
109 | - // stored into titre/admin directory, used to setup module. |
|
110 | - $this->config_page_url = array("subtotal_setup.php@subtotal"); |
|
108 | + // Config pages. Put here list of php pages |
|
109 | + // stored into titre/admin directory, used to setup module. |
|
110 | + $this->config_page_url = array("subtotal_setup.php@subtotal"); |
|
111 | 111 | |
112 | - // Dependencies |
|
113 | - // List of modules id that must be enabled if this module is enabled |
|
114 | - $this->depends = array(); |
|
112 | + // Dependencies |
|
113 | + // List of modules id that must be enabled if this module is enabled |
|
114 | + $this->depends = array(); |
|
115 | 115 | |
116 | 116 | $this->conflictwith=array('modMilestone'); |
117 | - // List of modules id to disable if this one is disabled |
|
118 | - $this->requiredby = array(); |
|
119 | - // Minimum version of PHP required by module |
|
120 | - $this->phpmin = array(5, 3); |
|
121 | - // Minimum version of Dolibarr required by module |
|
122 | - $this->need_dolibarr_version = array(3, 2); |
|
123 | - $this->langfiles = array("subtotal@subtotal"); // langfiles@titre |
|
124 | - // Constants |
|
125 | - // List of particular constants to add when module is enabled |
|
126 | - // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
127 | - // Example: |
|
128 | - $this->const = array( |
|
129 | - 0=>array( |
|
130 | - 'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES', |
|
131 | - 'chaine', |
|
132 | - 'I', |
|
133 | - 'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché', |
|
134 | - 1 |
|
135 | - ) |
|
117 | + // List of modules id to disable if this one is disabled |
|
118 | + $this->requiredby = array(); |
|
119 | + // Minimum version of PHP required by module |
|
120 | + $this->phpmin = array(5, 3); |
|
121 | + // Minimum version of Dolibarr required by module |
|
122 | + $this->need_dolibarr_version = array(3, 2); |
|
123 | + $this->langfiles = array("subtotal@subtotal"); // langfiles@titre |
|
124 | + // Constants |
|
125 | + // List of particular constants to add when module is enabled |
|
126 | + // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
127 | + // Example: |
|
128 | + $this->const = array( |
|
129 | + 0=>array( |
|
130 | + 'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES', |
|
131 | + 'chaine', |
|
132 | + 'I', |
|
133 | + 'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché', |
|
134 | + 1 |
|
135 | + ) |
|
136 | 136 | ,1=>array('SUBTOTAL_ALLOW_ADD_BLOCK', 'chaine', '1', 'Permet l\'ajout de titres et sous-totaux') |
137 | 137 | ,2=>array('SUBTOTAL_ALLOW_EDIT_BLOCK', 'chaine', '1', 'Permet de modifier titres et sous-totaux') |
138 | 138 | ,3=>array('SUBTOTAL_ALLOW_REMOVE_BLOCK', 'chaine', '1', 'Permet de supprimer les titres et sous-totaux') |
139 | 139 | ,4=>array('SUBTOTAL_TITLE_STYLE', 'chaine', 'BU') |
140 | 140 | ,5=>array('SUBTOTAL_SUBTOTAL_STYLE', 'chaine', 'B') |
141 | - // 1=>array( |
|
142 | - // 'MYMODULE_MYNEWCONST2', |
|
143 | - // 'chaine', |
|
144 | - // 'myvalue', |
|
145 | - // 'This is another constant to add', |
|
146 | - // 0 |
|
147 | - // ) |
|
148 | - ); |
|
141 | + // 1=>array( |
|
142 | + // 'MYMODULE_MYNEWCONST2', |
|
143 | + // 'chaine', |
|
144 | + // 'myvalue', |
|
145 | + // 'This is another constant to add', |
|
146 | + // 0 |
|
147 | + // ) |
|
148 | + ); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | 152 | |
153 | - // Array to add new pages in new tabs |
|
154 | - // Example: |
|
155 | - $this->tabs = array( |
|
156 | - // // To add a new tab identified by code tabname1 |
|
157 | - // 'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__', |
|
158 | - // // To add another new tab identified by code tabname2 |
|
159 | - // 'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__', |
|
160 | - // // To remove an existing tab identified by code tabname |
|
161 | - // 'objecttype:-tabname' |
|
162 | - ); |
|
163 | - // where objecttype can be |
|
164 | - // 'thirdparty' to add a tab in third party view |
|
165 | - // 'intervention' to add a tab in intervention view |
|
166 | - // 'order_supplier' to add a tab in supplier order view |
|
167 | - // 'invoice_supplier' to add a tab in supplier invoice view |
|
168 | - // 'invoice' to add a tab in customer invoice view |
|
169 | - // 'order' to add a tab in customer order view |
|
170 | - // 'product' to add a tab in product view |
|
171 | - // 'stock' to add a tab in stock view |
|
172 | - // 'propal' to add a tab in propal view |
|
173 | - // 'member' to add a tab in fundation member view |
|
174 | - // 'contract' to add a tab in contract view |
|
175 | - // 'user' to add a tab in user view |
|
176 | - // 'group' to add a tab in group view |
|
177 | - // 'contact' to add a tab in contact view |
|
178 | - // 'categories_x' to add a tab in category view |
|
179 | - // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
180 | - // Dictionnaries |
|
181 | - if (! isset($conf->subtotal->enabled)) { |
|
182 | - $conf->subtotal=new stdClass(); |
|
183 | - $conf->subtotal->enabled = 0; |
|
184 | - } |
|
185 | - $this->dictionaries = array( |
|
153 | + // Array to add new pages in new tabs |
|
154 | + // Example: |
|
155 | + $this->tabs = array( |
|
156 | + // // To add a new tab identified by code tabname1 |
|
157 | + // 'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__', |
|
158 | + // // To add another new tab identified by code tabname2 |
|
159 | + // 'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__', |
|
160 | + // // To remove an existing tab identified by code tabname |
|
161 | + // 'objecttype:-tabname' |
|
162 | + ); |
|
163 | + // where objecttype can be |
|
164 | + // 'thirdparty' to add a tab in third party view |
|
165 | + // 'intervention' to add a tab in intervention view |
|
166 | + // 'order_supplier' to add a tab in supplier order view |
|
167 | + // 'invoice_supplier' to add a tab in supplier invoice view |
|
168 | + // 'invoice' to add a tab in customer invoice view |
|
169 | + // 'order' to add a tab in customer order view |
|
170 | + // 'product' to add a tab in product view |
|
171 | + // 'stock' to add a tab in stock view |
|
172 | + // 'propal' to add a tab in propal view |
|
173 | + // 'member' to add a tab in fundation member view |
|
174 | + // 'contract' to add a tab in contract view |
|
175 | + // 'user' to add a tab in user view |
|
176 | + // 'group' to add a tab in group view |
|
177 | + // 'contact' to add a tab in contact view |
|
178 | + // 'categories_x' to add a tab in category view |
|
179 | + // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
180 | + // Dictionnaries |
|
181 | + if (! isset($conf->subtotal->enabled)) { |
|
182 | + $conf->subtotal=new stdClass(); |
|
183 | + $conf->subtotal->enabled = 0; |
|
184 | + } |
|
185 | + $this->dictionaries = array( |
|
186 | 186 | 'langs'=>'subtotal@subtotal', |
187 | - 'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor |
|
188 | - 'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables |
|
189 | - 'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields |
|
190 | - 'tabsqlsort'=>array('label ASC'), // Sort order |
|
191 | - 'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary) |
|
192 | - 'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record) |
|
193 | - 'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert) |
|
194 | - 'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid') |
|
195 | - 'tabcond'=>array($conf->subtotal->enabled) |
|
187 | + 'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor |
|
188 | + 'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables |
|
189 | + 'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields |
|
190 | + 'tabsqlsort'=>array('label ASC'), // Sort order |
|
191 | + 'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary) |
|
192 | + 'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record) |
|
193 | + 'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert) |
|
194 | + 'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid') |
|
195 | + 'tabcond'=>array($conf->subtotal->enabled) |
|
196 | 196 | ); |
197 | - /* Example: |
|
197 | + /* Example: |
|
198 | 198 | // This is to avoid warnings |
199 | 199 | if (! isset($conf->titre->enabled)) $conf->titre->enabled=0; |
200 | 200 | $this->dictionnaries=array( |
@@ -235,223 +235,223 @@ discard block |
||
235 | 235 | ); |
236 | 236 | */ |
237 | 237 | |
238 | - // Boxes |
|
239 | - // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
240 | - $this->boxes = array(); // Boxes list |
|
238 | + // Boxes |
|
239 | + // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
240 | + $this->boxes = array(); // Boxes list |
|
241 | 241 | |
242 | - /* |
|
242 | + /* |
|
243 | 243 | $this->boxes[$r][1] = "myboxb.php"; |
244 | 244 | $r++; |
245 | 245 | */ |
246 | 246 | |
247 | - // Permissions |
|
248 | - $this->rights = array(); // Permission array used by this module |
|
249 | - $r = 0; |
|
247 | + // Permissions |
|
248 | + $this->rights = array(); // Permission array used by this module |
|
249 | + $r = 0; |
|
250 | 250 | |
251 | - // Add here list of permission defined by |
|
252 | - // an id, a label, a boolean and two constant strings. |
|
253 | - // Example: |
|
254 | - //// Permission id (must not be already used) |
|
255 | - //$this->rights[$r][0] = 2000; |
|
256 | - //// Permission label |
|
257 | - //$this->rights[$r][1] = 'Permision label'; |
|
258 | - //// Permission by default for new user (0/1) |
|
259 | - //$this->rights[$r][3] = 1; |
|
260 | - //// In php code, permission will be checked by test |
|
261 | - //// if ($user->rights->permkey->level1->level2) |
|
262 | - //$this->rights[$r][4] = 'level1'; |
|
263 | - //// In php code, permission will be checked by test |
|
264 | - //// if ($user->rights->permkey->level1->level2) |
|
265 | - //$this->rights[$r][5] = 'level2'; |
|
266 | - //$r++; |
|
267 | - // Main menu entries |
|
268 | - $this->menus = array(); // List of menus to add |
|
269 | - $r = 0; |
|
251 | + // Add here list of permission defined by |
|
252 | + // an id, a label, a boolean and two constant strings. |
|
253 | + // Example: |
|
254 | + //// Permission id (must not be already used) |
|
255 | + //$this->rights[$r][0] = 2000; |
|
256 | + //// Permission label |
|
257 | + //$this->rights[$r][1] = 'Permision label'; |
|
258 | + //// Permission by default for new user (0/1) |
|
259 | + //$this->rights[$r][3] = 1; |
|
260 | + //// In php code, permission will be checked by test |
|
261 | + //// if ($user->rights->permkey->level1->level2) |
|
262 | + //$this->rights[$r][4] = 'level1'; |
|
263 | + //// In php code, permission will be checked by test |
|
264 | + //// if ($user->rights->permkey->level1->level2) |
|
265 | + //$this->rights[$r][5] = 'level2'; |
|
266 | + //$r++; |
|
267 | + // Main menu entries |
|
268 | + $this->menus = array(); // List of menus to add |
|
269 | + $r = 0; |
|
270 | 270 | |
271 | - // Add here entries to declare new menus |
|
272 | - // |
|
273 | - // Example to declare a new Top Menu entry and its Left menu entry: |
|
274 | - //$this->menu[$r]=array( |
|
275 | - // // Put 0 if this is a top menu |
|
276 | - // 'fk_menu'=>0, |
|
277 | - // // This is a Top menu entry |
|
278 | - // 'type'=>'top', |
|
279 | - // 'titre'=>'titre top menu', |
|
280 | - // 'mainmenu'=>'titre', |
|
281 | - // 'leftmenu'=>'titre', |
|
282 | - // 'url'=>'/titre/pagetop.php', |
|
283 | - // // Lang file to use (without .lang) by module. |
|
284 | - // // File must be in langs/code_CODE/ directory. |
|
285 | - // 'langs'=>'mylangfile', |
|
286 | - // 'position'=>100, |
|
287 | - // // Define condition to show or hide menu entry. |
|
288 | - // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
289 | - // 'enabled'=>'$conf->titre->enabled', |
|
290 | - // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
291 | - // // if you want your menu with a permission rules |
|
292 | - // 'perms'=>'1', |
|
293 | - // 'target'=>'', |
|
294 | - // // 0=Menu for internal users, 1=external users, 2=both |
|
295 | - // 'user'=>2 |
|
296 | - //); |
|
297 | - //$r++; |
|
298 | - //$this->menu[$r]=array( |
|
299 | - // // Use r=value where r is index key used for the parent menu entry |
|
300 | - // // (higher parent must be a top menu entry) |
|
301 | - // 'fk_menu'=>'r=0', |
|
302 | - // // This is a Left menu entry |
|
303 | - // 'type'=>'left', |
|
304 | - // 'titre'=>'titre left menu', |
|
305 | - // 'mainmenu'=>'titre', |
|
306 | - // 'leftmenu'=>'titre', |
|
307 | - // 'url'=>'/titre/pagelevel1.php', |
|
308 | - // // Lang file to use (without .lang) by module. |
|
309 | - // // File must be in langs/code_CODE/ directory. |
|
310 | - // 'langs'=>'mylangfile', |
|
311 | - // 'position'=>100, |
|
312 | - // // Define condition to show or hide menu entry. |
|
313 | - // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
314 | - // 'enabled'=>'$conf->titre->enabled', |
|
315 | - // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
316 | - // // if you want your menu with a permission rules |
|
317 | - // 'perms'=>'1', |
|
318 | - // 'target'=>'', |
|
319 | - // // 0=Menu for internal users, 1=external users, 2=both |
|
320 | - // 'user'=>2 |
|
321 | - //); |
|
322 | - //$r++; |
|
323 | - // |
|
324 | - // Example to declare a Left Menu entry into an existing Top menu entry: |
|
325 | - //$this->menu[$r]=array( |
|
326 | - // // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' |
|
327 | - // 'fk_menu'=>'fk_mainmenu=mainmenucode', |
|
328 | - // // This is a Left menu entry |
|
329 | - // 'type'=>'left', |
|
330 | - // 'titre'=>'titre left menu', |
|
331 | - // 'mainmenu'=>'mainmenucode', |
|
332 | - // 'leftmenu'=>'titre', |
|
333 | - // 'url'=>'/titre/pagelevel2.php', |
|
334 | - // // Lang file to use (without .lang) by module. |
|
335 | - // // File must be in langs/code_CODE/ directory. |
|
336 | - // 'langs'=>'mylangfile', |
|
337 | - // 'position'=>100, |
|
338 | - // // Define condition to show or hide menu entry. |
|
339 | - // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
340 | - // // Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
341 | - // 'enabled'=>'$conf->titre->enabled', |
|
342 | - // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
343 | - // // if you want your menu with a permission rules |
|
344 | - // 'perms'=>'1', |
|
345 | - // 'target'=>'', |
|
346 | - // // 0=Menu for internal users, 1=external users, 2=both |
|
347 | - // 'user'=>2 |
|
348 | - //); |
|
349 | - //$r++; |
|
350 | - // Exports |
|
351 | - $r = 1; |
|
271 | + // Add here entries to declare new menus |
|
272 | + // |
|
273 | + // Example to declare a new Top Menu entry and its Left menu entry: |
|
274 | + //$this->menu[$r]=array( |
|
275 | + // // Put 0 if this is a top menu |
|
276 | + // 'fk_menu'=>0, |
|
277 | + // // This is a Top menu entry |
|
278 | + // 'type'=>'top', |
|
279 | + // 'titre'=>'titre top menu', |
|
280 | + // 'mainmenu'=>'titre', |
|
281 | + // 'leftmenu'=>'titre', |
|
282 | + // 'url'=>'/titre/pagetop.php', |
|
283 | + // // Lang file to use (without .lang) by module. |
|
284 | + // // File must be in langs/code_CODE/ directory. |
|
285 | + // 'langs'=>'mylangfile', |
|
286 | + // 'position'=>100, |
|
287 | + // // Define condition to show or hide menu entry. |
|
288 | + // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
289 | + // 'enabled'=>'$conf->titre->enabled', |
|
290 | + // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
291 | + // // if you want your menu with a permission rules |
|
292 | + // 'perms'=>'1', |
|
293 | + // 'target'=>'', |
|
294 | + // // 0=Menu for internal users, 1=external users, 2=both |
|
295 | + // 'user'=>2 |
|
296 | + //); |
|
297 | + //$r++; |
|
298 | + //$this->menu[$r]=array( |
|
299 | + // // Use r=value where r is index key used for the parent menu entry |
|
300 | + // // (higher parent must be a top menu entry) |
|
301 | + // 'fk_menu'=>'r=0', |
|
302 | + // // This is a Left menu entry |
|
303 | + // 'type'=>'left', |
|
304 | + // 'titre'=>'titre left menu', |
|
305 | + // 'mainmenu'=>'titre', |
|
306 | + // 'leftmenu'=>'titre', |
|
307 | + // 'url'=>'/titre/pagelevel1.php', |
|
308 | + // // Lang file to use (without .lang) by module. |
|
309 | + // // File must be in langs/code_CODE/ directory. |
|
310 | + // 'langs'=>'mylangfile', |
|
311 | + // 'position'=>100, |
|
312 | + // // Define condition to show or hide menu entry. |
|
313 | + // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
314 | + // 'enabled'=>'$conf->titre->enabled', |
|
315 | + // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
316 | + // // if you want your menu with a permission rules |
|
317 | + // 'perms'=>'1', |
|
318 | + // 'target'=>'', |
|
319 | + // // 0=Menu for internal users, 1=external users, 2=both |
|
320 | + // 'user'=>2 |
|
321 | + //); |
|
322 | + //$r++; |
|
323 | + // |
|
324 | + // Example to declare a Left Menu entry into an existing Top menu entry: |
|
325 | + //$this->menu[$r]=array( |
|
326 | + // // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' |
|
327 | + // 'fk_menu'=>'fk_mainmenu=mainmenucode', |
|
328 | + // // This is a Left menu entry |
|
329 | + // 'type'=>'left', |
|
330 | + // 'titre'=>'titre left menu', |
|
331 | + // 'mainmenu'=>'mainmenucode', |
|
332 | + // 'leftmenu'=>'titre', |
|
333 | + // 'url'=>'/titre/pagelevel2.php', |
|
334 | + // // Lang file to use (without .lang) by module. |
|
335 | + // // File must be in langs/code_CODE/ directory. |
|
336 | + // 'langs'=>'mylangfile', |
|
337 | + // 'position'=>100, |
|
338 | + // // Define condition to show or hide menu entry. |
|
339 | + // // Use '$conf->titre->enabled' if entry must be visible if module is enabled. |
|
340 | + // // Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
341 | + // 'enabled'=>'$conf->titre->enabled', |
|
342 | + // // Use 'perms'=>'$user->rights->titre->level1->level2' |
|
343 | + // // if you want your menu with a permission rules |
|
344 | + // 'perms'=>'1', |
|
345 | + // 'target'=>'', |
|
346 | + // // 0=Menu for internal users, 1=external users, 2=both |
|
347 | + // 'user'=>2 |
|
348 | + //); |
|
349 | + //$r++; |
|
350 | + // Exports |
|
351 | + $r = 1; |
|
352 | 352 | |
353 | - // Example: |
|
354 | - //$this->export_code[$r]=$this->rights_class.'_'.$r; |
|
355 | - //// Translation key (used only if key ExportDataset_xxx_z not found) |
|
356 | - //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; |
|
357 | - //// Condition to show export in list (ie: '$user->id==3'). |
|
358 | - //// Set to 1 to always show when module is enabled. |
|
359 | - //$this->export_enabled[$r]='1'; |
|
360 | - //$this->export_permission[$r]=array(array("facture","facture","export")); |
|
361 | - //$this->export_fields_array[$r]=array( |
|
362 | - // 's.rowid'=>"IdCompany", |
|
363 | - // 's.nom'=>'CompanyName', |
|
364 | - // 's.address'=>'Address', |
|
365 | - // 's.cp'=>'Zip', |
|
366 | - // 's.ville'=>'Town', |
|
367 | - // 's.fk_pays'=>'Country', |
|
368 | - // 's.tel'=>'Phone', |
|
369 | - // 's.siren'=>'ProfId1', |
|
370 | - // 's.siret'=>'ProfId2', |
|
371 | - // 's.ape'=>'ProfId3', |
|
372 | - // 's.idprof4'=>'ProfId4', |
|
373 | - // 's.code_compta'=>'CustomerAccountancyCode', |
|
374 | - // 's.code_compta_fournisseur'=>'SupplierAccountancyCode', |
|
375 | - // 'f.rowid'=>"InvoiceId", |
|
376 | - // 'f.facnumber'=>"InvoiceRef", |
|
377 | - // 'f.datec'=>"InvoiceDateCreation", |
|
378 | - // 'f.datef'=>"DateInvoice", |
|
379 | - // 'f.total'=>"TotalHT", |
|
380 | - // 'f.total_ttc'=>"TotalTTC", |
|
381 | - // 'f.tva'=>"TotalVAT", |
|
382 | - // 'f.paye'=>"InvoicePaid", |
|
383 | - // 'f.fk_statut'=>'InvoiceStatus', |
|
384 | - // 'f.note'=>"InvoiceNote", |
|
385 | - // 'fd.rowid'=>'LineId', |
|
386 | - // 'fd.description'=>"LineDescription", |
|
387 | - // 'fd.price'=>"LineUnitPrice", |
|
388 | - // 'fd.tva_tx'=>"LineVATRate", |
|
389 | - // 'fd.qty'=>"LineQty", |
|
390 | - // 'fd.total_ht'=>"LineTotalHT", |
|
391 | - // 'fd.total_tva'=>"LineTotalTVA", |
|
392 | - // 'fd.total_ttc'=>"LineTotalTTC", |
|
393 | - // 'fd.date_start'=>"DateStart", |
|
394 | - // 'fd.date_end'=>"DateEnd", |
|
395 | - // 'fd.fk_product'=>'ProductId', |
|
396 | - // 'p.ref'=>'ProductRef' |
|
397 | - //); |
|
398 | - //$this->export_entities_array[$r]=array('s.rowid'=>"company", |
|
399 | - // 's.nom'=>'company', |
|
400 | - // 's.address'=>'company', |
|
401 | - // 's.cp'=>'company', |
|
402 | - // 's.ville'=>'company', |
|
403 | - // 's.fk_pays'=>'company', |
|
404 | - // 's.tel'=>'company', |
|
405 | - // 's.siren'=>'company', |
|
406 | - // 's.siret'=>'company', |
|
407 | - // 's.ape'=>'company', |
|
408 | - // 's.idprof4'=>'company', |
|
409 | - // 's.code_compta'=>'company', |
|
410 | - // 's.code_compta_fournisseur'=>'company', |
|
411 | - // 'f.rowid'=>"invoice", |
|
412 | - // 'f.facnumber'=>"invoice", |
|
413 | - // 'f.datec'=>"invoice", |
|
414 | - // 'f.datef'=>"invoice", |
|
415 | - // 'f.total'=>"invoice", |
|
416 | - // 'f.total_ttc'=>"invoice", |
|
417 | - // 'f.tva'=>"invoice", |
|
418 | - // 'f.paye'=>"invoice", |
|
419 | - // 'f.fk_statut'=>'invoice', |
|
420 | - // 'f.note'=>"invoice", |
|
421 | - // 'fd.rowid'=>'invoice_line', |
|
422 | - // 'fd.description'=>"invoice_line", |
|
423 | - // 'fd.price'=>"invoice_line", |
|
424 | - // 'fd.total_ht'=>"invoice_line", |
|
425 | - // 'fd.total_tva'=>"invoice_line", |
|
426 | - // 'fd.total_ttc'=>"invoice_line", |
|
427 | - // 'fd.tva_tx'=>"invoice_line", |
|
428 | - // 'fd.qty'=>"invoice_line", |
|
429 | - // 'fd.date_start'=>"invoice_line", |
|
430 | - // 'fd.date_end'=>"invoice_line", |
|
431 | - // 'fd.fk_product'=>'product', |
|
432 | - // 'p.ref'=>'product' |
|
433 | - //); |
|
434 | - //$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
435 | - //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, ' |
|
436 | - // . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)'; |
|
437 | - //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX |
|
438 | - // . 'product as p on (fd.fk_product = p.rowid)'; |
|
439 | - //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid ' |
|
440 | - // . 'AND f.rowid = fd.fk_facture'; |
|
441 | - //$r++; |
|
442 | - } |
|
353 | + // Example: |
|
354 | + //$this->export_code[$r]=$this->rights_class.'_'.$r; |
|
355 | + //// Translation key (used only if key ExportDataset_xxx_z not found) |
|
356 | + //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; |
|
357 | + //// Condition to show export in list (ie: '$user->id==3'). |
|
358 | + //// Set to 1 to always show when module is enabled. |
|
359 | + //$this->export_enabled[$r]='1'; |
|
360 | + //$this->export_permission[$r]=array(array("facture","facture","export")); |
|
361 | + //$this->export_fields_array[$r]=array( |
|
362 | + // 's.rowid'=>"IdCompany", |
|
363 | + // 's.nom'=>'CompanyName', |
|
364 | + // 's.address'=>'Address', |
|
365 | + // 's.cp'=>'Zip', |
|
366 | + // 's.ville'=>'Town', |
|
367 | + // 's.fk_pays'=>'Country', |
|
368 | + // 's.tel'=>'Phone', |
|
369 | + // 's.siren'=>'ProfId1', |
|
370 | + // 's.siret'=>'ProfId2', |
|
371 | + // 's.ape'=>'ProfId3', |
|
372 | + // 's.idprof4'=>'ProfId4', |
|
373 | + // 's.code_compta'=>'CustomerAccountancyCode', |
|
374 | + // 's.code_compta_fournisseur'=>'SupplierAccountancyCode', |
|
375 | + // 'f.rowid'=>"InvoiceId", |
|
376 | + // 'f.facnumber'=>"InvoiceRef", |
|
377 | + // 'f.datec'=>"InvoiceDateCreation", |
|
378 | + // 'f.datef'=>"DateInvoice", |
|
379 | + // 'f.total'=>"TotalHT", |
|
380 | + // 'f.total_ttc'=>"TotalTTC", |
|
381 | + // 'f.tva'=>"TotalVAT", |
|
382 | + // 'f.paye'=>"InvoicePaid", |
|
383 | + // 'f.fk_statut'=>'InvoiceStatus', |
|
384 | + // 'f.note'=>"InvoiceNote", |
|
385 | + // 'fd.rowid'=>'LineId', |
|
386 | + // 'fd.description'=>"LineDescription", |
|
387 | + // 'fd.price'=>"LineUnitPrice", |
|
388 | + // 'fd.tva_tx'=>"LineVATRate", |
|
389 | + // 'fd.qty'=>"LineQty", |
|
390 | + // 'fd.total_ht'=>"LineTotalHT", |
|
391 | + // 'fd.total_tva'=>"LineTotalTVA", |
|
392 | + // 'fd.total_ttc'=>"LineTotalTTC", |
|
393 | + // 'fd.date_start'=>"DateStart", |
|
394 | + // 'fd.date_end'=>"DateEnd", |
|
395 | + // 'fd.fk_product'=>'ProductId', |
|
396 | + // 'p.ref'=>'ProductRef' |
|
397 | + //); |
|
398 | + //$this->export_entities_array[$r]=array('s.rowid'=>"company", |
|
399 | + // 's.nom'=>'company', |
|
400 | + // 's.address'=>'company', |
|
401 | + // 's.cp'=>'company', |
|
402 | + // 's.ville'=>'company', |
|
403 | + // 's.fk_pays'=>'company', |
|
404 | + // 's.tel'=>'company', |
|
405 | + // 's.siren'=>'company', |
|
406 | + // 's.siret'=>'company', |
|
407 | + // 's.ape'=>'company', |
|
408 | + // 's.idprof4'=>'company', |
|
409 | + // 's.code_compta'=>'company', |
|
410 | + // 's.code_compta_fournisseur'=>'company', |
|
411 | + // 'f.rowid'=>"invoice", |
|
412 | + // 'f.facnumber'=>"invoice", |
|
413 | + // 'f.datec'=>"invoice", |
|
414 | + // 'f.datef'=>"invoice", |
|
415 | + // 'f.total'=>"invoice", |
|
416 | + // 'f.total_ttc'=>"invoice", |
|
417 | + // 'f.tva'=>"invoice", |
|
418 | + // 'f.paye'=>"invoice", |
|
419 | + // 'f.fk_statut'=>'invoice', |
|
420 | + // 'f.note'=>"invoice", |
|
421 | + // 'fd.rowid'=>'invoice_line', |
|
422 | + // 'fd.description'=>"invoice_line", |
|
423 | + // 'fd.price'=>"invoice_line", |
|
424 | + // 'fd.total_ht'=>"invoice_line", |
|
425 | + // 'fd.total_tva'=>"invoice_line", |
|
426 | + // 'fd.total_ttc'=>"invoice_line", |
|
427 | + // 'fd.tva_tx'=>"invoice_line", |
|
428 | + // 'fd.qty'=>"invoice_line", |
|
429 | + // 'fd.date_start'=>"invoice_line", |
|
430 | + // 'fd.date_end'=>"invoice_line", |
|
431 | + // 'fd.fk_product'=>'product', |
|
432 | + // 'p.ref'=>'product' |
|
433 | + //); |
|
434 | + //$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
435 | + //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, ' |
|
436 | + // . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)'; |
|
437 | + //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX |
|
438 | + // . 'product as p on (fd.fk_product = p.rowid)'; |
|
439 | + //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid ' |
|
440 | + // . 'AND f.rowid = fd.fk_facture'; |
|
441 | + //$r++; |
|
442 | + } |
|
443 | 443 | |
444 | - /** |
|
445 | - * Function called when module is enabled. |
|
446 | - * The init function add constants, boxes, permissions and menus |
|
447 | - * (defined in constructor) into Dolibarr database. |
|
448 | - * It also creates data directories |
|
449 | - * |
|
450 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
451 | - * @return int 1 if OK, 0 if KO |
|
452 | - */ |
|
453 | - public function init($options = '') |
|
454 | - { |
|
444 | + /** |
|
445 | + * Function called when module is enabled. |
|
446 | + * The init function add constants, boxes, permissions and menus |
|
447 | + * (defined in constructor) into Dolibarr database. |
|
448 | + * It also creates data directories |
|
449 | + * |
|
450 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
451 | + * @return int 1 if OK, 0 if KO |
|
452 | + */ |
|
453 | + public function init($options = '') |
|
454 | + { |
|
455 | 455 | global $conf; |
456 | 456 | |
457 | 457 | |
@@ -459,39 +459,39 @@ discard block |
||
459 | 459 | exit("Attention, ce module rentre ne conflit avec le module Jalon/Milestones. Merci de le désactiver auparavant."); |
460 | 460 | } |
461 | 461 | */ |
462 | - $sql = array(); |
|
462 | + $sql = array(); |
|
463 | 463 | |
464 | - $result = $this->loadTables(); |
|
464 | + $result = $this->loadTables(); |
|
465 | 465 | |
466 | 466 | |
467 | - return $this->_init($sql, $options); |
|
468 | - } |
|
467 | + return $this->_init($sql, $options); |
|
468 | + } |
|
469 | 469 | |
470 | - /** |
|
471 | - * Function called when module is disabled. |
|
472 | - * Remove from database constants, boxes and permissions from Dolibarr database. |
|
473 | - * Data directories are not deleted |
|
474 | - * |
|
475 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
476 | - * @return int 1 if OK, 0 if KO |
|
477 | - */ |
|
478 | - public function remove($options = '') |
|
479 | - { |
|
480 | - $sql = array(); |
|
470 | + /** |
|
471 | + * Function called when module is disabled. |
|
472 | + * Remove from database constants, boxes and permissions from Dolibarr database. |
|
473 | + * Data directories are not deleted |
|
474 | + * |
|
475 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
476 | + * @return int 1 if OK, 0 if KO |
|
477 | + */ |
|
478 | + public function remove($options = '') |
|
479 | + { |
|
480 | + $sql = array(); |
|
481 | 481 | |
482 | - return $this->_remove($sql, $options); |
|
483 | - } |
|
482 | + return $this->_remove($sql, $options); |
|
483 | + } |
|
484 | 484 | |
485 | - /** |
|
486 | - * Create tables, keys and data required by module |
|
487 | - * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys |
|
488 | - * and create data commands must be stored in directory /titre/sql/ |
|
489 | - * This function is called by this->init |
|
490 | - * |
|
491 | - * @return int <=0 if KO, >0 if OK |
|
492 | - */ |
|
493 | - private function loadTables() |
|
494 | - { |
|
495 | - return $this->_load_tables('/subtotal/sql/'); |
|
496 | - } |
|
485 | + /** |
|
486 | + * Create tables, keys and data required by module |
|
487 | + * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys |
|
488 | + * and create data commands must be stored in directory /titre/sql/ |
|
489 | + * This function is called by this->init |
|
490 | + * |
|
491 | + * @return int <=0 if KO, >0 if OK |
|
492 | + */ |
|
493 | + private function loadTables() |
|
494 | + { |
|
495 | + return $this->_load_tables('/subtotal/sql/'); |
|
496 | + } |
|
497 | 497 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup titre |
24 | 24 | * \brief Description and activation file for module titre |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php"; |
|
26 | +include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Description and activation class for module titre |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->version = '3.0.1'; |
67 | 67 | // Key used in llx_const table to save module status enabled/disabled |
68 | 68 | // (where MYMODULE is value of property name of module in uppercase) |
69 | - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
|
69 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
70 | 70 | // Where to store the module in setup page |
71 | 71 | // (0=common,1=interface,2=others,3=very specific) |
72 | 72 | $this->special = 2; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set this to relative path of css if module has its own css file |
97 | 97 | //'css' => '/titre/css/mycss.css.php', |
98 | 98 | // Set here all hooks context managed by module |
99 | - 'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard') |
|
99 | + 'hooks' => array('invoicecard', 'invoicesuppliercard', 'propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard', 'odtgeneration', 'orderstoinvoice', 'admin', 'invoicereccard') |
|
100 | 100 | // Set here all workflow context managed by module |
101 | 101 | //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) |
102 | 102 | ); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // List of modules id that must be enabled if this module is enabled |
114 | 114 | $this->depends = array(); |
115 | 115 | |
116 | - $this->conflictwith=array('modMilestone'); |
|
116 | + $this->conflictwith = array('modMilestone'); |
|
117 | 117 | // List of modules id to disable if this one is disabled |
118 | 118 | $this->requiredby = array(); |
119 | 119 | // Minimum version of PHP required by module |
@@ -178,20 +178,20 @@ discard block |
||
178 | 178 | // 'categories_x' to add a tab in category view |
179 | 179 | // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
180 | 180 | // Dictionnaries |
181 | - if (! isset($conf->subtotal->enabled)) { |
|
182 | - $conf->subtotal=new stdClass(); |
|
181 | + if (!isset($conf->subtotal->enabled)) { |
|
182 | + $conf->subtotal = new stdClass(); |
|
183 | 183 | $conf->subtotal->enabled = 0; |
184 | 184 | } |
185 | 185 | $this->dictionaries = array( |
186 | 186 | 'langs'=>'subtotal@subtotal', |
187 | - 'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor |
|
188 | - 'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables |
|
189 | - 'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields |
|
190 | - 'tabsqlsort'=>array('label ASC'), // Sort order |
|
191 | - 'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary) |
|
192 | - 'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record) |
|
193 | - 'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert) |
|
194 | - 'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid') |
|
187 | + 'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor |
|
188 | + 'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables |
|
189 | + 'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields |
|
190 | + 'tabsqlsort'=>array('label ASC'), // Sort order |
|
191 | + 'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary) |
|
192 | + 'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record) |
|
193 | + 'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert) |
|
194 | + 'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid') |
|
195 | 195 | 'tabcond'=>array($conf->subtotal->enabled) |
196 | 196 | ); |
197 | 197 | /* Example: |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @return void |
48 | 48 | */ |
49 | 49 | |
50 | - var $module_number = 104777; |
|
50 | + var $module_number = 104777; |
|
51 | 51 | |
52 | - function formObjectOptions($parameters, &$object, &$action, $hookmanager) |
|
53 | - { |
|
54 | - global $langs,$db,$user, $conf; |
|
52 | + function formObjectOptions($parameters, &$object, &$action, $hookmanager) |
|
53 | + { |
|
54 | + global $langs,$db,$user, $conf; |
|
55 | 55 | |
56 | 56 | $langs->load('subtotal@subtotal'); |
57 | 57 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $createRight = $user->rights->facture->creer; |
67 | 67 | } elseif($object->element == 'order_supplier' ) |
68 | 68 | { |
69 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
69 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
70 | 70 | } elseif($object->element == 'invoice_supplier' ) |
71 | 71 | { |
72 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
72 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($object->statut == 0 && $createRight) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
121 | 121 | |
122 | - TSubtotal::addSubTotalLine($object, $title, $qty); |
|
122 | + TSubtotal::addSubTotalLine($object, $title, $qty); |
|
123 | 123 | } |
124 | 124 | else if($action==='ask_deleteallline') { |
125 | 125 | $form=new Form($db); |
@@ -341,35 +341,35 @@ discard block |
||
341 | 341 | $TContext = explode(':',$parameters['context']); |
342 | 342 | if ( |
343 | 343 | in_array('invoicecard',$TContext) |
344 | - || in_array('invoicesuppliercard',$TContext) |
|
344 | + || in_array('invoicesuppliercard',$TContext) |
|
345 | 345 | || in_array('propalcard',$TContext) |
346 | 346 | || in_array('ordercard',$TContext) |
347 | - || in_array('ordersuppliercard',$TContext) |
|
347 | + || in_array('ordersuppliercard',$TContext) |
|
348 | 348 | || in_array('invoicereccard',$TContext) |
349 | 349 | ) |
350 | - { |
|
350 | + { |
|
351 | 351 | $hideInnerLines = isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0; |
352 | 352 | $hidedetails = isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0; |
353 | 353 | $hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0; |
354 | 354 | |
355 | 355 | $var=false; |
356 | - $out.= '<tr '.$bc[$var].'> |
|
356 | + $out.= '<tr '.$bc[$var].'> |
|
357 | 357 | <td colspan="4" align="right"> |
358 | 358 | <label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label> |
359 | 359 | <input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\') }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' /> |
360 | 360 | </td> |
361 | 361 | </tr>'; |
362 | 362 | |
363 | - $var=!$var; |
|
364 | - $out.= '<tr '.$bc[$var].'> |
|
363 | + $var=!$var; |
|
364 | + $out.= '<tr '.$bc[$var].'> |
|
365 | 365 | <td colspan="4" align="right"> |
366 | 366 | <label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label> |
367 | 367 | <input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' /> |
368 | 368 | </td> |
369 | 369 | </tr>'; |
370 | 370 | |
371 | - $var=!$var; |
|
372 | - $out.= '<tr '.$bc[$var].'> |
|
371 | + $var=!$var; |
|
372 | + $out.= '<tr '.$bc[$var].'> |
|
373 | 373 | <td colspan="4" align="right"> |
374 | 374 | <label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label> |
375 | 375 | <input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' /> |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | if ( |
382 | 382 | (in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP)) |
383 | 383 | || (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
384 | - || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
384 | + || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
385 | 385 | || (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
386 | - || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
386 | + || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
387 | 387 | || (in_array('invoicereccard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP )) |
388 | 388 | ) |
389 | 389 | { |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | |
405 | - return 1; |
|
405 | + return 1; |
|
406 | 406 | } |
407 | 407 | |
408 | - function formEditProductOptions($parameters, &$object, &$action, $hookmanager) |
|
409 | - { |
|
408 | + function formEditProductOptions($parameters, &$object, &$action, $hookmanager) |
|
409 | + { |
|
410 | 410 | |
411 | - if (in_array('invoicecard',explode(':',$parameters['context']))) |
|
412 | - { |
|
411 | + if (in_array('invoicecard',explode(':',$parameters['context']))) |
|
412 | + { |
|
413 | 413 | |
414 | - } |
|
414 | + } |
|
415 | 415 | |
416 | - return 0; |
|
417 | - } |
|
416 | + return 0; |
|
417 | + } |
|
418 | 418 | |
419 | 419 | function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) { |
420 | 420 | global $conf; |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | |
464 | 464 | if ( |
465 | 465 | in_array('invoicecard',explode(':',$parameters['context'])) |
466 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
466 | + || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
467 | 467 | || in_array('propalcard',explode(':',$parameters['context'])) |
468 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
468 | + || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
469 | 469 | || in_array('ordercard',explode(':',$parameters['context'])) |
470 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
470 | + || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
471 | 471 | || in_array('invoicereccard',explode(':',$parameters['context'])) |
472 | 472 | ) { |
473 | 473 | |
@@ -546,20 +546,20 @@ discard block |
||
546 | 546 | in_array('invoicecard',explode(':',$parameters['context'])) |
547 | 547 | || in_array('propalcard',explode(':',$parameters['context'])) |
548 | 548 | || in_array('ordercard',explode(':',$parameters['context'])) |
549 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
550 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
551 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
549 | + || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
550 | + || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
551 | + || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
552 | 552 | ) |
553 | - { |
|
553 | + { |
|
554 | 554 | if(in_array('invoicecard',explode(':',$parameters['context']))) { |
555 | 555 | $sessname = 'subtotal_hideInnerLines_facture'; |
556 | 556 | $sessname2 = 'subtotal_hidedetails_facture'; |
557 | 557 | $sessname3 = 'subtotal_hideprices_facture'; |
558 | 558 | } |
559 | 559 | elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
560 | - $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
|
561 | - $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
|
562 | - $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
|
560 | + $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
|
561 | + $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
|
562 | + $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
|
563 | 563 | } |
564 | 564 | elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
565 | 565 | $sessname = 'subtotal_hideInnerLines_propal'; |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | $sessname3 = 'subtotal_hideprices_propal'; |
568 | 568 | } |
569 | 569 | elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
570 | - $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
|
571 | - $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
|
572 | - $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
|
570 | + $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
|
571 | + $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
|
572 | + $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
|
573 | 573 | } |
574 | 574 | elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
575 | 575 | $sessname = 'subtotal_hideInnerLines_commande'; |
@@ -577,9 +577,9 @@ discard block |
||
577 | 577 | $sessname3 = 'subtotal_hideprices_commande'; |
578 | 578 | } |
579 | 579 | elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
580 | - $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
|
581 | - $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
|
582 | - $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
|
580 | + $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
|
581 | + $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
|
582 | + $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
|
583 | 583 | } |
584 | 584 | else { |
585 | 585 | $sessname = 'subtotal_hideInnerLines_unknown'; |
@@ -601,17 +601,17 @@ discard block |
||
601 | 601 | foreach($object->lines as &$line) { |
602 | 602 | if ($line->product_type == 9 && $line->special_code == $this->module_number) { |
603 | 603 | |
604 | - if($line->qty>=90) { |
|
605 | - $line->modsubtotal_total = 1; |
|
606 | - } |
|
607 | - else{ |
|
608 | - $line->modsubtotal_title = 1; |
|
609 | - } |
|
604 | + if($line->qty>=90) { |
|
605 | + $line->modsubtotal_total = 1; |
|
606 | + } |
|
607 | + else{ |
|
608 | + $line->modsubtotal_title = 1; |
|
609 | + } |
|
610 | 610 | |
611 | 611 | $line->total_ht = $this->getTotalLineFromObject($object, $line, ''); |
612 | 612 | } |
613 | - } |
|
614 | - } |
|
613 | + } |
|
614 | + } |
|
615 | 615 | |
616 | 616 | } |
617 | 617 | else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | else if($object->element=='invoice_supplier') |
630 | 630 | { |
631 | - $object->deleteline($idLine); |
|
631 | + $object->deleteline($idLine); |
|
632 | 632 | } |
633 | 633 | /** |
634 | 634 | * @var $object Propal |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | */ |
652 | 652 | else if($object->element=='order_supplier') |
653 | 653 | { |
654 | - $object->deleteline($idLine); |
|
654 | + $object->deleteline($idLine); |
|
655 | 655 | } |
656 | 656 | /** |
657 | 657 | * @var $object Facturerec |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | foreach($object->lines as $l) { |
697 | 697 | |
698 | - $lid = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
698 | + $lid = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
699 | 699 | if($lid == $lineid) { |
700 | 700 | |
701 | 701 | $found = true; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | |
705 | 705 | if($found) { |
706 | 706 | |
707 | - $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
707 | + $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); |
|
708 | 708 | |
709 | 709 | if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2)) ) { |
710 | 710 | break; // end of story |
@@ -783,17 +783,17 @@ discard block |
||
783 | 783 | if($l->rang>=$rang) { |
784 | 784 | return price($total); |
785 | 785 | } |
786 | - if (TSubtotal::isSubtotal($l)){ |
|
787 | - $total = 0; |
|
788 | - } else if ($l->situation_percent > 0 ){ |
|
786 | + if (TSubtotal::isSubtotal($l)){ |
|
787 | + $total = 0; |
|
788 | + } else if ($l->situation_percent > 0 ){ |
|
789 | 789 | |
790 | 790 | |
791 | 791 | $prev_progress = $l->get_prev_progress($object->id); |
792 | 792 | $progress = ($l->situation_percent - $prev_progress) /100; |
793 | - $total += ($l->total_ht/($l->situation_percent/100)) * $progress; |
|
793 | + $total += ($l->total_ht/($l->situation_percent/100)) * $progress; |
|
794 | 794 | |
795 | - } |
|
796 | - } |
|
795 | + } |
|
796 | + } |
|
797 | 797 | |
798 | 798 | return price($total); |
799 | 799 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | if(method_exists('Closure','bind')) { |
826 | 826 | $pageBreakOriginalValue = $pdf->AcceptPageBreak(); |
827 | 827 | $sweetsThief = function ($pdf) { |
828 | - return $pdf->bMargin ; |
|
828 | + return $pdf->bMargin ; |
|
829 | 829 | }; |
830 | 830 | $sweetsThief = Closure::bind($sweetsThief, null, $pdf); |
831 | 831 | |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | else |
889 | 889 | { |
890 | 890 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
891 | - if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
|
892 | - $total_to_print = $this->getTotalToPrintSituation($object, $line); |
|
893 | - } else { |
|
894 | - $total_to_print = price($total); |
|
895 | - } |
|
891 | + if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
|
892 | + $total_to_print = $this->getTotalToPrintSituation($object, $line); |
|
893 | + } else { |
|
894 | + $total_to_print = price($total); |
|
895 | + } |
|
896 | 896 | |
897 | 897 | $line->total_ht = $total; |
898 | 898 | $line->total = $total; |
@@ -1081,19 +1081,19 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | } |
1083 | 1083 | if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ |
1084 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1085 | - else $i = (int)$parameters; |
|
1086 | - $this->resprints = price($object->lines[$i]->total_ht); |
|
1084 | + if(is_array($parameters)) $i = & $parameters['i']; |
|
1085 | + else $i = (int)$parameters; |
|
1086 | + $this->resprints = price($object->lines[$i]->total_ht); |
|
1087 | 1087 | } |
1088 | 1088 | if (!empty($hideprices) |
1089 | - || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1090 | - ) |
|
1089 | + || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1090 | + ) |
|
1091 | 1091 | { |
1092 | - if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
1093 | - { |
|
1094 | - $this->resprints = ' '; |
|
1095 | - return 1; |
|
1096 | - } |
|
1092 | + if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
|
1093 | + { |
|
1094 | + $this->resprints = ' '; |
|
1095 | + return 1; |
|
1096 | + } |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | return 0; |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | $hidedetails = (int)GETPOST('hidedetails'); |
1374 | 1374 | |
1375 | 1375 | if ($hideInnerLines) { // si c une ligne de titre |
1376 | - $fk_parent_line=0; |
|
1376 | + $fk_parent_line=0; |
|
1377 | 1377 | $TLines =array(); |
1378 | 1378 | |
1379 | 1379 | $original_count=count($object->lines); |
1380 | - $TTvas = array(); // tableau de tva |
|
1380 | + $TTvas = array(); // tableau de tva |
|
1381 | 1381 | |
1382 | 1382 | foreach($object->lines as $k=>&$line) |
1383 | 1383 | { |
@@ -1407,48 +1407,48 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | if ($hideInnerLines) |
1409 | 1409 | { |
1410 | - if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1411 | - { |
|
1412 | - if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
1413 | - |
|
1414 | - // on remplit le tableau de tva pour substituer les lignes cachées |
|
1415 | - $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
1416 | - $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
1417 | - $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
1418 | - } |
|
1419 | - if($line->product_type==9 && $line->rowid>0) |
|
1420 | - { |
|
1421 | - //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
1422 | - // génère des lignes d'affichage des montants HT soumis à tva |
|
1423 | - $nbtva = count($TTvas); |
|
1424 | - if(!empty($nbtva)){ |
|
1425 | - foreach ($TTvas as $tx =>$val){ |
|
1426 | - $l = clone $line; |
|
1427 | - $l->product_type = 1; |
|
1428 | - $l->special_code = ''; |
|
1429 | - $l->qty = 1; |
|
1430 | - $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1431 | - $l->tva_tx = $tx; |
|
1432 | - $l->total_ht = $val['total_ht']; |
|
1433 | - $l->total_tva = $val['total_tva']; |
|
1434 | - $l->total = $line->total_ht; |
|
1435 | - $l->total_ttc = $val['total_ttc']; |
|
1436 | - $TLines[] = $l; |
|
1437 | - array_shift($TTvas); |
|
1438 | - } |
|
1439 | - } |
|
1440 | - |
|
1441 | - // ajoute la ligne de sous-total |
|
1442 | - $TLines[] = $line; |
|
1443 | - } |
|
1444 | - } else { |
|
1445 | - |
|
1446 | - if($line->product_type==9 && $line->rowid>0) |
|
1447 | - { |
|
1448 | - // ajoute la ligne de sous-total |
|
1449 | - $TLines[] = $line; |
|
1450 | - } |
|
1451 | - } |
|
1410 | + if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1411 | + { |
|
1412 | + if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
1413 | + |
|
1414 | + // on remplit le tableau de tva pour substituer les lignes cachées |
|
1415 | + $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
|
1416 | + $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
|
1417 | + $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
|
1418 | + } |
|
1419 | + if($line->product_type==9 && $line->rowid>0) |
|
1420 | + { |
|
1421 | + //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
|
1422 | + // génère des lignes d'affichage des montants HT soumis à tva |
|
1423 | + $nbtva = count($TTvas); |
|
1424 | + if(!empty($nbtva)){ |
|
1425 | + foreach ($TTvas as $tx =>$val){ |
|
1426 | + $l = clone $line; |
|
1427 | + $l->product_type = 1; |
|
1428 | + $l->special_code = ''; |
|
1429 | + $l->qty = 1; |
|
1430 | + $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1431 | + $l->tva_tx = $tx; |
|
1432 | + $l->total_ht = $val['total_ht']; |
|
1433 | + $l->total_tva = $val['total_tva']; |
|
1434 | + $l->total = $line->total_ht; |
|
1435 | + $l->total_ttc = $val['total_ttc']; |
|
1436 | + $TLines[] = $l; |
|
1437 | + array_shift($TTvas); |
|
1438 | + } |
|
1439 | + } |
|
1440 | + |
|
1441 | + // ajoute la ligne de sous-total |
|
1442 | + $TLines[] = $line; |
|
1443 | + } |
|
1444 | + } else { |
|
1445 | + |
|
1446 | + if($line->product_type==9 && $line->rowid>0) |
|
1447 | + { |
|
1448 | + // ajoute la ligne de sous-total |
|
1449 | + $TLines[] = $line; |
|
1450 | + } |
|
1451 | + } |
|
1452 | 1452 | |
1453 | 1453 | |
1454 | 1454 | } |
@@ -1473,20 +1473,20 @@ discard block |
||
1473 | 1473 | $nbtva = count($TTvas); |
1474 | 1474 | if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
1475 | 1475 | { |
1476 | - foreach ($TTvas as $tx =>$val){ |
|
1477 | - $l = clone $line; |
|
1478 | - $l->product_type = 1; |
|
1479 | - $l->special_code = ''; |
|
1480 | - $l->qty = 1; |
|
1481 | - $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1482 | - $l->tva_tx = $tx; |
|
1483 | - $l->total_ht = $val['total_ht']; |
|
1484 | - $l->total_tva = $val['total_tva']; |
|
1485 | - $l->total = $line->total_ht; |
|
1486 | - $l->total_ttc = $val['total_ttc']; |
|
1487 | - $TLines[] = $l; |
|
1488 | - array_shift($TTvas); |
|
1489 | - } |
|
1476 | + foreach ($TTvas as $tx =>$val){ |
|
1477 | + $l = clone $line; |
|
1478 | + $l->product_type = 1; |
|
1479 | + $l->special_code = ''; |
|
1480 | + $l->qty = 1; |
|
1481 | + $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1482 | + $l->tva_tx = $tx; |
|
1483 | + $l->total_ht = $val['total_ht']; |
|
1484 | + $l->total_tva = $val['total_tva']; |
|
1485 | + $l->total = $line->total_ht; |
|
1486 | + $l->total_ttc = $val['total_ttc']; |
|
1487 | + $TLines[] = $l; |
|
1488 | + array_shift($TTvas); |
|
1489 | + } |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | global $nblignes; |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | $this->resprints = ''; |
1499 | 1499 | return 0; |
1500 | 1500 | } |
1501 | - } |
|
1501 | + } |
|
1502 | 1502 | |
1503 | 1503 | return 0; |
1504 | 1504 | } |
@@ -1661,18 +1661,18 @@ discard block |
||
1661 | 1661 | } |
1662 | 1662 | elseif($object->element == 'order_supplier' ) |
1663 | 1663 | { |
1664 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
1664 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
1665 | 1665 | } |
1666 | 1666 | elseif($object->element == 'invoice_supplier' ) |
1667 | 1667 | { |
1668 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
1668 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1672 | 1672 | null; |
1673 | 1673 | } |
1674 | 1674 | else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
1675 | - { |
|
1675 | + { |
|
1676 | 1676 | if($object->element=='facture')$idvar = 'facid'; |
1677 | 1677 | else $idvar='id'; |
1678 | 1678 | |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | //var_dump($line); |
1720 | 1720 | |
1721 | 1721 | // HTML 5 data for js |
1722 | - $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
1722 | + $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager); |
|
1723 | 1723 | |
1724 | 1724 | |
1725 | 1725 | ?> |
@@ -1777,8 +1777,8 @@ discard block |
||
1777 | 1777 | } |
1778 | 1778 | |
1779 | 1779 | if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') { |
1780 | - $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
1781 | - $line->description = ''; |
|
1780 | + $line->label = !empty($line->description) ? $line->description : $line->desc; |
|
1781 | + $line->description = ''; |
|
1782 | 1782 | } |
1783 | 1783 | $newlabel = $line->label; |
1784 | 1784 | if($line->label=='' && !$isFreeText) { |
@@ -2157,80 +2157,80 @@ discard block |
||
2157 | 2157 | { |
2158 | 2158 | dol_include_once('/subtotal/class/subtotal.class.php'); |
2159 | 2159 | |
2160 | - $line = &$parameters['line']; |
|
2160 | + $line = &$parameters['line']; |
|
2161 | 2161 | |
2162 | - $ThtmlData['data-id'] = $line->id; |
|
2163 | - $ThtmlData['data-product_type'] = $line->product_type; |
|
2164 | - $ThtmlData['data-qty'] = 0; //$line->qty; |
|
2165 | - $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
2162 | + $ThtmlData['data-id'] = $line->id; |
|
2163 | + $ThtmlData['data-product_type'] = $line->product_type; |
|
2164 | + $ThtmlData['data-qty'] = 0; //$line->qty; |
|
2165 | + $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
|
2166 | 2166 | |
2167 | - if(TSubtotal::isTitle($line)){ |
|
2168 | - $ThtmlData['data-issubtotal'] = 'title'; |
|
2169 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2170 | - $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
2171 | - } |
|
2172 | - else{ |
|
2173 | - $ThtmlData['data-issubtotal'] = 'freetext'; |
|
2174 | - } |
|
2167 | + if(TSubtotal::isTitle($line)){ |
|
2168 | + $ThtmlData['data-issubtotal'] = 'title'; |
|
2169 | + }elseif(TSubtotal::isSubtotal($line)){ |
|
2170 | + $ThtmlData['data-issubtotal'] = 'subtotal'; |
|
2171 | + } |
|
2172 | + else{ |
|
2173 | + $ThtmlData['data-issubtotal'] = 'freetext'; |
|
2174 | + } |
|
2175 | 2175 | |
2176 | 2176 | |
2177 | - // Change or add data from hooks |
|
2178 | - $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
2177 | + // Change or add data from hooks |
|
2178 | + $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
2179 | 2179 | |
2180 | - // hook |
|
2181 | - $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
2182 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2183 | - if ($reshook>0) |
|
2184 | - { |
|
2185 | - $ThtmlData = $hookmanager->resArray; |
|
2186 | - } |
|
2180 | + // hook |
|
2181 | + $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
2182 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2183 | + if ($reshook>0) |
|
2184 | + { |
|
2185 | + $ThtmlData = $hookmanager->resArray; |
|
2186 | + } |
|
2187 | 2187 | |
2188 | - return $this->implodeHtmlData($ThtmlData); |
|
2188 | + return $this->implodeHtmlData($ThtmlData); |
|
2189 | 2189 | |
2190 | 2190 | } |
2191 | 2191 | |
2192 | 2192 | |
2193 | 2193 | function implodeHtmlData($ThtmlData = array()) |
2194 | 2194 | { |
2195 | - $data = ''; |
|
2196 | - foreach($ThtmlData as $k => $h ) |
|
2197 | - { |
|
2198 | - if(is_array($h)) |
|
2199 | - { |
|
2200 | - $h = json_encode($h); |
|
2201 | - } |
|
2202 | - |
|
2203 | - $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2204 | - } |
|
2205 | - |
|
2206 | - return $data; |
|
2195 | + $data = ''; |
|
2196 | + foreach($ThtmlData as $k => $h ) |
|
2197 | + { |
|
2198 | + if(is_array($h)) |
|
2199 | + { |
|
2200 | + $h = json_encode($h); |
|
2201 | + } |
|
2202 | + |
|
2203 | + $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2204 | + } |
|
2205 | + |
|
2206 | + return $data; |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | function _ajax_block_order_js($object) |
2210 | 2210 | { |
2211 | - global $conf,$tagidfortablednd,$filepath,$langs; |
|
2211 | + global $conf,$tagidfortablednd,$filepath,$langs; |
|
2212 | 2212 | |
2213 | - /* |
|
2213 | + /* |
|
2214 | 2214 | * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php |
2215 | 2215 | * for compatibility reasons we don't use tableDnD but jquery sortable |
2216 | 2216 | */ |
2217 | 2217 | |
2218 | - $id=$object->id; |
|
2219 | - $nboflines=(isset($object->lines)?count($object->lines):0); |
|
2220 | - $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
2218 | + $id=$object->id; |
|
2219 | + $nboflines=(isset($object->lines)?count($object->lines):0); |
|
2220 | + $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
2221 | 2221 | |
2222 | - $id=$object->id; |
|
2223 | - $fk_element=$object->fk_element; |
|
2224 | - $table_element_line=$object->table_element_line; |
|
2225 | - $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
2226 | - $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
2227 | - $filepath=(empty($filepath)?'':$filepath); |
|
2222 | + $id=$object->id; |
|
2223 | + $fk_element=$object->fk_element; |
|
2224 | + $table_element_line=$object->table_element_line; |
|
2225 | + $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
2226 | + $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
2227 | + $filepath=(empty($filepath)?'':$filepath); |
|
2228 | 2228 | |
2229 | 2229 | |
2230 | - if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
2231 | - { |
|
2230 | + if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
2231 | + { |
|
2232 | 2232 | |
2233 | - ?> |
|
2233 | + ?> |
|
2234 | 2234 | |
2235 | 2235 | |
2236 | 2236 | <script type="text/javascript"> |
@@ -51,43 +51,43 @@ discard block |
||
51 | 51 | |
52 | 52 | function formObjectOptions($parameters, &$object, &$action, $hookmanager) |
53 | 53 | { |
54 | - global $langs,$db,$user, $conf; |
|
54 | + global $langs, $db, $user, $conf; |
|
55 | 55 | |
56 | 56 | $langs->load('subtotal@subtotal'); |
57 | 57 | |
58 | - $contexts = explode(':',$parameters['context']); |
|
58 | + $contexts = explode(':', $parameters['context']); |
|
59 | 59 | |
60 | - if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts)) { |
|
60 | + if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts)) { |
|
61 | 61 | |
62 | 62 | $createRight = $user->rights->{$object->element}->creer; |
63 | - if($object->element == 'facturerec' ) |
|
63 | + if ($object->element == 'facturerec') |
|
64 | 64 | { |
65 | 65 | $object->statut = 0; // hack for facture rec |
66 | 66 | $createRight = $user->rights->facture->creer; |
67 | - } elseif($object->element == 'order_supplier' ) |
|
67 | + } elseif ($object->element == 'order_supplier') |
|
68 | 68 | { |
69 | 69 | $createRight = $user->rights->fournisseur->commande->creer; |
70 | - } elseif($object->element == 'invoice_supplier' ) |
|
70 | + } elseif ($object->element == 'invoice_supplier') |
|
71 | 71 | { |
72 | 72 | $createRight = $user->rights->fournisseur->facture->creer; |
73 | 73 | } |
74 | 74 | |
75 | - if ($object->statut == 0 && $createRight) { |
|
75 | + if ($object->statut == 0 && $createRight) { |
|
76 | 76 | |
77 | 77 | |
78 | - if($object->element=='facture')$idvar = 'facid'; |
|
79 | - else $idvar='id'; |
|
78 | + if ($object->element == 'facture')$idvar = 'facid'; |
|
79 | + else $idvar = 'id'; |
|
80 | 80 | |
81 | - if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) |
|
81 | + if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text'))) |
|
82 | 82 | { |
83 | 83 | $level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT |
84 | 84 | |
85 | - if($action=='add_title_line') { |
|
85 | + if ($action == 'add_title_line') { |
|
86 | 86 | $title = GETPOST('title'); |
87 | - if(empty($title)) $title = $langs->trans('title'); |
|
88 | - $qty = $level<1 ? 1 : $level ; |
|
87 | + if (empty($title)) $title = $langs->trans('title'); |
|
88 | + $qty = $level < 1 ? 1 : $level; |
|
89 | 89 | } |
90 | - else if($action=='add_free_text') { |
|
90 | + else if ($action == 'add_free_text') { |
|
91 | 91 | $title = GETPOST('title'); |
92 | 92 | |
93 | 93 | if (empty($title)) { |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | - if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
102 | + if (empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
103 | 103 | $qty = 50; |
104 | 104 | } |
105 | - else if($action=='add_subtitle_line') { |
|
105 | + else if ($action == 'add_subtitle_line') { |
|
106 | 106 | $title = GETPOST('title'); |
107 | - if(empty($title)) $title = $langs->trans('subtitle'); |
|
107 | + if (empty($title)) $title = $langs->trans('subtitle'); |
|
108 | 108 | $qty = 2; |
109 | 109 | } |
110 | - else if($action=='add_subtotal_line') { |
|
110 | + else if ($action == 'add_subtotal_line') { |
|
111 | 111 | $title = $langs->trans('SubSubTotal'); |
112 | 112 | $qty = 98; |
113 | 113 | } |
114 | 114 | else { |
115 | 115 | $title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); |
116 | - $qty = $level ? 100-$level : 99; |
|
116 | + $qty = $level ? 100 - $level : 99; |
|
117 | 117 | } |
118 | 118 | dol_include_once('/subtotal/class/subtotal.class.php'); |
119 | 119 | |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | |
122 | 122 | TSubtotal::addSubTotalLine($object, $title, $qty); |
123 | 123 | } |
124 | - else if($action==='ask_deleteallline') { |
|
125 | - $form=new Form($db); |
|
124 | + else if ($action === 'ask_deleteallline') { |
|
125 | + $form = new Form($db); |
|
126 | 126 | |
127 | - $lineid = GETPOST('lineid','integer'); |
|
127 | + $lineid = GETPOST('lineid', 'integer'); |
|
128 | 128 | $TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid); |
129 | 129 | |
130 | 130 | $nbLines = count($TIdForGroup); |
131 | 131 | |
132 | - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1); |
|
132 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1); |
|
133 | 133 | print $formconfirm; |
134 | 134 | } |
135 | 135 | |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | - if($action!='editline') { |
|
142 | + if ($action != 'editline') { |
|
143 | 143 | // New format is for 3.8 |
144 | 144 | $this->printNewFormat($object, $conf, $langs, $idvar); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | - elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
148 | + elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts)) |
|
149 | 149 | { |
150 | 150 | ?> |
151 | 151 | <script type="text/javascript"> |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $(document).ready(function() { |
171 | 171 | $('div.fiche div.tabsAction').append('<br />'); |
172 | 172 | |
173 | - $('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo $langs->trans('AddTitle' )?></a></div>'); |
|
173 | + $('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo $langs->trans('AddTitle')?></a></div>'); |
|
174 | 174 | $('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo $langs->trans('AddSubTotal')?></a></div>'); |
175 | 175 | $('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo $langs->trans('AddFreeText')?></a></div>'); |
176 | 176 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | $('body').append(dialog_html); |
222 | 222 | |
223 | 223 | <?php |
224 | - $editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME; |
|
225 | - $editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS; |
|
226 | - if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ |
|
224 | + $editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME; |
|
225 | + $editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS; |
|
226 | + if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { |
|
227 | 227 | ?> |
228 | 228 | if (action == 'addTitle' || action == 'addFreeTxt') |
229 | 229 | { |
@@ -338,61 +338,61 @@ discard block |
||
338 | 338 | global $conf, $langs, $bc; |
339 | 339 | |
340 | 340 | $action = GETPOST('action'); |
341 | - $TContext = explode(':',$parameters['context']); |
|
341 | + $TContext = explode(':', $parameters['context']); |
|
342 | 342 | if ( |
343 | - in_array('invoicecard',$TContext) |
|
344 | - || in_array('invoicesuppliercard',$TContext) |
|
345 | - || in_array('propalcard',$TContext) |
|
346 | - || in_array('ordercard',$TContext) |
|
347 | - || in_array('ordersuppliercard',$TContext) |
|
348 | - || in_array('invoicereccard',$TContext) |
|
343 | + in_array('invoicecard', $TContext) |
|
344 | + || in_array('invoicesuppliercard', $TContext) |
|
345 | + || in_array('propalcard', $TContext) |
|
346 | + || in_array('ordercard', $TContext) |
|
347 | + || in_array('ordersuppliercard', $TContext) |
|
348 | + || in_array('invoicereccard', $TContext) |
|
349 | 349 | ) |
350 | 350 | { |
351 | - $hideInnerLines = isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0; |
|
352 | - $hidedetails = isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0; |
|
353 | - $hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0; |
|
351 | + $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0; |
|
352 | + $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0; |
|
353 | + $hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0; |
|
354 | 354 | |
355 | - $var=false; |
|
356 | - $out.= '<tr '.$bc[$var].'> |
|
355 | + $var = false; |
|
356 | + $out .= '<tr '.$bc[$var].'> |
|
357 | 357 | <td colspan="4" align="right"> |
358 | 358 | <label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label> |
359 | - <input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\') }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' /> |
|
359 | + <input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\') }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' /> |
|
360 | 360 | </td> |
361 | 361 | </tr>'; |
362 | 362 | |
363 | - $var=!$var; |
|
364 | - $out.= '<tr '.$bc[$var].'> |
|
363 | + $var = !$var; |
|
364 | + $out .= '<tr '.$bc[$var].'> |
|
365 | 365 | <td colspan="4" align="right"> |
366 | 366 | <label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label> |
367 | - <input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' /> |
|
367 | + <input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' /> |
|
368 | 368 | </td> |
369 | 369 | </tr>'; |
370 | 370 | |
371 | - $var=!$var; |
|
372 | - $out.= '<tr '.$bc[$var].'> |
|
371 | + $var = !$var; |
|
372 | + $out .= '<tr '.$bc[$var].'> |
|
373 | 373 | <td colspan="4" align="right"> |
374 | 374 | <label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label> |
375 | - <input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' /> |
|
375 | + <input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' /> |
|
376 | 376 | </td> |
377 | 377 | </tr>'; |
378 | 378 | |
379 | 379 | |
380 | 380 | |
381 | 381 | if ( |
382 | - (in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP)) |
|
383 | - || (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
384 | - || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
385 | - || (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
386 | - || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
387 | - || (in_array('invoicereccard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP )) |
|
382 | + (in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP)) |
|
383 | + || (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
384 | + || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP)) |
|
385 | + || (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
386 | + || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
387 | + || (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP)) |
|
388 | 388 | ) |
389 | 389 | { |
390 | - $var=!$var; |
|
391 | - $out.= ' |
|
390 | + $var = !$var; |
|
391 | + $out .= ' |
|
392 | 392 | <tr '.$bc[$var].'> |
393 | 393 | <td colspan="4" align="right"> |
394 | 394 | <label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label> |
395 | - <input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' /> |
|
395 | + <input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' /> |
|
396 | 396 | </td> |
397 | 397 | </tr>'; |
398 | 398 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | function formEditProductOptions($parameters, &$object, &$action, $hookmanager) |
409 | 409 | { |
410 | 410 | |
411 | - if (in_array('invoicecard',explode(':',$parameters['context']))) |
|
411 | + if (in_array('invoicecard', explode(':', $parameters['context']))) |
|
412 | 412 | { |
413 | 413 | |
414 | 414 | } |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) { |
420 | 420 | global $conf; |
421 | 421 | |
422 | - if($action === 'builddoc') { |
|
422 | + if ($action === 'builddoc') { |
|
423 | 423 | |
424 | 424 | $line = &$parameters['line']; |
425 | 425 | $object = &$parameters['object']; |
426 | 426 | $substitutionarray = &$parameters['substitutionarray']; |
427 | 427 | |
428 | - if($line->product_type == 9 && $line->special_code == $this->module_number) { |
|
428 | + if ($line->product_type == 9 && $line->special_code == $this->module_number) { |
|
429 | 429 | $substitutionarray['line_modsubtotal'] = 1; |
430 | 430 | |
431 | 431 | $substitutionarray['line_price_ht'] |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | = $substitutionarray['line_up'] |
437 | 437 | = ''; |
438 | 438 | |
439 | - if($line->qty>90) { |
|
439 | + if ($line->qty > 90) { |
|
440 | 440 | $substitutionarray['line_modsubtotal_total'] = true; |
441 | 441 | |
442 | 442 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | |
451 | 451 | |
452 | 452 | } |
453 | - else{ |
|
453 | + else { |
|
454 | 454 | $substitutionarray['line_not_modsubtotal'] = true; |
455 | 455 | $substitutionarray['line_modsubtotal'] = 0; |
456 | 456 | } |
@@ -462,29 +462,29 @@ discard block |
||
462 | 462 | function createFrom($parameters, &$object, $action, $hookmanager) { |
463 | 463 | |
464 | 464 | if ( |
465 | - in_array('invoicecard',explode(':',$parameters['context'])) |
|
466 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
467 | - || in_array('propalcard',explode(':',$parameters['context'])) |
|
468 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
469 | - || in_array('ordercard',explode(':',$parameters['context'])) |
|
470 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
471 | - || in_array('invoicereccard',explode(':',$parameters['context'])) |
|
465 | + in_array('invoicecard', explode(':', $parameters['context'])) |
|
466 | + || in_array('invoicesuppliercard', explode(':', $parameters['context'])) |
|
467 | + || in_array('propalcard', explode(':', $parameters['context'])) |
|
468 | + || in_array('supplier_proposalcard', explode(':', $parameters['context'])) |
|
469 | + || in_array('ordercard', explode(':', $parameters['context'])) |
|
470 | + || in_array('ordersuppliercard', explode(':', $parameters['context'])) |
|
471 | + || in_array('invoicereccard', explode(':', $parameters['context'])) |
|
472 | 472 | ) { |
473 | 473 | |
474 | 474 | global $db; |
475 | 475 | |
476 | 476 | $objFrom = $parameters['objFrom']; |
477 | 477 | |
478 | - foreach($objFrom->lines as $k=> &$lineOld) { |
|
478 | + foreach ($objFrom->lines as $k=> &$lineOld) { |
|
479 | 479 | |
480 | - if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) { |
|
480 | + if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) { |
|
481 | 481 | |
482 | 482 | $line = & $object->lines[$k]; |
483 | 483 | |
484 | 484 | $idLine = (int) ($line->id ? $line->id : $line->rowid); |
485 | 485 | |
486 | 486 | $db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element." |
487 | - SET info_bits=".(int)$lineOld->info_bits." |
|
487 | + SET info_bits=".(int) $lineOld->info_bits." |
|
488 | 488 | WHERE rowid = ".$idLine." |
489 | 489 | "); |
490 | 490 | |
@@ -500,15 +500,15 @@ discard block |
||
500 | 500 | |
501 | 501 | function doActions($parameters, &$object, $action, $hookmanager) |
502 | 502 | { |
503 | - global $db, $conf, $langs,$user; |
|
503 | + global $db, $conf, $langs, $user; |
|
504 | 504 | |
505 | 505 | dol_include_once('/subtotal/class/subtotal.class.php'); |
506 | 506 | dol_include_once('/subtotal/lib/subtotal.lib.php'); |
507 | - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
507 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
508 | 508 | |
509 | 509 | $showBlockExtrafields = GETPOST('showBlockExtrafields'); |
510 | 510 | |
511 | - if($object->element=='facture') $idvar = 'facid'; |
|
511 | + if ($object->element == 'facture') $idvar = 'facid'; |
|
512 | 512 | else $idvar = 'id'; |
513 | 513 | |
514 | 514 | if ($action == 'updateligne' || $action == 'updateline') |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line)) |
522 | 522 | { |
523 | 523 | $found = true; |
524 | - if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) { |
|
524 | + if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) { |
|
525 | 525 | $extrafieldsline = new ExtraFields($db); |
526 | 526 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
527 | 527 | $extrafieldsline->setOptionalsFromPost($extralabelsline, $line); |
@@ -540,43 +540,43 @@ discard block |
||
540 | 540 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne |
541 | 541 | } |
542 | 542 | } |
543 | - else if($action === 'builddoc') { |
|
543 | + else if ($action === 'builddoc') { |
|
544 | 544 | |
545 | 545 | if ( |
546 | - in_array('invoicecard',explode(':',$parameters['context'])) |
|
547 | - || in_array('propalcard',explode(':',$parameters['context'])) |
|
548 | - || in_array('ordercard',explode(':',$parameters['context'])) |
|
549 | - || in_array('ordersuppliercard',explode(':',$parameters['context'])) |
|
550 | - || in_array('invoicesuppliercard',explode(':',$parameters['context'])) |
|
551 | - || in_array('supplier_proposalcard',explode(':',$parameters['context'])) |
|
546 | + in_array('invoicecard', explode(':', $parameters['context'])) |
|
547 | + || in_array('propalcard', explode(':', $parameters['context'])) |
|
548 | + || in_array('ordercard', explode(':', $parameters['context'])) |
|
549 | + || in_array('ordersuppliercard', explode(':', $parameters['context'])) |
|
550 | + || in_array('invoicesuppliercard', explode(':', $parameters['context'])) |
|
551 | + || in_array('supplier_proposalcard', explode(':', $parameters['context'])) |
|
552 | 552 | ) |
553 | 553 | { |
554 | - if(in_array('invoicecard',explode(':',$parameters['context']))) { |
|
554 | + if (in_array('invoicecard', explode(':', $parameters['context']))) { |
|
555 | 555 | $sessname = 'subtotal_hideInnerLines_facture'; |
556 | 556 | $sessname2 = 'subtotal_hidedetails_facture'; |
557 | 557 | $sessname3 = 'subtotal_hideprices_facture'; |
558 | 558 | } |
559 | - elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
559 | + elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) { |
|
560 | 560 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
561 | 561 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
562 | 562 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
563 | 563 | } |
564 | - elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
564 | + elseif (in_array('propalcard', explode(':', $parameters['context']))) { |
|
565 | 565 | $sessname = 'subtotal_hideInnerLines_propal'; |
566 | 566 | $sessname2 = 'subtotal_hidedetails_propal'; |
567 | 567 | $sessname3 = 'subtotal_hideprices_propal'; |
568 | 568 | } |
569 | - elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
569 | + elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) { |
|
570 | 570 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
571 | 571 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
572 | 572 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
573 | 573 | } |
574 | - elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
574 | + elseif (in_array('ordercard', explode(':', $parameters['context']))) { |
|
575 | 575 | $sessname = 'subtotal_hideInnerLines_commande'; |
576 | 576 | $sessname2 = 'subtotal_hidedetails_commande'; |
577 | 577 | $sessname3 = 'subtotal_hideprices_commande'; |
578 | 578 | } |
579 | - elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
579 | + elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) { |
|
580 | 580 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
581 | 581 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
582 | 582 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
@@ -589,22 +589,22 @@ discard block |
||
589 | 589 | |
590 | 590 | global $hideprices; |
591 | 591 | |
592 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
592 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
593 | 593 | $_SESSION[$sessname] = $hideInnerLines; |
594 | 594 | |
595 | - $hidedetails= (int)GETPOST('hidedetails'); |
|
595 | + $hidedetails = (int) GETPOST('hidedetails'); |
|
596 | 596 | $_SESSION[$sessname2] = $hidedetails; |
597 | 597 | |
598 | - $hideprices= (int)GETPOST('hideprices'); |
|
598 | + $hideprices = (int) GETPOST('hideprices'); |
|
599 | 599 | $_SESSION[$sessname3] = $hideprices; |
600 | 600 | |
601 | - foreach($object->lines as &$line) { |
|
601 | + foreach ($object->lines as &$line) { |
|
602 | 602 | if ($line->product_type == 9 && $line->special_code == $this->module_number) { |
603 | 603 | |
604 | - if($line->qty>=90) { |
|
604 | + if ($line->qty >= 90) { |
|
605 | 605 | $line->modsubtotal_total = 1; |
606 | 606 | } |
607 | - else{ |
|
607 | + else { |
|
608 | 608 | $line->modsubtotal_title = 1; |
609 | 609 | } |
610 | 610 | |
@@ -614,34 +614,34 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | } |
617 | - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
617 | + else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') { |
|
618 | 618 | |
619 | 619 | $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); |
620 | 620 | |
621 | - foreach($Tab as $idLine) { |
|
621 | + foreach ($Tab as $idLine) { |
|
622 | 622 | /** |
623 | 623 | * @var $object Facture |
624 | 624 | */ |
625 | - if($object->element=='facture') $object->deleteline($idLine); |
|
625 | + if ($object->element == 'facture') $object->deleteline($idLine); |
|
626 | 626 | /** |
627 | 627 | * @var $object Facture fournisseur |
628 | 628 | */ |
629 | - else if($object->element=='invoice_supplier') |
|
629 | + else if ($object->element == 'invoice_supplier') |
|
630 | 630 | { |
631 | 631 | $object->deleteline($idLine); |
632 | 632 | } |
633 | 633 | /** |
634 | 634 | * @var $object Propal |
635 | 635 | */ |
636 | - else if($object->element=='propal') $object->deleteline($idLine); |
|
636 | + else if ($object->element == 'propal') $object->deleteline($idLine); |
|
637 | 637 | /** |
638 | 638 | * @var $object Propal Fournisseur |
639 | 639 | */ |
640 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); |
|
640 | + else if ($object->element == 'supplier_proposal') $object->deleteline($idLine); |
|
641 | 641 | /** |
642 | 642 | * @var $object Commande |
643 | 643 | */ |
644 | - else if($object->element=='commande') |
|
644 | + else if ($object->element == 'commande') |
|
645 | 645 | { |
646 | 646 | if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); |
647 | 647 | else $object->deleteline($idLine); |
@@ -649,14 +649,14 @@ discard block |
||
649 | 649 | /** |
650 | 650 | * @var $object Commande fournisseur |
651 | 651 | */ |
652 | - else if($object->element=='order_supplier') |
|
652 | + else if ($object->element == 'order_supplier') |
|
653 | 653 | { |
654 | 654 | $object->deleteline($idLine); |
655 | 655 | } |
656 | 656 | /** |
657 | 657 | * @var $object Facturerec |
658 | 658 | */ |
659 | - else if($object->element=='facturerec') $object->deleteline($idLine); |
|
659 | + else if ($object->element == 'facturerec') $object->deleteline($idLine); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | header('location:?id='.$object->id); |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | return 0; |
680 | 680 | } |
681 | 681 | |
682 | - function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) { |
|
682 | + function formAddObjectLine($parameters, &$object, &$action, $hookmanager) { |
|
683 | 683 | return 0; |
684 | 684 | } |
685 | 685 | |
@@ -691,22 +691,22 @@ discard block |
||
691 | 691 | |
692 | 692 | $found = false; |
693 | 693 | |
694 | - $Tab= array(); |
|
694 | + $Tab = array(); |
|
695 | 695 | |
696 | - foreach($object->lines as $l) { |
|
696 | + foreach ($object->lines as $l) { |
|
697 | 697 | |
698 | 698 | $lid = (!empty($l->rowid) ? $l->rowid : $l->id); |
699 | - if($lid == $lineid) { |
|
699 | + if ($lid == $lineid) { |
|
700 | 700 | |
701 | 701 | $found = true; |
702 | 702 | $qty_line = $l->qty; |
703 | 703 | } |
704 | 704 | |
705 | - if($found) { |
|
705 | + if ($found) { |
|
706 | 706 | |
707 | 707 | $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id); |
708 | 708 | |
709 | - if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2)) ) { |
|
709 | + if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) { |
|
710 | 710 | break; // end of story |
711 | 711 | } |
712 | 712 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @param $use_level isn't used anymore |
737 | 737 | */ |
738 | - function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) { |
|
738 | + function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) { |
|
739 | 739 | |
740 | 740 | $rang = $line->rang; |
741 | 741 | $qty_line = $line->qty; |
@@ -746,21 +746,21 @@ discard block |
||
746 | 746 | $TTotal_tva = array(); |
747 | 747 | |
748 | 748 | dol_include_once('/subtotal/class/subtotal.class.php'); |
749 | - foreach($object->lines as $l) { |
|
749 | + foreach ($object->lines as $l) { |
|
750 | 750 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; |
751 | - if($l->rang>=$rang) { |
|
751 | + if ($l->rang >= $rang) { |
|
752 | 752 | //echo 'return!<br>'; |
753 | 753 | if (!$return_all) return $total; |
754 | 754 | else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
755 | 755 | } |
756 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
756 | + else if (TSubtotal::isTitle($l, 100 - $qty_line)) |
|
757 | 757 | { |
758 | 758 | $total = 0; |
759 | 759 | $total_tva = 0; |
760 | 760 | $total_ttc = 0; |
761 | 761 | $TTotal_tva = array(); |
762 | 762 | } |
763 | - elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
763 | + elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
764 | 764 | $total += $l->total_ht; |
765 | 765 | $total_tva += $l->total_tva; |
766 | 766 | $TTotal_tva[$l->tva_tx] += $l->total_tva; |
@@ -779,18 +779,18 @@ discard block |
||
779 | 779 | |
780 | 780 | $rang = $line->rang; |
781 | 781 | $total = 0; |
782 | - foreach($object->lines as $l) { |
|
783 | - if($l->rang>=$rang) { |
|
782 | + foreach ($object->lines as $l) { |
|
783 | + if ($l->rang >= $rang) { |
|
784 | 784 | return price($total); |
785 | 785 | } |
786 | - if (TSubtotal::isSubtotal($l)){ |
|
786 | + if (TSubtotal::isSubtotal($l)) { |
|
787 | 787 | $total = 0; |
788 | - } else if ($l->situation_percent > 0 ){ |
|
788 | + } else if ($l->situation_percent > 0) { |
|
789 | 789 | |
790 | 790 | |
791 | 791 | $prev_progress = $l->get_prev_progress($object->id); |
792 | - $progress = ($l->situation_percent - $prev_progress) /100; |
|
793 | - $total += ($l->total_ht/($l->situation_percent/100)) * $progress; |
|
792 | + $progress = ($l->situation_percent - $prev_progress) / 100; |
|
793 | + $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress; |
|
794 | 794 | |
795 | 795 | } |
796 | 796 | } |
@@ -809,10 +809,10 @@ discard block |
||
809 | 809 | * @param $w float width |
810 | 810 | * @param $h float height |
811 | 811 | */ |
812 | - function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { |
|
813 | - global $conf,$subtotal_last_title_posy; |
|
812 | + function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) { |
|
813 | + global $conf, $subtotal_last_title_posy; |
|
814 | 814 | |
815 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
815 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
816 | 816 | if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy)) |
817 | 817 | { |
818 | 818 | $posy = $subtotal_last_title_posy; |
@@ -822,34 +822,34 @@ discard block |
||
822 | 822 | $hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines'); |
823 | 823 | |
824 | 824 | $set_pagebreak_margin = false; |
825 | - if(method_exists('Closure','bind')) { |
|
825 | + if (method_exists('Closure', 'bind')) { |
|
826 | 826 | $pageBreakOriginalValue = $pdf->AcceptPageBreak(); |
827 | - $sweetsThief = function ($pdf) { |
|
828 | - return $pdf->bMargin ; |
|
827 | + $sweetsThief = function($pdf) { |
|
828 | + return $pdf->bMargin; |
|
829 | 829 | }; |
830 | 830 | $sweetsThief = Closure::bind($sweetsThief, null, $pdf); |
831 | 831 | |
832 | - $bMargin = $sweetsThief($pdf); |
|
832 | + $bMargin = $sweetsThief($pdf); |
|
833 | 833 | |
834 | - $pdf->SetAutoPageBreak( false ); |
|
834 | + $pdf->SetAutoPageBreak(false); |
|
835 | 835 | |
836 | 836 | $set_pagebreak_margin = true; |
837 | 837 | } |
838 | 838 | |
839 | 839 | |
840 | - if($line->qty==99) |
|
841 | - $pdf->SetFillColor(220,220,220); |
|
842 | - elseif ($line->qty==98) |
|
843 | - $pdf->SetFillColor(230,230,230); |
|
840 | + if ($line->qty == 99) |
|
841 | + $pdf->SetFillColor(220, 220, 220); |
|
842 | + elseif ($line->qty == 98) |
|
843 | + $pdf->SetFillColor(230, 230, 230); |
|
844 | 844 | else |
845 | - $pdf->SetFillColor(240,240,240); |
|
845 | + $pdf->SetFillColor(240, 240, 240); |
|
846 | 846 | |
847 | 847 | $style = 'B'; |
848 | 848 | if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
849 | 849 | |
850 | 850 | $pdf->SetFont('', $style, 9); |
851 | 851 | |
852 | - $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true); |
|
852 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true); |
|
853 | 853 | // var_dump($bMargin); |
854 | 854 | $pageAfter = $pdf->getPage(); |
855 | 855 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
877 | - if($total_to_print) { |
|
877 | + if ($total_to_print) { |
|
878 | 878 | |
879 | 879 | if (GETPOST('hideInnerLines')) |
880 | 880 | { |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | else |
889 | 889 | { |
890 | 890 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
891 | - if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
|
891 | + if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation |
|
892 | 892 | $total_to_print = $this->getTotalToPrintSituation($object, $line); |
893 | 893 | } else { |
894 | 894 | $total_to_print = price($total); |
@@ -902,11 +902,11 @@ discard block |
||
902 | 902 | } |
903 | 903 | |
904 | 904 | $pdf->SetXY($pdf->postotalht, $posy); |
905 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
906 | - $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
|
905 | + if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin); |
|
906 | + $pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
|
907 | 907 | } |
908 | - else{ |
|
909 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
908 | + else { |
|
909 | + if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | $posy = $posy + $cell_height; |
@@ -926,22 +926,22 @@ discard block |
||
926 | 926 | * @param $w float width |
927 | 927 | * @param $h float height |
928 | 928 | */ |
929 | - function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) { |
|
929 | + function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) { |
|
930 | 930 | |
931 | - global $db,$conf,$subtotal_last_title_posy; |
|
931 | + global $db, $conf, $subtotal_last_title_posy; |
|
932 | 932 | |
933 | 933 | $subtotal_last_title_posy = $posy; |
934 | - $pdf->SetXY ($posx, $posy); |
|
934 | + $pdf->SetXY($posx, $posy); |
|
935 | 935 | |
936 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
936 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
937 | 937 | |
938 | 938 | |
939 | 939 | |
940 | - $style = ($line->qty==1) ? 'BU' : 'BUI'; |
|
940 | + $style = ($line->qty == 1) ? 'BU' : 'BUI'; |
|
941 | 941 | if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
942 | 942 | |
943 | - if($hideInnerLines) { |
|
944 | - if($line->qty==1)$pdf->SetFont('', $style, 9); |
|
943 | + if ($hideInnerLines) { |
|
944 | + if ($line->qty == 1)$pdf->SetFont('', $style, 9); |
|
945 | 945 | else |
946 | 946 | { |
947 | 947 | if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
@@ -950,43 +950,43 @@ discard block |
||
950 | 950 | } |
951 | 951 | else { |
952 | 952 | |
953 | - if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
953 | + if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
954 | 954 | else $pdf->SetFont('', $style, 9); |
955 | 955 | |
956 | 956 | } |
957 | 957 | |
958 | 958 | if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine |
959 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML |
|
959 | + else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML |
|
960 | 960 | |
961 | - if($description && !$hidedesc) { |
|
961 | + if ($description && !$hidedesc) { |
|
962 | 962 | $posy = $pdf->GetY(); |
963 | 963 | |
964 | 964 | $pdf->SetFont('', '', 8); |
965 | 965 | |
966 | - $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true); |
|
966 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true); |
|
967 | 967 | |
968 | 968 | } |
969 | 969 | |
970 | 970 | } |
971 | 971 | |
972 | - function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') { |
|
972 | + function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') { |
|
973 | 973 | // ultimate PDF hook O_o |
974 | 974 | |
975 | - return $this->pdf_writelinedesc($parameters,$object,$action); |
|
975 | + return $this->pdf_writelinedesc($parameters, $object, $action); |
|
976 | 976 | |
977 | 977 | } |
978 | 978 | |
979 | 979 | function isModSubtotalLine(&$parameters, &$object) { |
980 | 980 | |
981 | - if(is_array($parameters)) { |
|
981 | + if (is_array($parameters)) { |
|
982 | 982 | $i = & $parameters['i']; |
983 | 983 | } |
984 | 984 | else { |
985 | - $i = (int)$parameters; |
|
985 | + $i = (int) $parameters; |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | |
989 | - if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) { |
|
989 | + if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) { |
|
990 | 990 | return true; |
991 | 991 | } |
992 | 992 | |
@@ -994,42 +994,42 @@ discard block |
||
994 | 994 | |
995 | 995 | } |
996 | 996 | |
997 | - function pdf_getlineqty($parameters=array(), &$object, &$action='') { |
|
998 | - global $conf,$hideprices; |
|
997 | + function pdf_getlineqty($parameters = array(), &$object, &$action = '') { |
|
998 | + global $conf, $hideprices; |
|
999 | 999 | |
1000 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1000 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1001 | 1001 | |
1002 | 1002 | $this->resprints = ' '; |
1003 | 1003 | |
1004 | - if((float)DOL_VERSION<=3.6) { |
|
1004 | + if ((float) DOL_VERSION <= 3.6) { |
|
1005 | 1005 | return ''; |
1006 | 1006 | } |
1007 | - else if((float)DOL_VERSION>=3.8) { |
|
1007 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1008 | 1008 | return 1; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | } |
1012 | - elseif(!empty($hideprices)) { |
|
1012 | + elseif (!empty($hideprices)) { |
|
1013 | 1013 | $this->resprints = $object->lines[$parameters['i']]->qty; |
1014 | 1014 | return 1; |
1015 | 1015 | } |
1016 | 1016 | elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
1017 | 1017 | { |
1018 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
1019 | - $hidedetails = (int)GETPOST('hidedetails'); |
|
1018 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
1019 | + $hidedetails = (int) GETPOST('hidedetails'); |
|
1020 | 1020 | if (empty($hideInnerLines) && !empty($hidedetails)) |
1021 | 1021 | { |
1022 | 1022 | $this->resprints = $object->lines[$parameters['i']]->qty; |
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1027 | - else $i = (int)$parameters; |
|
1026 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1027 | + else $i = (int) $parameters; |
|
1028 | 1028 | |
1029 | 1029 | if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
1030 | 1030 | |
1031 | 1031 | $object->lines[$i]->fetch_optionals(); |
1032 | - if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1032 | + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1033 | 1033 | { |
1034 | 1034 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1035 | 1035 | { |
@@ -1041,25 +1041,25 @@ discard block |
||
1041 | 1041 | return 0; |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { |
|
1044 | + function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') { |
|
1045 | 1045 | global $conf, $hideprices; |
1046 | 1046 | |
1047 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1047 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1048 | 1048 | |
1049 | 1049 | $this->resprints = ' '; |
1050 | 1050 | |
1051 | - if((float)DOL_VERSION<=3.6) { |
|
1051 | + if ((float) DOL_VERSION <= 3.6) { |
|
1052 | 1052 | return ''; |
1053 | 1053 | } |
1054 | - else if((float)DOL_VERSION>=3.8) { |
|
1054 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1055 | 1055 | return 1; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | } |
1059 | 1059 | elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
1060 | 1060 | { |
1061 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1062 | - else $i = (int)$parameters; |
|
1061 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1062 | + else $i = (int) $parameters; |
|
1063 | 1063 | |
1064 | 1064 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1065 | 1065 | { |
@@ -1080,13 +1080,13 @@ discard block |
||
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | } |
1083 | - if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ |
|
1084 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1085 | - else $i = (int)$parameters; |
|
1083 | + if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) { |
|
1084 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1085 | + else $i = (int) $parameters; |
|
1086 | 1086 | $this->resprints = price($object->lines[$i]->total_ht); |
1087 | 1087 | } |
1088 | 1088 | if (!empty($hideprices) |
1089 | - || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1089 | + || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1090 | 1090 | ) |
1091 | 1091 | { |
1092 | 1092 | if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
@@ -1099,25 +1099,25 @@ discard block |
||
1099 | 1099 | return 0; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') { |
|
1102 | + function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') { |
|
1103 | 1103 | global $conf; |
1104 | 1104 | |
1105 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1105 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1106 | 1106 | |
1107 | 1107 | $this->resprints = ' '; |
1108 | 1108 | |
1109 | - if((float)DOL_VERSION<=3.6) { |
|
1109 | + if ((float) DOL_VERSION <= 3.6) { |
|
1110 | 1110 | return ''; |
1111 | 1111 | } |
1112 | - else if((float)DOL_VERSION>=3.8) { |
|
1112 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1113 | 1113 | return 1; |
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1118 | - else $i = (int)$parameters; |
|
1117 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1118 | + else $i = (int) $parameters; |
|
1119 | 1119 | |
1120 | - if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1120 | + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1121 | 1121 | { |
1122 | 1122 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1123 | 1123 | { |
@@ -1129,24 +1129,24 @@ discard block |
||
1129 | 1129 | return 0; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | - function pdf_getlineunit($parameters=array(), &$object, &$action='') { |
|
1132 | + function pdf_getlineunit($parameters = array(), &$object, &$action = '') { |
|
1133 | 1133 | global $conf; |
1134 | 1134 | |
1135 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1135 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1136 | 1136 | $this->resprints = ' '; |
1137 | 1137 | |
1138 | - if((float)DOL_VERSION<=3.6) { |
|
1138 | + if ((float) DOL_VERSION <= 3.6) { |
|
1139 | 1139 | return ''; |
1140 | 1140 | } |
1141 | - else if((float)DOL_VERSION>=3.8) { |
|
1141 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1142 | 1142 | return 1; |
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1147 | - else $i = (int)$parameters; |
|
1146 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1147 | + else $i = (int) $parameters; |
|
1148 | 1148 | |
1149 | - if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1149 | + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1150 | 1150 | { |
1151 | 1151 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1152 | 1152 | { |
@@ -1158,24 +1158,24 @@ discard block |
||
1158 | 1158 | return 0; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') { |
|
1162 | - global $conf,$hideprices; |
|
1161 | + function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') { |
|
1162 | + global $conf, $hideprices; |
|
1163 | 1163 | |
1164 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1164 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1165 | 1165 | $this->resprints = ' '; |
1166 | 1166 | |
1167 | - if((float)DOL_VERSION<=3.6) { |
|
1167 | + if ((float) DOL_VERSION <= 3.6) { |
|
1168 | 1168 | return ''; |
1169 | 1169 | } |
1170 | - else if((float)DOL_VERSION>=3.8) { |
|
1170 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1171 | 1171 | return 1; |
1172 | 1172 | } |
1173 | 1173 | } |
1174 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1175 | - else $i = (int)$parameters; |
|
1174 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1175 | + else $i = (int) $parameters; |
|
1176 | 1176 | |
1177 | 1177 | if (!empty($hideprices) |
1178 | - || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1178 | + || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1179 | 1179 | ) |
1180 | 1180 | { |
1181 | 1181 | if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
@@ -1188,24 +1188,24 @@ discard block |
||
1188 | 1188 | return 0; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') { |
|
1192 | - global $conf,$hideprices; |
|
1191 | + function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') { |
|
1192 | + global $conf, $hideprices; |
|
1193 | 1193 | |
1194 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1194 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1195 | 1195 | $this->resprints = ' '; |
1196 | - if((float)DOL_VERSION<=3.6) { |
|
1196 | + if ((float) DOL_VERSION <= 3.6) { |
|
1197 | 1197 | return ''; |
1198 | 1198 | } |
1199 | - else if((float)DOL_VERSION>=3.8) { |
|
1199 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1200 | 1200 | return 1; |
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | |
1204 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1205 | - else $i = (int)$parameters; |
|
1204 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1205 | + else $i = (int) $parameters; |
|
1206 | 1206 | |
1207 | 1207 | if (!empty($hideprices) |
1208 | - || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1208 | + || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1209 | 1209 | ) |
1210 | 1210 | { |
1211 | 1211 | if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
@@ -1218,27 +1218,27 @@ discard block |
||
1218 | 1218 | return 0; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - function pdf_getlinevatrate($parameters=array(), &$object, &$action='') { |
|
1221 | + function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') { |
|
1222 | 1222 | global $conf; |
1223 | 1223 | |
1224 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1224 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1225 | 1225 | $this->resprints = ' '; |
1226 | 1226 | |
1227 | - if((float)DOL_VERSION<=3.6) { |
|
1227 | + if ((float) DOL_VERSION <= 3.6) { |
|
1228 | 1228 | return ''; |
1229 | 1229 | } |
1230 | - else if((float)DOL_VERSION>=3.8) { |
|
1230 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1231 | 1231 | return 1; |
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1236 | - else $i = (int)$parameters; |
|
1235 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1236 | + else $i = (int) $parameters; |
|
1237 | 1237 | |
1238 | 1238 | if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
1239 | 1239 | |
1240 | 1240 | $object->lines[$i]->fetch_optionals(); |
1241 | - if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1241 | + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1242 | 1242 | { |
1243 | 1243 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1244 | 1244 | { |
@@ -1250,23 +1250,23 @@ discard block |
||
1250 | 1250 | return 0; |
1251 | 1251 | } |
1252 | 1252 | |
1253 | - function pdf_getlineprogress($parameters=array(), &$object, &$action) { |
|
1253 | + function pdf_getlineprogress($parameters = array(), &$object, &$action) { |
|
1254 | 1254 | global $conf; |
1255 | 1255 | |
1256 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1256 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1257 | 1257 | $this->resprints = ' '; |
1258 | - if((float)DOL_VERSION<=3.6) { |
|
1258 | + if ((float) DOL_VERSION <= 3.6) { |
|
1259 | 1259 | return ''; |
1260 | 1260 | } |
1261 | - else if((float)DOL_VERSION>=3.8) { |
|
1261 | + else if ((float) DOL_VERSION >= 3.8) { |
|
1262 | 1262 | return 1; |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1267 | - else $i = (int)$parameters; |
|
1266 | + if (is_array($parameters)) $i = & $parameters['i']; |
|
1267 | + else $i = (int) $parameters; |
|
1268 | 1268 | |
1269 | - if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
|
1269 | + if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) |
|
1270 | 1270 | { |
1271 | 1271 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1272 | 1272 | { |
@@ -1281,12 +1281,12 @@ discard block |
||
1281 | 1281 | function add_numerotation(&$object) { |
1282 | 1282 | global $conf; |
1283 | 1283 | |
1284 | - if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) { |
|
1284 | + if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) { |
|
1285 | 1285 | |
1286 | 1286 | $TLevelTitre = array(); |
1287 | 1287 | $prevlevel = 0; |
1288 | 1288 | |
1289 | - foreach($object->lines as $k=>&$line) |
|
1289 | + foreach ($object->lines as $k=>&$line) |
|
1290 | 1290 | { |
1291 | 1291 | if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10) |
1292 | 1292 | { |
@@ -1300,12 +1300,12 @@ discard block |
||
1300 | 1300 | } |
1301 | 1301 | |
1302 | 1302 | // TODO ne gère pas encore la numération des lignes "Totaux" |
1303 | - private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0) |
|
1303 | + private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0) |
|
1304 | 1304 | { |
1305 | 1305 | $TTitle = array(); |
1306 | 1306 | |
1307 | - $i=1; |
|
1308 | - $j=0; |
|
1307 | + $i = 1; |
|
1308 | + $j = 0; |
|
1309 | 1309 | foreach ($TLineTitle as $k => &$line) |
1310 | 1310 | { |
1311 | 1311 | if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
@@ -1315,7 +1315,7 @@ discard block |
||
1315 | 1315 | { |
1316 | 1316 | $TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i; |
1317 | 1317 | //var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].' ### '.$line->qty .'=='. $level); |
1318 | - if (empty($line->label) && (float)DOL_VERSION < 6) |
|
1318 | + if (empty($line->label) && (float) DOL_VERSION < 6) |
|
1319 | 1319 | { |
1320 | 1320 | $line->label = !empty($line->desc) ? $line->desc : $line->description; |
1321 | 1321 | $line->desc = $line->description = ''; |
@@ -1341,26 +1341,26 @@ discard block |
||
1341 | 1341 | |
1342 | 1342 | function setDocTVA(&$pdf, &$object) { |
1343 | 1343 | |
1344 | - $hidedetails = (int)GETPOST('hidedetails'); |
|
1344 | + $hidedetails = (int) GETPOST('hidedetails'); |
|
1345 | 1345 | |
1346 | - if(empty($hidedetails)) return false; |
|
1346 | + if (empty($hidedetails)) return false; |
|
1347 | 1347 | |
1348 | 1348 | // TODO can't add VAT to document without lines... :-/ |
1349 | 1349 | |
1350 | 1350 | return true; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - function beforePDFCreation($parameters=array(), &$object, &$action) |
|
1353 | + function beforePDFCreation($parameters = array(), &$object, &$action) |
|
1354 | 1354 | { |
1355 | 1355 | /** |
1356 | 1356 | * @var $pdf TCPDF |
1357 | 1357 | */ |
1358 | - global $pdf,$conf, $langs; |
|
1358 | + global $pdf, $conf, $langs; |
|
1359 | 1359 | |
1360 | 1360 | // var_dump($object->lines); |
1361 | 1361 | dol_include_once('/subtotal/class/subtotal.class.php'); |
1362 | 1362 | |
1363 | - foreach($parameters as $key=>$value) { |
|
1363 | + foreach ($parameters as $key=>$value) { |
|
1364 | 1364 | ${$key} = $value; |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1369,25 +1369,25 @@ discard block |
||
1369 | 1369 | $this->add_numerotation($object); |
1370 | 1370 | |
1371 | 1371 | |
1372 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
1373 | - $hidedetails = (int)GETPOST('hidedetails'); |
|
1372 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
1373 | + $hidedetails = (int) GETPOST('hidedetails'); |
|
1374 | 1374 | |
1375 | 1375 | if ($hideInnerLines) { // si c une ligne de titre |
1376 | - $fk_parent_line=0; |
|
1377 | - $TLines =array(); |
|
1376 | + $fk_parent_line = 0; |
|
1377 | + $TLines = array(); |
|
1378 | 1378 | |
1379 | - $original_count=count($object->lines); |
|
1379 | + $original_count = count($object->lines); |
|
1380 | 1380 | $TTvas = array(); // tableau de tva |
1381 | 1381 | |
1382 | - foreach($object->lines as $k=>&$line) |
|
1382 | + foreach ($object->lines as $k=>&$line) |
|
1383 | 1383 | { |
1384 | 1384 | |
1385 | - if($line->product_type==9 && $line->rowid>0) |
|
1385 | + if ($line->product_type == 9 && $line->rowid > 0) |
|
1386 | 1386 | { |
1387 | 1387 | $fk_parent_line = $line->rowid; |
1388 | 1388 | |
1389 | 1389 | // Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme |
1390 | - if(TSubtotal::isSubtotal($line)) |
|
1390 | + if (TSubtotal::isSubtotal($line)) |
|
1391 | 1391 | { |
1392 | 1392 | /*$total = $this->getTotalLineFromObject($object, $line, ''); |
1393 | 1393 | |
@@ -1407,27 +1407,27 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | if ($hideInnerLines) |
1409 | 1409 | { |
1410 | - if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1410 | + if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1411 | 1411 | { |
1412 | - if($line->tva_tx != '0.000' && $line->product_type!=9){ |
|
1412 | + if ($line->tva_tx != '0.000' && $line->product_type != 9) { |
|
1413 | 1413 | |
1414 | 1414 | // on remplit le tableau de tva pour substituer les lignes cachées |
1415 | 1415 | $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva; |
1416 | 1416 | $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht; |
1417 | 1417 | $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; |
1418 | 1418 | } |
1419 | - if($line->product_type==9 && $line->rowid>0) |
|
1419 | + if ($line->product_type == 9 && $line->rowid > 0) |
|
1420 | 1420 | { |
1421 | 1421 | //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres |
1422 | 1422 | // génère des lignes d'affichage des montants HT soumis à tva |
1423 | 1423 | $nbtva = count($TTvas); |
1424 | - if(!empty($nbtva)){ |
|
1425 | - foreach ($TTvas as $tx =>$val){ |
|
1424 | + if (!empty($nbtva)) { |
|
1425 | + foreach ($TTvas as $tx =>$val) { |
|
1426 | 1426 | $l = clone $line; |
1427 | 1427 | $l->product_type = 1; |
1428 | 1428 | $l->special_code = ''; |
1429 | 1429 | $l->qty = 1; |
1430 | - $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1430 | + $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '.price($tx).' %'; |
|
1431 | 1431 | $l->tva_tx = $tx; |
1432 | 1432 | $l->total_ht = $val['total_ht']; |
1433 | 1433 | $l->total_tva = $val['total_tva']; |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | } else { |
1445 | 1445 | |
1446 | - if($line->product_type==9 && $line->rowid>0) |
|
1446 | + if ($line->product_type == 9 && $line->rowid > 0) |
|
1447 | 1447 | { |
1448 | 1448 | // ajoute la ligne de sous-total |
1449 | 1449 | $TLines[] = $line; |
@@ -1471,14 +1471,14 @@ discard block |
||
1471 | 1471 | |
1472 | 1472 | // cas incongru où il y aurait des produits en dessous du dernier sous-total |
1473 | 1473 | $nbtva = count($TTvas); |
1474 | - if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1474 | + if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) |
|
1475 | 1475 | { |
1476 | - foreach ($TTvas as $tx =>$val){ |
|
1476 | + foreach ($TTvas as $tx =>$val) { |
|
1477 | 1477 | $l = clone $line; |
1478 | 1478 | $l->product_type = 1; |
1479 | 1479 | $l->special_code = ''; |
1480 | 1480 | $l->qty = 1; |
1481 | - $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %'; |
|
1481 | + $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '.price($tx).' %'; |
|
1482 | 1482 | $l->tva_tx = $tx; |
1483 | 1483 | $l->total_ht = $val['total_ht']; |
1484 | 1484 | $l->total_tva = $val['total_tva']; |
@@ -1490,11 +1490,11 @@ discard block |
||
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | global $nblignes; |
1493 | - $nblignes=count($TLines); |
|
1493 | + $nblignes = count($TLines); |
|
1494 | 1494 | |
1495 | 1495 | $object->lines = $TLines; |
1496 | 1496 | |
1497 | - if($i>count($object->lines)) { |
|
1497 | + if ($i > count($object->lines)) { |
|
1498 | 1498 | $this->resprints = ''; |
1499 | 1499 | return 0; |
1500 | 1500 | } |
@@ -1503,59 +1503,59 @@ discard block |
||
1503 | 1503 | return 0; |
1504 | 1504 | } |
1505 | 1505 | |
1506 | - function pdf_writelinedesc($parameters=array(), &$object, &$action) |
|
1506 | + function pdf_writelinedesc($parameters = array(), &$object, &$action) |
|
1507 | 1507 | { |
1508 | 1508 | /** |
1509 | 1509 | * @var $pdf TCPDF |
1510 | 1510 | */ |
1511 | - global $pdf,$conf; |
|
1511 | + global $pdf, $conf; |
|
1512 | 1512 | |
1513 | - foreach($parameters as $key=>$value) { |
|
1513 | + foreach ($parameters as $key=>$value) { |
|
1514 | 1514 | ${$key} = $value; |
1515 | 1515 | } |
1516 | 1516 | |
1517 | - $hideInnerLines = (int)GETPOST('hideInnerLines'); |
|
1518 | - $hidedetails = (int)GETPOST('hidedetails'); |
|
1517 | + $hideInnerLines = (int) GETPOST('hideInnerLines'); |
|
1518 | + $hidedetails = (int) GETPOST('hidedetails'); |
|
1519 | 1519 | |
1520 | - if($this->isModSubtotalLine($parameters,$object) ){ |
|
1520 | + if ($this->isModSubtotalLine($parameters, $object)) { |
|
1521 | 1521 | |
1522 | 1522 | global $hideprices; |
1523 | 1523 | |
1524 | - if(!empty($hideprices)) { |
|
1525 | - foreach($object->lines as &$line) { |
|
1526 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
1524 | + if (!empty($hideprices)) { |
|
1525 | + foreach ($object->lines as &$line) { |
|
1526 | + if ($line->fk_product_type != 9) $line->fk_parent_line = -1; |
|
1527 | 1527 | } |
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | $line = &$object->lines[$i]; |
1531 | 1531 | |
1532 | - if($line->info_bits>0) { // PAGE BREAK |
|
1532 | + if ($line->info_bits > 0) { // PAGE BREAK |
|
1533 | 1533 | $pdf->addPage(); |
1534 | 1534 | $posy = $pdf->GetY(); |
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | $label = $line->label; |
1538 | - $description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description); |
|
1538 | + $description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description); |
|
1539 | 1539 | |
1540 | - if(empty($label)) { |
|
1540 | + if (empty($label)) { |
|
1541 | 1541 | $label = $description; |
1542 | - $description=''; |
|
1542 | + $description = ''; |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | - if($line->qty>90) { |
|
1545 | + if ($line->qty > 90) { |
|
1546 | 1546 | |
1547 | 1547 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
1548 | 1548 | |
1549 | 1549 | $pageBefore = $pdf->getPage(); |
1550 | - $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
|
1550 | + $this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); |
|
1551 | 1551 | $pageAfter = $pdf->getPage(); |
1552 | 1552 | |
1553 | - if($pageAfter>$pageBefore) { |
|
1553 | + if ($pageAfter > $pageBefore) { |
|
1554 | 1554 | //print "ST $pageAfter>$pageBefore<br>"; |
1555 | 1555 | $pdf->rollbackTransaction(true); |
1556 | - $pdf->addPage('','', true); |
|
1556 | + $pdf->addPage('', '', true); |
|
1557 | 1557 | $posy = $pdf->GetY(); |
1558 | - $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
|
1558 | + $this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); |
|
1559 | 1559 | $posy = $pdf->GetY(); |
1560 | 1560 | //print 'add ST'.$pdf->getPage().'<br />'; |
1561 | 1561 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | else if ($line->qty < 10) { |
1567 | 1567 | $pageBefore = $pdf->getPage(); |
1568 | 1568 | |
1569 | - $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
|
1569 | + $this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); |
|
1570 | 1570 | $pageAfter = $pdf->getPage(); |
1571 | 1571 | |
1572 | 1572 | |
@@ -1641,9 +1641,9 @@ discard block |
||
1641 | 1641 | * @param $hookmanager HookManager |
1642 | 1642 | * @return int |
1643 | 1643 | */ |
1644 | - function printObjectLine ($parameters, &$object, &$action, $hookmanager){ |
|
1644 | + function printObjectLine($parameters, &$object, &$action, $hookmanager) { |
|
1645 | 1645 | |
1646 | - global $conf,$langs,$user,$db,$bc; |
|
1646 | + global $conf, $langs, $user, $db, $bc; |
|
1647 | 1647 | |
1648 | 1648 | $num = &$parameters['num']; |
1649 | 1649 | $line = &$parameters['line']; |
@@ -1651,32 +1651,32 @@ discard block |
||
1651 | 1651 | |
1652 | 1652 | $var = &$parameters['var']; |
1653 | 1653 | |
1654 | - $contexts = explode(':',$parameters['context']); |
|
1654 | + $contexts = explode(':', $parameters['context']); |
|
1655 | 1655 | |
1656 | 1656 | $createRight = $user->rights->{$object->element}->creer; |
1657 | - if($object->element == 'facturerec' ) |
|
1657 | + if ($object->element == 'facturerec') |
|
1658 | 1658 | { |
1659 | 1659 | $object->statut = 0; // hack for facture rec |
1660 | 1660 | $createRight = $user->rights->facture->creer; |
1661 | 1661 | } |
1662 | - elseif($object->element == 'order_supplier' ) |
|
1662 | + elseif ($object->element == 'order_supplier') |
|
1663 | 1663 | { |
1664 | 1664 | $createRight = $user->rights->fournisseur->commande->creer; |
1665 | 1665 | } |
1666 | - elseif($object->element == 'invoice_supplier' ) |
|
1666 | + elseif ($object->element == 'invoice_supplier') |
|
1667 | 1667 | { |
1668 | 1668 | $createRight = $user->rights->fournisseur->facture->creer; |
1669 | 1669 | } |
1670 | 1670 | |
1671 | - if($line->special_code!=$this->module_number || $line->product_type!=9) { |
|
1671 | + if ($line->special_code != $this->module_number || $line->product_type != 9) { |
|
1672 | 1672 | null; |
1673 | 1673 | } |
1674 | - else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
1674 | + else if (in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('invoicereccard', $contexts)) |
|
1675 | 1675 | { |
1676 | - if($object->element=='facture')$idvar = 'facid'; |
|
1677 | - else $idvar='id'; |
|
1676 | + if ($object->element == 'facture')$idvar = 'facid'; |
|
1677 | + else $idvar = 'id'; |
|
1678 | 1678 | |
1679 | - if((float)DOL_VERSION <= 3.4) |
|
1679 | + if ((float) DOL_VERSION <= 3.4) |
|
1680 | 1680 | { |
1681 | 1681 | ?> |
1682 | 1682 | <script type="text/javascript"> |
@@ -1700,20 +1700,20 @@ discard block |
||
1700 | 1700 | <?php |
1701 | 1701 | } |
1702 | 1702 | |
1703 | - if(empty($line->description)) $line->description = $line->desc; |
|
1703 | + if (empty($line->description)) $line->description = $line->desc; |
|
1704 | 1704 | |
1705 | 1705 | $colspan = 5; |
1706 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
1707 | - if($object->element == 'order_supplier') $colspan = 3; |
|
1708 | - if($object->element == 'invoice_supplier') $colspan = 4; |
|
1709 | - if($object->element == 'supplier_proposal') $colspan = 4; |
|
1710 | - if(!empty($conf->multicurrency->enabled)) $colspan+=2; |
|
1711 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1712 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
1713 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1714 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1715 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1716 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
1706 | + if ($object->element == 'facturerec') $colspan = 3; |
|
1707 | + if ($object->element == 'order_supplier') $colspan = 3; |
|
1708 | + if ($object->element == 'invoice_supplier') $colspan = 4; |
|
1709 | + if ($object->element == 'supplier_proposal') $colspan = 4; |
|
1710 | + if (!empty($conf->multicurrency->enabled)) $colspan += 2; |
|
1711 | + if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1712 | + if (!empty($conf->margin->enabled)) $colspan++; |
|
1713 | + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1714 | + if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1715 | + if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1716 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
1717 | 1717 | |
1718 | 1718 | /* Titre */ |
1719 | 1719 | //var_dump($line); |
@@ -1723,35 +1723,35 @@ discard block |
||
1723 | 1723 | |
1724 | 1724 | |
1725 | 1725 | ?> |
1726 | - <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
|
1726 | + <tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
|
1727 | 1727 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
1728 | 1728 | { |
1729 | - if($line->qty==99) print 'background:#adadcf'; |
|
1730 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1731 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
1732 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
1733 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
1734 | - else if($line->qty==50) print ''; |
|
1729 | + if ($line->qty == 99) print 'background:#adadcf'; |
|
1730 | + else if ($line->qty == 98) print 'background:#ddddff;'; |
|
1731 | + else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;'; |
|
1732 | + else if ($line->qty == 1) print 'background:#adadcf;'; |
|
1733 | + else if ($line->qty == 2) print 'background:#ddddff;'; |
|
1734 | + else if ($line->qty == 50) print ''; |
|
1735 | 1735 | else print 'background:#eeeeff;'; |
1736 | 1736 | |
1737 | 1737 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
1738 | 1738 | } |
1739 | 1739 | else |
1740 | 1740 | { |
1741 | - if($line->qty==99) print 'background:#ddffdd'; |
|
1742 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1743 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
1744 | - else if($line->qty==50) print ''; |
|
1745 | - else print 'background:#eeffee;' ; |
|
1741 | + if ($line->qty == 99) print 'background:#ddffdd'; |
|
1742 | + else if ($line->qty == 98) print 'background:#ddddff;'; |
|
1743 | + else if ($line->qty == 2) print 'background:#eeeeff; '; |
|
1744 | + else if ($line->qty == 50) print ''; |
|
1745 | + else print 'background:#eeffee;'; |
|
1746 | 1746 | } |
1747 | 1747 | |
1748 | 1748 | ?>;"> |
1749 | 1749 | |
1750 | - <td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?> <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php |
|
1751 | - if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) { |
|
1750 | + <td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?> <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php |
|
1751 | + if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) { |
|
1752 | 1752 | |
1753 | - $params=array('line'=>$line); |
|
1754 | - $reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action); |
|
1753 | + $params = array('line'=>$line); |
|
1754 | + $reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action); |
|
1755 | 1755 | |
1756 | 1756 | echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr |
1757 | 1757 | echo '<input type="hidden" value="'.$line->id.'" name="lineid">'; |
@@ -1759,7 +1759,7 @@ discard block |
||
1759 | 1759 | echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">'; |
1760 | 1760 | echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">'; |
1761 | 1761 | |
1762 | - $isFreeText=false; |
|
1762 | + $isFreeText = false; |
|
1763 | 1763 | if (TSubtotal::isTitle($line)) |
1764 | 1764 | { |
1765 | 1765 | $qty_displayed = $line->qty; |
@@ -1781,13 +1781,13 @@ discard block |
||
1781 | 1781 | $line->description = ''; |
1782 | 1782 | } |
1783 | 1783 | $newlabel = $line->label; |
1784 | - if($line->label=='' && !$isFreeText) { |
|
1785 | - if(TSubtotal::isSubtotal($line)) { |
|
1784 | + if ($line->label == '' && !$isFreeText) { |
|
1785 | + if (TSubtotal::isSubtotal($line)) { |
|
1786 | 1786 | $newlabel = $line->description.' '.$this->getTitle($object, $line); |
1787 | - $line->description=''; |
|
1788 | - } elseif( (float)DOL_VERSION < 6 ) { |
|
1789 | - $newlabel= $line->description; |
|
1790 | - $line->description=''; |
|
1787 | + $line->description = ''; |
|
1788 | + } elseif ((float) DOL_VERSION < 6) { |
|
1789 | + $newlabel = $line->description; |
|
1790 | + $line->description = ''; |
|
1791 | 1791 | } |
1792 | 1792 | } |
1793 | 1793 | |
@@ -1796,10 +1796,10 @@ discard block |
||
1796 | 1796 | |
1797 | 1797 | if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
1798 | 1798 | |
1799 | - if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
|
1799 | + if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))) |
|
1800 | 1800 | { |
1801 | 1801 | $select = '<select name="subtotal_level">'; |
1802 | - for ($j=1; $j<10; $j++) |
|
1802 | + for ($j = 1; $j < 10; $j++) |
|
1803 | 1803 | { |
1804 | 1804 | if (!empty($readonlyForSituation)) { |
1805 | 1805 | if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
@@ -1812,7 +1812,7 @@ discard block |
||
1812 | 1812 | |
1813 | 1813 | |
1814 | 1814 | echo '<div class="subtotal_underline" style="margin-left:24px;">'; |
1815 | - echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;" type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' /> '; |
|
1815 | + echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;" type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' /> '; |
|
1816 | 1816 | |
1817 | 1817 | if (TSubtotal::isTitle($line)) |
1818 | 1818 | { |
@@ -1830,9 +1830,9 @@ discard block |
||
1830 | 1830 | else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
1831 | 1831 | echo '</div>'; |
1832 | 1832 | |
1833 | - if($line->qty<10) { |
|
1833 | + if ($line->qty < 10) { |
|
1834 | 1834 | // WYSIWYG editor |
1835 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
1835 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
1836 | 1836 | $nbrows = ROWS_2; |
1837 | 1837 | $cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); |
1838 | 1838 | if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
@@ -1852,25 +1852,25 @@ discard block |
||
1852 | 1852 | |
1853 | 1853 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
1854 | 1854 | { |
1855 | - if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) |
|
1855 | + if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) |
|
1856 | 1856 | { |
1857 | - echo str_repeat(' ', $line->qty-1); |
|
1857 | + echo str_repeat(' ', $line->qty - 1); |
|
1858 | 1858 | |
1859 | 1859 | if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
1860 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
1860 | + else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span> '; |
|
1861 | 1861 | } |
1862 | 1862 | } |
1863 | 1863 | else |
1864 | 1864 | { |
1865 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
1866 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
1865 | + if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal'); |
|
1866 | + else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
1867 | 1867 | } |
1868 | 1868 | |
1869 | 1869 | |
1870 | 1870 | // Get display styles and apply them |
1871 | 1871 | $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;'; |
1872 | - $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;'; |
|
1873 | - $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
|
1872 | + $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;'; |
|
1873 | + $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
|
1874 | 1874 | |
1875 | 1875 | if (empty($line->label)) { |
1876 | 1876 | if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
@@ -1878,16 +1878,16 @@ discard block |
||
1878 | 1878 | } |
1879 | 1879 | else { |
1880 | 1880 | |
1881 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
|
1881 | + if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
|
1882 | 1882 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
1883 | 1883 | } |
1884 | - else{ |
|
1884 | + else { |
|
1885 | 1885 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | } |
1889 | - if($line->qty>90) print ' : '; |
|
1890 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
1889 | + if ($line->qty > 90) print ' : '; |
|
1890 | + if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
1891 | 1891 | |
1892 | 1892 | |
1893 | 1893 | |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | ?></td> |
1897 | 1897 | |
1898 | 1898 | <?php |
1899 | - if($line->qty>90) { |
|
1899 | + if ($line->qty > 90) { |
|
1900 | 1900 | /* Total */ |
1901 | 1901 | $total_line = $this->getTotalLineFromObject($object, $line, ''); |
1902 | 1902 | echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>'; |
@@ -1909,7 +1909,7 @@ discard block |
||
1909 | 1909 | <?php |
1910 | 1910 | if ($action != 'selectlines') { |
1911 | 1911 | |
1912 | - if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) { |
|
1912 | + if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) { |
|
1913 | 1913 | ?> |
1914 | 1914 | <input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" /> |
1915 | 1915 | <br /> |
@@ -1925,13 +1925,13 @@ discard block |
||
1925 | 1925 | <?php |
1926 | 1926 | |
1927 | 1927 | } |
1928 | - else{ |
|
1929 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
|
1928 | + else { |
|
1929 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
|
1930 | 1930 | { |
1931 | - if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
1931 | + if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
|
1934 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
|
1935 | 1935 | { |
1936 | 1936 | echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>'; |
1937 | 1937 | } |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | <?php |
1947 | 1947 | |
1948 | 1948 | if ($action != 'editline' && $action != 'selectlines') { |
1949 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) |
|
1949 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) |
|
1950 | 1950 | { |
1951 | 1951 | |
1952 | 1952 | if ($object->situation_counter == 1 || !$object->situation_cycle_ref) |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>'; |
1955 | 1955 | } |
1956 | 1956 | |
1957 | - if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) |
|
1957 | + if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) |
|
1958 | 1958 | { |
1959 | 1959 | $img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal'); |
1960 | 1960 | echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>'; |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | </td> |
1966 | 1966 | |
1967 | 1967 | <?php |
1968 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline') |
|
1968 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline') |
|
1969 | 1969 | { |
1970 | 1970 | echo '<td class="subtotal_nc">'; |
1971 | 1971 | echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />'; |
@@ -1976,11 +1976,11 @@ discard block |
||
1976 | 1976 | <td align="center" class="tdlineupdown"> |
1977 | 1977 | </td> |
1978 | 1978 | <?php } else { ?> |
1979 | - <td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight ))?' class="tdlineupdown"':''); ?>></td> |
|
1979 | + <td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td> |
|
1980 | 1980 | <?php } ?> |
1981 | 1981 | |
1982 | - <?php if($action == 'selectlines'){ // dolibarr 8 ?> |
|
1983 | - <td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td> |
|
1982 | + <?php if ($action == 'selectlines') { // dolibarr 8 ?> |
|
1983 | + <td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td> |
|
1984 | 1984 | <?php } ?> |
1985 | 1985 | |
1986 | 1986 | </tr> |
@@ -1988,29 +1988,29 @@ discard block |
||
1988 | 1988 | |
1989 | 1989 | |
1990 | 1990 | // Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres) |
1991 | - if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) { |
|
1991 | + if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) { |
|
1992 | 1992 | |
1993 | - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
1993 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
1994 | 1994 | |
1995 | 1995 | // Extrafields |
1996 | 1996 | $extrafieldsline = new ExtraFields($db); |
1997 | 1997 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
1998 | 1998 | |
1999 | - $colspan+=3; $mode = 'view'; |
|
2000 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
1999 | + $colspan += 3; $mode = 'view'; |
|
2000 | + if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
2001 | 2001 | |
2002 | 2002 | $ex_element = $line->element; |
2003 | 2003 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
2004 | - print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan)); |
|
2004 | + print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan)); |
|
2005 | 2005 | $isExtraSelected = false; |
2006 | - foreach($line->array_options as $option) { |
|
2007 | - if(!empty($option) && $option != "-1") { |
|
2006 | + foreach ($line->array_options as $option) { |
|
2007 | + if (!empty($option) && $option != "-1") { |
|
2008 | 2008 | $isExtraSelected = true; |
2009 | 2009 | break; |
2010 | 2010 | } |
2011 | 2011 | } |
2012 | 2012 | |
2013 | - if($mode === 'edit') { |
|
2013 | + if ($mode === 'edit') { |
|
2014 | 2014 | ?> |
2015 | 2015 | <script> |
2016 | 2016 | $(document).ready(function(){ |
@@ -2018,7 +2018,7 @@ discard block |
||
2018 | 2018 | var all_tr_extrafields = $("tr.tr_extrafield_title"); |
2019 | 2019 | <?php |
2020 | 2020 | // Si un extrafield est rempli alors on affiche directement les extrafields |
2021 | - if(!$isExtraSelected) { |
|
2021 | + if (!$isExtraSelected) { |
|
2022 | 2022 | echo 'all_tr_extrafields.hide();'; |
2023 | 2023 | echo 'var trad = "'.$langs->trans('showExtrafields').'";'; |
2024 | 2024 | echo 'var extra = 0;'; |
@@ -2064,7 +2064,7 @@ discard block |
||
2064 | 2064 | |
2065 | 2065 | |
2066 | 2066 | function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { |
2067 | - global $conf,$langs; |
|
2067 | + global $conf, $langs; |
|
2068 | 2068 | |
2069 | 2069 | if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline') |
2070 | 2070 | { |
@@ -2164,23 +2164,23 @@ discard block |
||
2164 | 2164 | $ThtmlData['data-qty'] = 0; //$line->qty; |
2165 | 2165 | $ThtmlData['data-level'] = TSubtotal::getNiveau($line); |
2166 | 2166 | |
2167 | - if(TSubtotal::isTitle($line)){ |
|
2167 | + if (TSubtotal::isTitle($line)) { |
|
2168 | 2168 | $ThtmlData['data-issubtotal'] = 'title'; |
2169 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2169 | + }elseif (TSubtotal::isSubtotal($line)) { |
|
2170 | 2170 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
2171 | 2171 | } |
2172 | - else{ |
|
2172 | + else { |
|
2173 | 2173 | $ThtmlData['data-issubtotal'] = 'freetext'; |
2174 | 2174 | } |
2175 | 2175 | |
2176 | 2176 | |
2177 | 2177 | // Change or add data from hooks |
2178 | - $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) ); |
|
2178 | + $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData)); |
|
2179 | 2179 | |
2180 | 2180 | // hook |
2181 | - $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
2181 | + $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
2182 | 2182 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
2183 | - if ($reshook>0) |
|
2183 | + if ($reshook > 0) |
|
2184 | 2184 | { |
2185 | 2185 | $ThtmlData = $hookmanager->resArray; |
2186 | 2186 | } |
@@ -2193,14 +2193,14 @@ discard block |
||
2193 | 2193 | function implodeHtmlData($ThtmlData = array()) |
2194 | 2194 | { |
2195 | 2195 | $data = ''; |
2196 | - foreach($ThtmlData as $k => $h ) |
|
2196 | + foreach ($ThtmlData as $k => $h) |
|
2197 | 2197 | { |
2198 | - if(is_array($h)) |
|
2198 | + if (is_array($h)) |
|
2199 | 2199 | { |
2200 | 2200 | $h = json_encode($h); |
2201 | 2201 | } |
2202 | 2202 | |
2203 | - $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2203 | + $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" '; |
|
2204 | 2204 | } |
2205 | 2205 | |
2206 | 2206 | return $data; |
@@ -2208,26 +2208,26 @@ discard block |
||
2208 | 2208 | |
2209 | 2209 | function _ajax_block_order_js($object) |
2210 | 2210 | { |
2211 | - global $conf,$tagidfortablednd,$filepath,$langs; |
|
2211 | + global $conf, $tagidfortablednd, $filepath, $langs; |
|
2212 | 2212 | |
2213 | 2213 | /* |
2214 | 2214 | * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php |
2215 | 2215 | * for compatibility reasons we don't use tableDnD but jquery sortable |
2216 | 2216 | */ |
2217 | 2217 | |
2218 | - $id=$object->id; |
|
2219 | - $nboflines=(isset($object->lines)?count($object->lines):0); |
|
2220 | - $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; |
|
2218 | + $id = $object->id; |
|
2219 | + $nboflines = (isset($object->lines) ?count($object->lines) : 0); |
|
2220 | + $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1; |
|
2221 | 2221 | |
2222 | - $id=$object->id; |
|
2223 | - $fk_element=$object->fk_element; |
|
2224 | - $table_element_line=$object->table_element_line; |
|
2225 | - $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines)); |
|
2226 | - $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd); |
|
2227 | - $filepath=(empty($filepath)?'':$filepath); |
|
2222 | + $id = $object->id; |
|
2223 | + $fk_element = $object->fk_element; |
|
2224 | + $table_element_line = $object->table_element_line; |
|
2225 | + $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines)); |
|
2226 | + $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd); |
|
2227 | + $filepath = (empty($filepath) ? '' : $filepath); |
|
2228 | 2228 | |
2229 | 2229 | |
2230 | - if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1) |
|
2230 | + if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1) |
|
2231 | 2231 | { |
2232 | 2232 | |
2233 | 2233 | ?> |
@@ -2245,7 +2245,7 @@ discard block |
||
2245 | 2245 | moveBlockCol.disableSelection(); // prevent selection |
2246 | 2246 | <?php if ($object->statut == 0) { ?> |
2247 | 2247 | // apply some graphical stuff |
2248 | - moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2); ?>)'); |
|
2248 | + moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)'); |
|
2249 | 2249 | moveBlockCol.css("background-repeat","no-repeat"); |
2250 | 2250 | moveBlockCol.css("background-position","center center"); |
2251 | 2251 | moveBlockCol.css("cursor","move"); |
@@ -75,8 +75,11 @@ discard block |
||
75 | 75 | if ($object->statut == 0 && $createRight) { |
76 | 76 | |
77 | 77 | |
78 | - if($object->element=='facture')$idvar = 'facid'; |
|
79 | - else $idvar='id'; |
|
78 | + if($object->element=='facture') { |
|
79 | + $idvar = 'facid'; |
|
80 | + } else { |
|
81 | + $idvar='id'; |
|
82 | + } |
|
80 | 83 | |
81 | 84 | if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) |
82 | 85 | { |
@@ -84,10 +87,11 @@ discard block |
||
84 | 87 | |
85 | 88 | if($action=='add_title_line') { |
86 | 89 | $title = GETPOST('title'); |
87 | - if(empty($title)) $title = $langs->trans('title'); |
|
90 | + if(empty($title)) { |
|
91 | + $title = $langs->trans('title'); |
|
92 | + } |
|
88 | 93 | $qty = $level<1 ? 1 : $level ; |
89 | - } |
|
90 | - else if($action=='add_free_text') { |
|
94 | + } else if($action=='add_free_text') { |
|
91 | 95 | $title = GETPOST('title'); |
92 | 96 | |
93 | 97 | if (empty($title)) { |
@@ -99,29 +103,31 @@ discard block |
||
99 | 103 | } |
100 | 104 | } |
101 | 105 | } |
102 | - if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
106 | + if(empty($title)) { |
|
107 | + $title = $langs->trans('subtotalAddLineDescription'); |
|
108 | + } |
|
103 | 109 | $qty = 50; |
104 | - } |
|
105 | - else if($action=='add_subtitle_line') { |
|
110 | + } else if($action=='add_subtitle_line') { |
|
106 | 111 | $title = GETPOST('title'); |
107 | - if(empty($title)) $title = $langs->trans('subtitle'); |
|
112 | + if(empty($title)) { |
|
113 | + $title = $langs->trans('subtitle'); |
|
114 | + } |
|
108 | 115 | $qty = 2; |
109 | - } |
|
110 | - else if($action=='add_subtotal_line') { |
|
116 | + } else if($action=='add_subtotal_line') { |
|
111 | 117 | $title = $langs->trans('SubSubTotal'); |
112 | 118 | $qty = 98; |
113 | - } |
|
114 | - else { |
|
119 | + } else { |
|
115 | 120 | $title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); |
116 | 121 | $qty = $level ? 100-$level : 99; |
117 | 122 | } |
118 | 123 | dol_include_once('/subtotal/class/subtotal.class.php'); |
119 | 124 | |
120 | - if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
|
125 | + if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) { |
|
126 | + TSubtotal::addSubtotalMissing($object, $qty); |
|
127 | + } |
|
121 | 128 | |
122 | 129 | TSubtotal::addSubTotalLine($object, $title, $qty); |
123 | - } |
|
124 | - else if($action==='ask_deleteallline') { |
|
130 | + } else if($action==='ask_deleteallline') { |
|
125 | 131 | $form=new Form($db); |
126 | 132 | |
127 | 133 | $lineid = GETPOST('lineid','integer'); |
@@ -144,8 +150,7 @@ discard block |
||
144 | 150 | $this->printNewFormat($object, $conf, $langs, $idvar); |
145 | 151 | } |
146 | 152 | } |
147 | - } |
|
148 | - elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
153 | + } elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
149 | 154 | { |
150 | 155 | ?> |
151 | 156 | <script type="text/javascript"> |
@@ -163,8 +168,13 @@ discard block |
||
163 | 168 | |
164 | 169 | function printNewFormat(&$object, &$conf, &$langs, $idvar) |
165 | 170 | { |
166 | - if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false; |
|
167 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation |
|
171 | + if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) { |
|
172 | + return false; |
|
173 | + } |
|
174 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
175 | + return false; |
|
176 | + } |
|
177 | + // Si facture de situation |
|
168 | 178 | ?> |
169 | 179 | <script type="text/javascript"> |
170 | 180 | $(document).ready(function() { |
@@ -449,8 +459,7 @@ discard block |
||
449 | 459 | } |
450 | 460 | |
451 | 461 | |
452 | - } |
|
453 | - else{ |
|
462 | + } else{ |
|
454 | 463 | $substitutionarray['line_not_modsubtotal'] = true; |
455 | 464 | $substitutionarray['line_modsubtotal'] = 0; |
456 | 465 | } |
@@ -508,8 +517,11 @@ discard block |
||
508 | 517 | |
509 | 518 | $showBlockExtrafields = GETPOST('showBlockExtrafields'); |
510 | 519 | |
511 | - if($object->element=='facture') $idvar = 'facid'; |
|
512 | - else $idvar = 'id'; |
|
520 | + if($object->element=='facture') { |
|
521 | + $idvar = 'facid'; |
|
522 | + } else { |
|
523 | + $idvar = 'id'; |
|
524 | + } |
|
513 | 525 | |
514 | 526 | if ($action == 'updateligne' || $action == 'updateline') |
515 | 527 | { |
@@ -539,8 +551,7 @@ discard block |
||
539 | 551 | header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); |
540 | 552 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne |
541 | 553 | } |
542 | - } |
|
543 | - else if($action === 'builddoc') { |
|
554 | + } else if($action === 'builddoc') { |
|
544 | 555 | |
545 | 556 | if ( |
546 | 557 | in_array('invoicecard',explode(':',$parameters['context'])) |
@@ -555,33 +566,27 @@ discard block |
||
555 | 566 | $sessname = 'subtotal_hideInnerLines_facture'; |
556 | 567 | $sessname2 = 'subtotal_hidedetails_facture'; |
557 | 568 | $sessname3 = 'subtotal_hideprices_facture'; |
558 | - } |
|
559 | - elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
569 | + } elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
560 | 570 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
561 | 571 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
562 | 572 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
563 | - } |
|
564 | - elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
573 | + } elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
565 | 574 | $sessname = 'subtotal_hideInnerLines_propal'; |
566 | 575 | $sessname2 = 'subtotal_hidedetails_propal'; |
567 | 576 | $sessname3 = 'subtotal_hideprices_propal'; |
568 | - } |
|
569 | - elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
577 | + } elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
570 | 578 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
571 | 579 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
572 | 580 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
573 | - } |
|
574 | - elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
581 | + } elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
575 | 582 | $sessname = 'subtotal_hideInnerLines_commande'; |
576 | 583 | $sessname2 = 'subtotal_hidedetails_commande'; |
577 | 584 | $sessname3 = 'subtotal_hideprices_commande'; |
578 | - } |
|
579 | - elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
585 | + } elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
580 | 586 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
581 | 587 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
582 | 588 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
583 | - } |
|
584 | - else { |
|
589 | + } else { |
|
585 | 590 | $sessname = 'subtotal_hideInnerLines_unknown'; |
586 | 591 | $sessname2 = 'subtotal_hidedetails_unknown'; |
587 | 592 | $sessname3 = 'subtotal_hideprices_unknown'; |
@@ -603,8 +608,7 @@ discard block |
||
603 | 608 | |
604 | 609 | if($line->qty>=90) { |
605 | 610 | $line->modsubtotal_total = 1; |
606 | - } |
|
607 | - else{ |
|
611 | + } else{ |
|
608 | 612 | $line->modsubtotal_title = 1; |
609 | 613 | } |
610 | 614 | |
@@ -613,8 +617,7 @@ discard block |
||
613 | 617 | } |
614 | 618 | } |
615 | 619 | |
616 | - } |
|
617 | - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
620 | + } else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
618 | 621 | |
619 | 622 | $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); |
620 | 623 | |
@@ -622,7 +625,9 @@ discard block |
||
622 | 625 | /** |
623 | 626 | * @var $object Facture |
624 | 627 | */ |
625 | - if($object->element=='facture') $object->deleteline($idLine); |
|
628 | + if($object->element=='facture') { |
|
629 | + $object->deleteline($idLine); |
|
630 | + } |
|
626 | 631 | /** |
627 | 632 | * @var $object Facture fournisseur |
628 | 633 | */ |
@@ -633,18 +638,25 @@ discard block |
||
633 | 638 | /** |
634 | 639 | * @var $object Propal |
635 | 640 | */ |
636 | - else if($object->element=='propal') $object->deleteline($idLine); |
|
641 | + else if($object->element=='propal') { |
|
642 | + $object->deleteline($idLine); |
|
643 | + } |
|
637 | 644 | /** |
638 | 645 | * @var $object Propal Fournisseur |
639 | 646 | */ |
640 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); |
|
647 | + else if($object->element=='supplier_proposal') { |
|
648 | + $object->deleteline($idLine); |
|
649 | + } |
|
641 | 650 | /** |
642 | 651 | * @var $object Commande |
643 | 652 | */ |
644 | 653 | else if($object->element=='commande') |
645 | 654 | { |
646 | - if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); |
|
647 | - else $object->deleteline($idLine); |
|
655 | + if ((float) DOL_VERSION >= 5.0) { |
|
656 | + $object->deleteline($user, $idLine); |
|
657 | + } else { |
|
658 | + $object->deleteline($idLine); |
|
659 | + } |
|
648 | 660 | } |
649 | 661 | /** |
650 | 662 | * @var $object Commande fournisseur |
@@ -656,21 +668,26 @@ discard block |
||
656 | 668 | /** |
657 | 669 | * @var $object Facturerec |
658 | 670 | */ |
659 | - else if($object->element=='facturerec') $object->deleteline($idLine); |
|
671 | + else if($object->element=='facturerec') { |
|
672 | + $object->deleteline($idLine); |
|
673 | + } |
|
660 | 674 | } |
661 | 675 | |
662 | 676 | header('location:?id='.$object->id); |
663 | 677 | exit; |
664 | 678 | |
665 | - } |
|
666 | - else if ($action == 'duplicate') |
|
679 | + } else if ($action == 'duplicate') |
|
667 | 680 | { |
668 | 681 | $lineid = GETPOST('lineid', 'int'); |
669 | 682 | $nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); |
670 | 683 | |
671 | - if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
672 | - elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
673 | - else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
684 | + if ($nbDuplicate > 0) { |
|
685 | + setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
686 | + } elseif ($nbDuplicate == 0) { |
|
687 | + setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
688 | + } else { |
|
689 | + setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
690 | + } |
|
674 | 691 | |
675 | 692 | header('Location: ?id='.$object->id); |
676 | 693 | exit; |
@@ -750,17 +767,18 @@ discard block |
||
750 | 767 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; |
751 | 768 | if($l->rang>=$rang) { |
752 | 769 | //echo 'return!<br>'; |
753 | - if (!$return_all) return $total; |
|
754 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
755 | - } |
|
756 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
770 | + if (!$return_all) { |
|
771 | + return $total; |
|
772 | + } else { |
|
773 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
774 | + } |
|
775 | + } else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
757 | 776 | { |
758 | 777 | $total = 0; |
759 | 778 | $total_tva = 0; |
760 | 779 | $total_ttc = 0; |
761 | 780 | $TTotal_tva = array(); |
762 | - } |
|
763 | - elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
781 | + } elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
764 | 782 | $total += $l->total_ht; |
765 | 783 | $total_tva += $l->total_tva; |
766 | 784 | $TTotal_tva[$l->tva_tx] += $l->total_tva; |
@@ -768,8 +786,11 @@ discard block |
||
768 | 786 | } |
769 | 787 | |
770 | 788 | } |
771 | - if (!$return_all) return $total; |
|
772 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
789 | + if (!$return_all) { |
|
790 | + return $total; |
|
791 | + } else { |
|
792 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
793 | + } |
|
773 | 794 | } |
774 | 795 | |
775 | 796 | /* |
@@ -837,15 +858,18 @@ discard block |
||
837 | 858 | } |
838 | 859 | |
839 | 860 | |
840 | - if($line->qty==99) |
|
841 | - $pdf->SetFillColor(220,220,220); |
|
842 | - elseif ($line->qty==98) |
|
843 | - $pdf->SetFillColor(230,230,230); |
|
844 | - else |
|
845 | - $pdf->SetFillColor(240,240,240); |
|
861 | + if($line->qty==99) { |
|
862 | + $pdf->SetFillColor(220,220,220); |
|
863 | + } elseif ($line->qty==98) { |
|
864 | + $pdf->SetFillColor(230,230,230); |
|
865 | + } else { |
|
866 | + $pdf->SetFillColor(240,240,240); |
|
867 | + } |
|
846 | 868 | |
847 | 869 | $style = 'B'; |
848 | - if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
870 | + if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) { |
|
871 | + $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
872 | + } |
|
849 | 873 | |
850 | 874 | $pdf->SetFont('', $style, 9); |
851 | 875 | |
@@ -884,8 +908,7 @@ discard block |
||
884 | 908 | // $line->total_tva |
885 | 909 | // $line->total |
886 | 910 | // $line->total_ttc |
887 | - } |
|
888 | - else |
|
911 | + } else |
|
889 | 912 | { |
890 | 913 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
891 | 914 | if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation |
@@ -902,11 +925,14 @@ discard block |
||
902 | 925 | } |
903 | 926 | |
904 | 927 | $pdf->SetXY($pdf->postotalht, $posy); |
905 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
928 | + if($set_pagebreak_margin) { |
|
929 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
930 | + } |
|
906 | 931 | $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
907 | - } |
|
908 | - else{ |
|
909 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
932 | + } else{ |
|
933 | + if($set_pagebreak_margin) { |
|
934 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
935 | + } |
|
910 | 936 | } |
911 | 937 | |
912 | 938 | $posy = $posy + $cell_height; |
@@ -938,25 +964,40 @@ discard block |
||
938 | 964 | |
939 | 965 | |
940 | 966 | $style = ($line->qty==1) ? 'BU' : 'BUI'; |
941 | - if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
967 | + if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) { |
|
968 | + $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
969 | + } |
|
942 | 970 | |
943 | 971 | if($hideInnerLines) { |
944 | - if($line->qty==1)$pdf->SetFont('', $style, 9); |
|
945 | - else |
|
972 | + if($line->qty==1) { |
|
973 | + $pdf->SetFont('', $style, 9); |
|
974 | + } else |
|
946 | 975 | { |
947 | - if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
976 | + if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) { |
|
977 | + $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
978 | + } |
|
948 | 979 | $pdf->SetFont('', $style, 9); |
949 | 980 | } |
950 | - } |
|
951 | - else { |
|
981 | + } else { |
|
952 | 982 | |
953 | - if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
954 | - else $pdf->SetFont('', $style, 9); |
|
983 | + if($line->qty==1) { |
|
984 | + $pdf->SetFont('', $style, 9); |
|
985 | + } |
|
986 | + //TODO if super utile |
|
987 | + else { |
|
988 | + $pdf->SetFont('', $style, 9); |
|
989 | + } |
|
955 | 990 | |
956 | 991 | } |
957 | 992 | |
958 | - if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine |
|
959 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML |
|
993 | + if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) { |
|
994 | + $pdf->MultiCell($w, $h, $label, 0, 'L'); |
|
995 | + } |
|
996 | + // Pas de HTML dans la chaine |
|
997 | + else { |
|
998 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); |
|
999 | + } |
|
1000 | + // et maintenant avec du HTML |
|
960 | 1001 | |
961 | 1002 | if($description && !$hidedesc) { |
962 | 1003 | $posy = $pdf->GetY(); |
@@ -980,8 +1021,7 @@ discard block |
||
980 | 1021 | |
981 | 1022 | if(is_array($parameters)) { |
982 | 1023 | $i = & $parameters['i']; |
983 | - } |
|
984 | - else { |
|
1024 | + } else { |
|
985 | 1025 | $i = (int)$parameters; |
986 | 1026 | } |
987 | 1027 | |
@@ -1003,17 +1043,14 @@ discard block |
||
1003 | 1043 | |
1004 | 1044 | if((float)DOL_VERSION<=3.6) { |
1005 | 1045 | return ''; |
1006 | - } |
|
1007 | - else if((float)DOL_VERSION>=3.8) { |
|
1046 | + } else if((float)DOL_VERSION>=3.8) { |
|
1008 | 1047 | return 1; |
1009 | 1048 | } |
1010 | 1049 | |
1011 | - } |
|
1012 | - elseif(!empty($hideprices)) { |
|
1050 | + } elseif(!empty($hideprices)) { |
|
1013 | 1051 | $this->resprints = $object->lines[$parameters['i']]->qty; |
1014 | 1052 | return 1; |
1015 | - } |
|
1016 | - elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1053 | + } elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1017 | 1054 | { |
1018 | 1055 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
1019 | 1056 | $hidedetails = (int)GETPOST('hidedetails'); |
@@ -1023,10 +1060,16 @@ discard block |
||
1023 | 1060 | } |
1024 | 1061 | } |
1025 | 1062 | |
1026 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1027 | - else $i = (int)$parameters; |
|
1063 | + if(is_array($parameters)) { |
|
1064 | + $i = & $parameters['i']; |
|
1065 | + } else { |
|
1066 | + $i = (int)$parameters; |
|
1067 | + } |
|
1028 | 1068 | |
1029 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1069 | + if (empty($object->lines[$i])) { |
|
1070 | + return 0; |
|
1071 | + } |
|
1072 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1030 | 1073 | |
1031 | 1074 | $object->lines[$i]->fetch_optionals(); |
1032 | 1075 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1050,16 +1093,17 @@ discard block |
||
1050 | 1093 | |
1051 | 1094 | if((float)DOL_VERSION<=3.6) { |
1052 | 1095 | return ''; |
1053 | - } |
|
1054 | - else if((float)DOL_VERSION>=3.8) { |
|
1096 | + } else if((float)DOL_VERSION>=3.8) { |
|
1055 | 1097 | return 1; |
1056 | 1098 | } |
1057 | 1099 | |
1058 | - } |
|
1059 | - elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1100 | + } elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1060 | 1101 | { |
1061 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1062 | - else $i = (int)$parameters; |
|
1102 | + if(is_array($parameters)) { |
|
1103 | + $i = & $parameters['i']; |
|
1104 | + } else { |
|
1105 | + $i = (int)$parameters; |
|
1106 | + } |
|
1063 | 1107 | |
1064 | 1108 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1065 | 1109 | { |
@@ -1081,8 +1125,11 @@ discard block |
||
1081 | 1125 | } |
1082 | 1126 | } |
1083 | 1127 | if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){ |
1084 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1085 | - else $i = (int)$parameters; |
|
1128 | + if(is_array($parameters)) { |
|
1129 | + $i = & $parameters['i']; |
|
1130 | + } else { |
|
1131 | + $i = (int)$parameters; |
|
1132 | + } |
|
1086 | 1133 | $this->resprints = price($object->lines[$i]->total_ht); |
1087 | 1134 | } |
1088 | 1135 | if (!empty($hideprices) |
@@ -1108,14 +1155,16 @@ discard block |
||
1108 | 1155 | |
1109 | 1156 | if((float)DOL_VERSION<=3.6) { |
1110 | 1157 | return ''; |
1111 | - } |
|
1112 | - else if((float)DOL_VERSION>=3.8) { |
|
1158 | + } else if((float)DOL_VERSION>=3.8) { |
|
1113 | 1159 | return 1; |
1114 | 1160 | } |
1115 | 1161 | } |
1116 | 1162 | |
1117 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1118 | - else $i = (int)$parameters; |
|
1163 | + if(is_array($parameters)) { |
|
1164 | + $i = & $parameters['i']; |
|
1165 | + } else { |
|
1166 | + $i = (int)$parameters; |
|
1167 | + } |
|
1119 | 1168 | |
1120 | 1169 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1121 | 1170 | { |
@@ -1137,14 +1186,16 @@ discard block |
||
1137 | 1186 | |
1138 | 1187 | if((float)DOL_VERSION<=3.6) { |
1139 | 1188 | return ''; |
1140 | - } |
|
1141 | - else if((float)DOL_VERSION>=3.8) { |
|
1189 | + } else if((float)DOL_VERSION>=3.8) { |
|
1142 | 1190 | return 1; |
1143 | 1191 | } |
1144 | 1192 | } |
1145 | 1193 | |
1146 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1147 | - else $i = (int)$parameters; |
|
1194 | + if(is_array($parameters)) { |
|
1195 | + $i = & $parameters['i']; |
|
1196 | + } else { |
|
1197 | + $i = (int)$parameters; |
|
1198 | + } |
|
1148 | 1199 | |
1149 | 1200 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1150 | 1201 | { |
@@ -1166,13 +1217,15 @@ discard block |
||
1166 | 1217 | |
1167 | 1218 | if((float)DOL_VERSION<=3.6) { |
1168 | 1219 | return ''; |
1169 | - } |
|
1170 | - else if((float)DOL_VERSION>=3.8) { |
|
1220 | + } else if((float)DOL_VERSION>=3.8) { |
|
1171 | 1221 | return 1; |
1172 | 1222 | } |
1173 | 1223 | } |
1174 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1175 | - else $i = (int)$parameters; |
|
1224 | + if(is_array($parameters)) { |
|
1225 | + $i = & $parameters['i']; |
|
1226 | + } else { |
|
1227 | + $i = (int)$parameters; |
|
1228 | + } |
|
1176 | 1229 | |
1177 | 1230 | if (!empty($hideprices) |
1178 | 1231 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1195,14 +1248,16 @@ discard block |
||
1195 | 1248 | $this->resprints = ' '; |
1196 | 1249 | if((float)DOL_VERSION<=3.6) { |
1197 | 1250 | return ''; |
1198 | - } |
|
1199 | - else if((float)DOL_VERSION>=3.8) { |
|
1251 | + } else if((float)DOL_VERSION>=3.8) { |
|
1200 | 1252 | return 1; |
1201 | 1253 | } |
1202 | 1254 | } |
1203 | 1255 | |
1204 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1205 | - else $i = (int)$parameters; |
|
1256 | + if(is_array($parameters)) { |
|
1257 | + $i = & $parameters['i']; |
|
1258 | + } else { |
|
1259 | + $i = (int)$parameters; |
|
1260 | + } |
|
1206 | 1261 | |
1207 | 1262 | if (!empty($hideprices) |
1208 | 1263 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1226,16 +1281,21 @@ discard block |
||
1226 | 1281 | |
1227 | 1282 | if((float)DOL_VERSION<=3.6) { |
1228 | 1283 | return ''; |
1229 | - } |
|
1230 | - else if((float)DOL_VERSION>=3.8) { |
|
1284 | + } else if((float)DOL_VERSION>=3.8) { |
|
1231 | 1285 | return 1; |
1232 | 1286 | } |
1233 | 1287 | } |
1234 | 1288 | |
1235 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1236 | - else $i = (int)$parameters; |
|
1289 | + if(is_array($parameters)) { |
|
1290 | + $i = & $parameters['i']; |
|
1291 | + } else { |
|
1292 | + $i = (int)$parameters; |
|
1293 | + } |
|
1237 | 1294 | |
1238 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1295 | + if (empty($object->lines[$i])) { |
|
1296 | + return 0; |
|
1297 | + } |
|
1298 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1239 | 1299 | |
1240 | 1300 | $object->lines[$i]->fetch_optionals(); |
1241 | 1301 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1257,14 +1317,16 @@ discard block |
||
1257 | 1317 | $this->resprints = ' '; |
1258 | 1318 | if((float)DOL_VERSION<=3.6) { |
1259 | 1319 | return ''; |
1260 | - } |
|
1261 | - else if((float)DOL_VERSION>=3.8) { |
|
1320 | + } else if((float)DOL_VERSION>=3.8) { |
|
1262 | 1321 | return 1; |
1263 | 1322 | } |
1264 | 1323 | } |
1265 | 1324 | |
1266 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1267 | - else $i = (int)$parameters; |
|
1325 | + if(is_array($parameters)) { |
|
1326 | + $i = & $parameters['i']; |
|
1327 | + } else { |
|
1328 | + $i = (int)$parameters; |
|
1329 | + } |
|
1268 | 1330 | |
1269 | 1331 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1270 | 1332 | { |
@@ -1294,7 +1356,9 @@ discard block |
||
1294 | 1356 | } |
1295 | 1357 | } |
1296 | 1358 | |
1297 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1359 | + if (!empty($TLineTitle)) { |
|
1360 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1361 | + } |
|
1298 | 1362 | } |
1299 | 1363 | |
1300 | 1364 | } |
@@ -1308,8 +1372,12 @@ discard block |
||
1308 | 1372 | $j=0; |
1309 | 1373 | foreach ($TLineTitle as $k => &$line) |
1310 | 1374 | { |
1311 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
|
1312 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; |
|
1375 | + if (!empty($line_reference) && $line->rang <= $line_reference->rang) { |
|
1376 | + continue; |
|
1377 | + } |
|
1378 | + if (!empty($line_reference) && $line->qty <= $line_reference->qty) { |
|
1379 | + break; |
|
1380 | + } |
|
1313 | 1381 | |
1314 | 1382 | if ($line->qty == $level) |
1315 | 1383 | { |
@@ -1343,7 +1411,9 @@ discard block |
||
1343 | 1411 | |
1344 | 1412 | $hidedetails = (int)GETPOST('hidedetails'); |
1345 | 1413 | |
1346 | - if(empty($hidedetails)) return false; |
|
1414 | + if(empty($hidedetails)) { |
|
1415 | + return false; |
|
1416 | + } |
|
1347 | 1417 | |
1348 | 1418 | // TODO can't add VAT to document without lines... :-/ |
1349 | 1419 | |
@@ -1396,7 +1466,9 @@ discard block |
||
1396 | 1466 | */ |
1397 | 1467 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
1398 | 1468 | |
1399 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; |
|
1469 | + if (TSubtotal::getNiveau($line) == 1) { |
|
1470 | + $line->TTotal_tva = $TTotal_tva; |
|
1471 | + } |
|
1400 | 1472 | $line->total_ht = $total; |
1401 | 1473 | $line->total_tva = $total_tva; |
1402 | 1474 | $line->total = $line->total_ht; |
@@ -1451,8 +1523,7 @@ discard block |
||
1451 | 1523 | } |
1452 | 1524 | |
1453 | 1525 | |
1454 | - } |
|
1455 | - elseif ($hidedetails) |
|
1526 | + } elseif ($hidedetails) |
|
1456 | 1527 | { |
1457 | 1528 | $TLines[] = $line; //Cas où je cache uniquement les prix des produits |
1458 | 1529 | } |
@@ -1523,7 +1594,9 @@ discard block |
||
1523 | 1594 | |
1524 | 1595 | if(!empty($hideprices)) { |
1525 | 1596 | foreach($object->lines as &$line) { |
1526 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
1597 | + if($line->fk_product_type!=9) { |
|
1598 | + $line->fk_parent_line = -1; |
|
1599 | + } |
|
1527 | 1600 | } |
1528 | 1601 | } |
1529 | 1602 | |
@@ -1544,7 +1617,9 @@ discard block |
||
1544 | 1617 | |
1545 | 1618 | if($line->qty>90) { |
1546 | 1619 | |
1547 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
|
1620 | + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
1621 | + $label .= ' '.$this->getTitle($object, $line); |
|
1622 | + } |
|
1548 | 1623 | |
1549 | 1624 | $pageBefore = $pdf->getPage(); |
1550 | 1625 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1562,8 +1637,7 @@ discard block |
||
1562 | 1637 | |
1563 | 1638 | $posy = $pdf->GetY(); |
1564 | 1639 | return 1; |
1565 | - } |
|
1566 | - else if ($line->qty < 10) { |
|
1640 | + } else if ($line->qty < 10) { |
|
1567 | 1641 | $pageBefore = $pdf->getPage(); |
1568 | 1642 | |
1569 | 1643 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1587,8 +1661,7 @@ discard block |
||
1587 | 1661 | // if($line->rowid==47) exit; |
1588 | 1662 | |
1589 | 1663 | return 0; |
1590 | - } |
|
1591 | - elseif (empty($object->lines[$parameters['i']])) |
|
1664 | + } elseif (empty($object->lines[$parameters['i']])) |
|
1592 | 1665 | { |
1593 | 1666 | $this->resprints = -1; |
1594 | 1667 | } |
@@ -1621,7 +1694,9 @@ discard block |
||
1621 | 1694 | |
1622 | 1695 | foreach ($object->lines as $line) |
1623 | 1696 | { |
1624 | - if ($line->id == $currentLine->id) break; |
|
1697 | + if ($line->id == $currentLine->id) { |
|
1698 | + break; |
|
1699 | + } |
|
1625 | 1700 | |
1626 | 1701 | $qty_search = 100 - $currentLine->qty; |
1627 | 1702 | |
@@ -1658,23 +1733,23 @@ discard block |
||
1658 | 1733 | { |
1659 | 1734 | $object->statut = 0; // hack for facture rec |
1660 | 1735 | $createRight = $user->rights->facture->creer; |
1661 | - } |
|
1662 | - elseif($object->element == 'order_supplier' ) |
|
1736 | + } elseif($object->element == 'order_supplier' ) |
|
1663 | 1737 | { |
1664 | 1738 | $createRight = $user->rights->fournisseur->commande->creer; |
1665 | - } |
|
1666 | - elseif($object->element == 'invoice_supplier' ) |
|
1739 | + } elseif($object->element == 'invoice_supplier' ) |
|
1667 | 1740 | { |
1668 | 1741 | $createRight = $user->rights->fournisseur->facture->creer; |
1669 | 1742 | } |
1670 | 1743 | |
1671 | 1744 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1672 | 1745 | null; |
1673 | - } |
|
1674 | - else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
1746 | + } else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
1675 | 1747 | { |
1676 | - if($object->element=='facture')$idvar = 'facid'; |
|
1677 | - else $idvar='id'; |
|
1748 | + if($object->element=='facture') { |
|
1749 | + $idvar = 'facid'; |
|
1750 | + } else { |
|
1751 | + $idvar='id'; |
|
1752 | + } |
|
1678 | 1753 | |
1679 | 1754 | if((float)DOL_VERSION <= 3.4) |
1680 | 1755 | { |
@@ -1700,20 +1775,44 @@ discard block |
||
1700 | 1775 | <?php |
1701 | 1776 | } |
1702 | 1777 | |
1703 | - if(empty($line->description)) $line->description = $line->desc; |
|
1778 | + if(empty($line->description)) { |
|
1779 | + $line->description = $line->desc; |
|
1780 | + } |
|
1704 | 1781 | |
1705 | 1782 | $colspan = 5; |
1706 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
1707 | - if($object->element == 'order_supplier') $colspan = 3; |
|
1708 | - if($object->element == 'invoice_supplier') $colspan = 4; |
|
1709 | - if($object->element == 'supplier_proposal') $colspan = 4; |
|
1710 | - if(!empty($conf->multicurrency->enabled)) $colspan+=2; |
|
1711 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1712 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
1713 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1714 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1715 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1716 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
1783 | + if($object->element == 'facturerec' ) { |
|
1784 | + $colspan = 3; |
|
1785 | + } |
|
1786 | + if($object->element == 'order_supplier') { |
|
1787 | + $colspan = 3; |
|
1788 | + } |
|
1789 | + if($object->element == 'invoice_supplier') { |
|
1790 | + $colspan = 4; |
|
1791 | + } |
|
1792 | + if($object->element == 'supplier_proposal') { |
|
1793 | + $colspan = 4; |
|
1794 | + } |
|
1795 | + if(!empty($conf->multicurrency->enabled)) { |
|
1796 | + $colspan+=2; |
|
1797 | + } |
|
1798 | + if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { |
|
1799 | + $colspan++; |
|
1800 | + } |
|
1801 | + if(!empty($conf->margin->enabled)) { |
|
1802 | + $colspan++; |
|
1803 | + } |
|
1804 | + if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
1805 | + $colspan++; |
|
1806 | + } |
|
1807 | + if(!empty($conf->global->DISPLAY_MARK_RATES)) { |
|
1808 | + $colspan++; |
|
1809 | + } |
|
1810 | + if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { |
|
1811 | + $colspan++; |
|
1812 | + } |
|
1813 | + if(!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
1814 | + $colspan++; |
|
1815 | + } |
|
1717 | 1816 | |
1718 | 1817 | /* Titre */ |
1719 | 1818 | //var_dump($line); |
@@ -1726,23 +1825,36 @@ discard block |
||
1726 | 1825 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
1727 | 1826 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
1728 | 1827 | { |
1729 | - if($line->qty==99) print 'background:#adadcf'; |
|
1730 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1731 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
1732 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
1733 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
1734 | - else if($line->qty==50) print ''; |
|
1735 | - else print 'background:#eeeeff;'; |
|
1828 | + if($line->qty==99) { |
|
1829 | + print 'background:#adadcf'; |
|
1830 | + } else if($line->qty==98) { |
|
1831 | + print 'background:#ddddff;'; |
|
1832 | + } else if($line->qty<=97 && $line->qty>=91) { |
|
1833 | + print 'background:#eeeeff;'; |
|
1834 | + } else if($line->qty==1) { |
|
1835 | + print 'background:#adadcf;'; |
|
1836 | + } else if($line->qty==2) { |
|
1837 | + print 'background:#ddddff;'; |
|
1838 | + } else if($line->qty==50) { |
|
1839 | + print ''; |
|
1840 | + } else { |
|
1841 | + print 'background:#eeeeff;'; |
|
1842 | + } |
|
1736 | 1843 | |
1737 | 1844 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
1738 | - } |
|
1739 | - else |
|
1845 | + } else |
|
1740 | 1846 | { |
1741 | - if($line->qty==99) print 'background:#ddffdd'; |
|
1742 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1743 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
1744 | - else if($line->qty==50) print ''; |
|
1745 | - else print 'background:#eeffee;' ; |
|
1847 | + if($line->qty==99) { |
|
1848 | + print 'background:#ddffdd'; |
|
1849 | + } else if($line->qty==98) { |
|
1850 | + print 'background:#ddddff;'; |
|
1851 | + } else if($line->qty==2) { |
|
1852 | + print 'background:#eeeeff; '; |
|
1853 | + } else if($line->qty==50) { |
|
1854 | + print ''; |
|
1855 | + } else { |
|
1856 | + print 'background:#eeffee;' ; |
|
1857 | + } |
|
1746 | 1858 | } |
1747 | 1859 | |
1748 | 1860 | ?>;"> |
@@ -1765,13 +1877,11 @@ discard block |
||
1765 | 1877 | $qty_displayed = $line->qty; |
1766 | 1878 | print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span> '; |
1767 | 1879 | |
1768 | - } |
|
1769 | - else if (TSubtotal::isSubtotal($line)) |
|
1880 | + } else if (TSubtotal::isSubtotal($line)) |
|
1770 | 1881 | { |
1771 | 1882 | $qty_displayed = 100 - $line->qty; |
1772 | 1883 | print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span> '; |
1773 | - } |
|
1774 | - else |
|
1884 | + } else |
|
1775 | 1885 | { |
1776 | 1886 | $isFreeText = true; |
1777 | 1887 | } |
@@ -1792,9 +1902,13 @@ discard block |
||
1792 | 1902 | } |
1793 | 1903 | |
1794 | 1904 | $readonlyForSituation = ''; |
1795 | - if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly'; |
|
1905 | + if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) { |
|
1906 | + $readonlyForSituation = 'readonly'; |
|
1907 | + } |
|
1796 | 1908 | |
1797 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
1909 | + if (!$isFreeText) { |
|
1910 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
1911 | + } |
|
1798 | 1912 | |
1799 | 1913 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
1800 | 1914 | { |
@@ -1802,8 +1916,12 @@ discard block |
||
1802 | 1916 | for ($j=1; $j<10; $j++) |
1803 | 1917 | { |
1804 | 1918 | if (!empty($readonlyForSituation)) { |
1805 | - if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
1806 | - } else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
1919 | + if ($qty_displayed == $j) { |
|
1920 | + $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
1921 | + } |
|
1922 | + } else { |
|
1923 | + $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
1924 | + } |
|
1807 | 1925 | } |
1808 | 1926 | $select .= '</select> '; |
1809 | 1927 | |
@@ -1819,15 +1937,18 @@ discard block |
||
1819 | 1937 | $form = new Form($db); |
1820 | 1938 | echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; |
1821 | 1939 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; |
1822 | - if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
1940 | + if (empty($readonlyForSituation)) { |
|
1941 | + echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
1942 | + } |
|
1823 | 1943 | echo '</select> '; |
1824 | 1944 | |
1825 | 1945 | if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION) |
1826 | 1946 | { |
1827 | 1947 | echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%'; |
1828 | 1948 | } |
1949 | + } else if ($isFreeText) { |
|
1950 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
1829 | 1951 | } |
1830 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
1831 | 1952 | echo '</div>'; |
1832 | 1953 | |
1833 | 1954 | if($line->qty<10) { |
@@ -1847,8 +1968,7 @@ discard block |
||
1847 | 1968 | $doleditor->Create(); |
1848 | 1969 | } |
1849 | 1970 | |
1850 | - } |
|
1851 | - else { |
|
1971 | + } else { |
|
1852 | 1972 | |
1853 | 1973 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
1854 | 1974 | { |
@@ -1856,14 +1976,19 @@ discard block |
||
1856 | 1976 | { |
1857 | 1977 | echo str_repeat(' ', $line->qty-1); |
1858 | 1978 | |
1859 | - if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
1860 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
1979 | + if (TSubtotal::isTitle($line)) { |
|
1980 | + print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
1981 | + } else { |
|
1982 | + print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
1983 | + } |
|
1861 | 1984 | } |
1862 | - } |
|
1863 | - else |
|
1985 | + } else |
|
1864 | 1986 | { |
1865 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
1866 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
1987 | + if($line->qty<=1) { |
|
1988 | + print img_picto('', 'subtotal@subtotal'); |
|
1989 | + } else if($line->qty==2) { |
|
1990 | + print img_picto('', 'subsubtotal@subtotal').' '; |
|
1991 | + } |
|
1867 | 1992 | } |
1868 | 1993 | |
1869 | 1994 | |
@@ -1873,21 +1998,26 @@ discard block |
||
1873 | 1998 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
1874 | 1999 | |
1875 | 2000 | if (empty($line->label)) { |
1876 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
|
1877 | - else print $line->description; |
|
1878 | - } |
|
1879 | - else { |
|
2001 | + if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
2002 | + print $line->description.' '.$this->getTitle($object, $line); |
|
2003 | + } else { |
|
2004 | + print $line->description; |
|
2005 | + } |
|
2006 | + } else { |
|
1880 | 2007 | |
1881 | 2008 | if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
1882 | 2009 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
1883 | - } |
|
1884 | - else{ |
|
2010 | + } else{ |
|
1885 | 2011 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
1886 | 2012 | } |
1887 | 2013 | |
1888 | 2014 | } |
1889 | - if($line->qty>90) print ' : '; |
|
1890 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2015 | + if($line->qty>90) { |
|
2016 | + print ' : '; |
|
2017 | + } |
|
2018 | + if($line->info_bits > 0) { |
|
2019 | + echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2020 | + } |
|
1891 | 2021 | |
1892 | 2022 | |
1893 | 2023 | |
@@ -1924,11 +2054,12 @@ discard block |
||
1924 | 2054 | </script> |
1925 | 2055 | <?php |
1926 | 2056 | |
1927 | - } |
|
1928 | - else{ |
|
2057 | + } else{ |
|
1929 | 2058 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
1930 | 2059 | { |
1931 | - if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2060 | + if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) { |
|
2061 | + echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2062 | + } |
|
1932 | 2063 | } |
1933 | 2064 | |
1934 | 2065 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
@@ -1997,7 +2128,9 @@ discard block |
||
1997 | 2128 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
1998 | 2129 | |
1999 | 2130 | $colspan+=3; $mode = 'view'; |
2000 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
2131 | + if($action === 'editline' && $line->rowid == GETPOST('lineid')) { |
|
2132 | + $mode = 'edit'; |
|
2133 | + } |
|
2001 | 2134 | |
2002 | 2135 | $ex_element = $line->element; |
2003 | 2136 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
@@ -2166,10 +2299,9 @@ discard block |
||
2166 | 2299 | |
2167 | 2300 | if(TSubtotal::isTitle($line)){ |
2168 | 2301 | $ThtmlData['data-issubtotal'] = 'title'; |
2169 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2302 | + } elseif(TSubtotal::isSubtotal($line)){ |
|
2170 | 2303 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
2171 | - } |
|
2172 | - else{ |
|
2304 | + } else{ |
|
2173 | 2305 | $ThtmlData['data-issubtotal'] = 'freetext'; |
2174 | 2306 | } |
2175 | 2307 | |
@@ -2179,7 +2311,9 @@ discard block |
||
2179 | 2311 | |
2180 | 2312 | // hook |
2181 | 2313 | $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
2182 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2314 | + if ($reshook < 0) { |
|
2315 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2316 | + } |
|
2183 | 2317 | if ($reshook>0) |
2184 | 2318 | { |
2185 | 2319 | $ThtmlData = $hookmanager->resArray; |
@@ -13,18 +13,23 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @var $object Facture |
15 | 15 | */ |
16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
16 | + if($object->element=='facture') { |
|
17 | + $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
18 | + } |
|
17 | 19 | /** |
18 | 20 | * @var $object Propal |
19 | 21 | */ |
20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
22 | + else if($object->element=='propal') { |
|
23 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
24 | + } |
|
21 | 25 | /** |
22 | 26 | * @var $object Commande |
23 | 27 | */ |
24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
28 | + else if($object->element=='commande') { |
|
29 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
30 | + } |
|
25 | 31 | |
26 | - } |
|
27 | - else { |
|
32 | + } else { |
|
28 | 33 | $desc = ''; |
29 | 34 | if ((float) DOL_VERSION < 6 || $qty==50) { |
30 | 35 | $desc = $label; |
@@ -34,7 +39,9 @@ discard block |
||
34 | 39 | /** |
35 | 40 | * @var $object Facture |
36 | 41 | */ |
37 | - if($object->element=='facture') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
42 | + if($object->element=='facture') { |
|
43 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
44 | + } |
|
38 | 45 | /** |
39 | 46 | * @var $object Facture fournisseur |
40 | 47 | */ |
@@ -46,16 +53,22 @@ discard block |
||
46 | 53 | /** |
47 | 54 | * @var $object Propal |
48 | 55 | */ |
49 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
56 | + else if($object->element=='propal') { |
|
57 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
58 | + } |
|
50 | 59 | /** |
51 | 60 | * @var $object Propal Fournisseur |
52 | 61 | */ |
53 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
62 | + else if($object->element=='supplier_proposal') { |
|
63 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
64 | + } |
|
54 | 65 | |
55 | 66 | /** |
56 | 67 | * @var $object Commande |
57 | 68 | */ |
58 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
69 | + else if($object->element=='commande') { |
|
70 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
71 | + } |
|
59 | 72 | /** |
60 | 73 | * @var $object Commande fournisseur |
61 | 74 | */ |
@@ -66,7 +79,9 @@ discard block |
||
66 | 79 | /** |
67 | 80 | * @var $object Facturerec |
68 | 81 | */ |
69 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
82 | + else if($object->element=='facturerec') { |
|
83 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
84 | + } |
|
70 | 85 | |
71 | 86 | } |
72 | 87 | |
@@ -88,8 +103,9 @@ discard block |
||
88 | 103 | // Define output language |
89 | 104 | $outputlangs = $langs; |
90 | 105 | $newlang = GETPOST('lang_id', 'alpha'); |
91 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
92 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
106 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
107 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
108 | + } |
|
93 | 109 | if (! empty($newlang)) { |
94 | 110 | $outputlangs = new Translate("", $conf); |
95 | 111 | $outputlangs->setDefaultLang($newlang); |
@@ -98,13 +114,18 @@ discard block |
||
98 | 114 | $ret = $object->fetch($object->id); // Reload to get new records |
99 | 115 | if ((float) DOL_VERSION <= 3.6) |
100 | 116 | { |
101 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
102 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
103 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
104 | - } |
|
105 | - else |
|
117 | + if ($object->element == 'propal') { |
|
118 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
119 | + } elseif ($object->element == 'commande') { |
|
120 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
121 | + } elseif ($object->element == 'facture') { |
|
122 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
123 | + } |
|
124 | + } else |
|
106 | 125 | { |
107 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
126 | + if ($object->element!= 'facturerec') { |
|
127 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
128 | + } |
|
108 | 129 | } |
109 | 130 | } |
110 | 131 | } |
@@ -118,7 +139,9 @@ discard block |
||
118 | 139 | */ |
119 | 140 | public static function updateRang(&$object, $rang_start, $move_to=1) |
120 | 141 | { |
121 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
142 | + if (!class_exists('GenericObject')) { |
|
143 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
144 | + } |
|
122 | 145 | |
123 | 146 | $row=new GenericObject($object->db); |
124 | 147 | $row->table_element_line = $object->table_element_line; |
@@ -127,7 +150,9 @@ discard block |
||
127 | 150 | |
128 | 151 | foreach ($object->lines as &$line) |
129 | 152 | { |
130 | - if ($line->rang < $rang_start) continue; |
|
153 | + if ($line->rang < $rang_start) { |
|
154 | + continue; |
|
155 | + } |
|
131 | 156 | |
132 | 157 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
133 | 158 | } |
@@ -150,21 +175,28 @@ discard block |
||
150 | 175 | foreach ($TTitle_reverse as $k => $title_line) |
151 | 176 | { |
152 | 177 | $title_niveau = self::getNiveau($title_line); |
153 | - if ($title_niveau < $level_new_title) break; |
|
178 | + if ($title_niveau < $level_new_title) { |
|
179 | + break; |
|
180 | + } |
|
154 | 181 | |
155 | 182 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
156 | 183 | |
157 | 184 | if (is_numeric($rang_to_add)) |
158 | 185 | { |
159 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
186 | + if ($rang_to_add != -1) { |
|
187 | + self::updateRang($object, $rang_to_add); |
|
188 | + } |
|
160 | 189 | |
161 | 190 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
162 | 191 | |
163 | 192 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
164 | 193 | if ($rang_to_add != -1) |
165 | 194 | { |
166 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
167 | - else $object->fetch($object->id); |
|
195 | + if (method_exists($object, 'fetch_lines')) { |
|
196 | + $object->fetch_lines(); |
|
197 | + } else { |
|
198 | + $object->fetch($object->id); |
|
199 | + } |
|
168 | 200 | } |
169 | 201 | } |
170 | 202 | } |
@@ -194,7 +226,9 @@ discard block |
||
194 | 226 | |
195 | 227 | foreach ($TTitle as $k => $title_line) |
196 | 228 | { |
197 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
229 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
230 | + unset($TTitle[$k]); |
|
231 | + } |
|
198 | 232 | } |
199 | 233 | |
200 | 234 | return $TTitle; |
@@ -211,23 +245,41 @@ discard block |
||
211 | 245 | */ |
212 | 246 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
213 | 247 | { |
214 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
248 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
249 | + return false; |
|
250 | + } |
|
215 | 251 | |
216 | 252 | $title_niveau = self::getNiveau($title_line); |
217 | 253 | foreach ($object->lines as &$line) |
218 | 254 | { |
219 | - if ($line->rang <= $title_line->rang) continue; |
|
220 | - if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
221 | - if (!self::isSubtotal($line)) continue; |
|
255 | + if ($line->rang <= $title_line->rang) { |
|
256 | + continue; |
|
257 | + } |
|
258 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
259 | + return false; |
|
260 | + } |
|
261 | + // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
262 | + if (!self::isSubtotal($line)) { |
|
263 | + continue; |
|
264 | + } |
|
222 | 265 | |
223 | 266 | $subtotal_niveau = self::getNiveau($line); |
224 | 267 | |
225 | 268 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
226 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
227 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
269 | + if ($subtotal_niveau == $title_niveau) { |
|
270 | + return true; |
|
271 | + } |
|
272 | + // niveau égale => Ok mon titre a un sous-total |
|
273 | + elseif ($subtotal_niveau < $title_niveau) { |
|
274 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
228 | 275 | { |
229 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
230 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
276 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
277 | + } |
|
278 | + // mode strict niveau pas égale donc faux |
|
279 | + else { |
|
280 | + return true; |
|
281 | + } |
|
282 | + // mode libre => OK je considère que mon titre à un sous-total |
|
231 | 283 | } |
232 | 284 | } |
233 | 285 | |
@@ -275,16 +327,19 @@ discard block |
||
275 | 327 | |
276 | 328 | foreach ($object->lines as &$l) |
277 | 329 | { |
278 | - if ($l->rang <= $line->rang) continue; |
|
279 | - elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break; |
|
280 | - elseif (self::isModSubtotalLine($l)) continue; |
|
330 | + if ($l->rang <= $line->rang) { |
|
331 | + continue; |
|
332 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) { |
|
333 | + break; |
|
334 | + } elseif (self::isModSubtotalLine($l)) { |
|
335 | + continue; |
|
336 | + } |
|
281 | 337 | |
282 | 338 | if (!empty($l->array_options['options_subtotal_nc'])) |
283 | 339 | { |
284 | 340 | $tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type); |
285 | 341 | $TTot['total_options'] += $tabprice[0]; // total ht |
286 | - } |
|
287 | - else |
|
342 | + } else |
|
288 | 343 | { |
289 | 344 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
290 | 345 | $TTot['total_ht'] += $l->total_ht; |
@@ -303,29 +358,41 @@ discard block |
||
303 | 358 | |
304 | 359 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
305 | 360 | { |
306 | - if (empty($fk_commandedet)) return false; |
|
361 | + if (empty($fk_commandedet)) { |
|
362 | + return false; |
|
363 | + } |
|
307 | 364 | |
308 | 365 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
309 | 366 | $resql = $db->query($sql); |
310 | 367 | |
311 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
312 | - else return false; |
|
368 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
369 | + return $row->fk_commande; |
|
370 | + } else { |
|
371 | + return false; |
|
372 | + } |
|
313 | 373 | } |
314 | 374 | |
315 | 375 | public static function getLastLineOrderId(&$db, $fk_commande) |
316 | 376 | { |
317 | - if (empty($fk_commande)) return false; |
|
377 | + if (empty($fk_commande)) { |
|
378 | + return false; |
|
379 | + } |
|
318 | 380 | |
319 | 381 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
320 | 382 | $resql = $db->query($sql); |
321 | 383 | |
322 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
323 | - else return false; |
|
384 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
385 | + return $row->rowid; |
|
386 | + } else { |
|
387 | + return false; |
|
388 | + } |
|
324 | 389 | } |
325 | 390 | |
326 | 391 | public static function getParentTitleOfLine(&$object, $i) |
327 | 392 | { |
328 | - if ($i <= 0) return false; |
|
393 | + if ($i <= 0) { |
|
394 | + return false; |
|
395 | + } |
|
329 | 396 | |
330 | 397 | $skip_title = 0; |
331 | 398 | // Je parcours les lignes précédentes |
@@ -344,8 +411,7 @@ discard block |
||
344 | 411 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
345 | 412 | return $line; |
346 | 413 | break; |
347 | - } |
|
348 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
414 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
349 | 415 | { |
350 | 416 | // Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux) |
351 | 417 | $skip_title++; |
@@ -360,7 +426,9 @@ discard block |
||
360 | 426 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
361 | 427 | if($res && $level > -1) { |
362 | 428 | return $line->qty == $level; |
363 | - } else return $res; |
|
429 | + } else { |
|
430 | + return $res; |
|
431 | + } |
|
364 | 432 | |
365 | 433 | } |
366 | 434 | |
@@ -387,10 +455,14 @@ discard block |
||
387 | 455 | // editeur wysiwyg |
388 | 456 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
389 | 457 | $nbrows=ROWS_2; |
390 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
458 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
459 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
460 | + } |
|
391 | 461 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
392 | 462 | $toolbarname='dolibarr_details'; |
393 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
463 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
464 | + $toolbarname='dolibarr_notes'; |
|
465 | + } |
|
394 | 466 | $text = !empty($line->description)?$line->description:$line->label; |
395 | 467 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
396 | 468 | return $doleditor->Create(1); |
@@ -405,12 +477,10 @@ discard block |
||
405 | 477 | { |
406 | 478 | $object->statut = 0; // hack for facture rec |
407 | 479 | $createRight = $user->rights->facture->creer; |
408 | - } |
|
409 | - elseif($object->element == 'order_supplier' ) |
|
480 | + } elseif($object->element == 'order_supplier' ) |
|
410 | 481 | { |
411 | 482 | $createRight = $user->rights->fournisseur->commande->creer; |
412 | - } |
|
413 | - elseif($object->element == 'invoice_supplier' ) |
|
483 | + } elseif($object->element == 'invoice_supplier' ) |
|
414 | 484 | { |
415 | 485 | $createRight = $user->rights->fournisseur->facture->creer; |
416 | 486 | } |
@@ -483,8 +553,9 @@ discard block |
||
483 | 553 | |
484 | 554 | $TLineAdded[] = $object->line; |
485 | 555 | // Error from addline |
486 | - if ($res <= 0) break; |
|
487 | - else |
|
556 | + if ($res <= 0) { |
|
557 | + break; |
|
558 | + } else |
|
488 | 559 | { |
489 | 560 | $object->line_from = $line; |
490 | 561 | // Call trigger |
@@ -506,8 +577,7 @@ discard block |
||
506 | 577 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
507 | 578 | } |
508 | 579 | return count($TLineAdded); |
509 | - } |
|
510 | - else |
|
580 | + } else |
|
511 | 581 | { |
512 | 582 | $object->db->rollback(); |
513 | 583 | return -1; |
@@ -523,10 +593,14 @@ discard block |
||
523 | 593 | global $langs; |
524 | 594 | |
525 | 595 | // Besoin de comparer sur les 2 formes d'écriture |
526 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
596 | + if (!$key_is_id) { |
|
597 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
598 | + } |
|
527 | 599 | |
528 | 600 | $TTitle_under_search = array(); |
529 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
601 | + if (!empty($under_title)) { |
|
602 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
603 | + } |
|
530 | 604 | |
531 | 605 | $TLine = array(); |
532 | 606 | $add_line = false; |
@@ -536,28 +610,37 @@ discard block |
||
536 | 610 | { |
537 | 611 | if (!$under_title_found && !empty($TTitle_under_search)) |
538 | 612 | { |
539 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
540 | - } |
|
541 | - else |
|
613 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
614 | + $under_title_found = true; |
|
615 | + } |
|
616 | + } else |
|
542 | 617 | { |
543 | 618 | if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
544 | 619 | { |
545 | - if ($key_is_id) $level = $line->qty; |
|
620 | + if ($key_is_id) { |
|
621 | + $level = $line->qty; |
|
622 | + } |
|
546 | 623 | |
547 | 624 | $add_line = true; |
548 | - if ($withBlockLine) $TLine[] = $line; |
|
625 | + if ($withBlockLine) { |
|
626 | + $TLine[] = $line; |
|
627 | + } |
|
549 | 628 | continue; |
550 | - } |
|
551 | - elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
629 | + } elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) { |
|
630 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
552 | 631 | { |
553 | 632 | if ($withBlockLine) $TLine[] = $line; |
633 | + } |
|
554 | 634 | break; |
555 | 635 | } |
556 | 636 | |
557 | 637 | if ($add_line) |
558 | 638 | { |
559 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
560 | - else $TLine[] = $line; |
|
639 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
640 | + continue; |
|
641 | + } else { |
|
642 | + $TLine[] = $line; |
|
643 | + } |
|
561 | 644 | } |
562 | 645 | } |
563 | 646 | } |
@@ -591,7 +674,9 @@ discard block |
||
591 | 674 | |
592 | 675 | case 'order_supplier': |
593 | 676 | $object->special_code = SELF::$module_number; |
594 | - if (empty($desc)) $desc = $label; |
|
677 | + if (empty($desc)) { |
|
678 | + $desc = $label; |
|
679 | + } |
|
595 | 680 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
596 | 681 | break; |
597 | 682 | |
@@ -601,7 +686,9 @@ discard block |
||
601 | 686 | |
602 | 687 | case 'invoice_supplier': |
603 | 688 | $object->special_code = SELF::$module_number; |
604 | - if (empty($desc)) $desc = $label; |
|
689 | + if (empty($desc)) { |
|
690 | + $desc = $label; |
|
691 | + } |
|
605 | 692 | $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
606 | 693 | break; |
607 | 694 | |
@@ -618,8 +705,11 @@ discard block |
||
618 | 705 | break; |
619 | 706 | } |
620 | 707 | |
621 | - if ($res <= 0) $object->db->rollback(); |
|
622 | - else $object->db->commit(); |
|
708 | + if ($res <= 0) { |
|
709 | + $object->db->rollback(); |
|
710 | + } else { |
|
711 | + $object->db->commit(); |
|
712 | + } |
|
623 | 713 | |
624 | 714 | return $res; |
625 | 715 | } |
@@ -629,24 +719,20 @@ discard block |
||
629 | 719 | global $db, $object; |
630 | 720 | |
631 | 721 | $TTitle = array(); |
632 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
633 | - else { |
|
722 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
634 | 723 | if ($origin_line->element == 'propaldet') |
635 | 724 | { |
636 | 725 | $object = new Propal($db); |
637 | 726 | $object->fetch($origin_line->fk_propal); |
638 | - } |
|
639 | - else if ($origin_line->element == 'commandedet') |
|
727 | + } else if ($origin_line->element == 'commandedet') |
|
640 | 728 | { |
641 | 729 | $object = new Commande($db); |
642 | 730 | $object->fetch($origin_line->fk_commande); |
643 | - } |
|
644 | - else if ($origin_line->element == 'facturedet') |
|
731 | + } else if ($origin_line->element == 'facturedet') |
|
645 | 732 | { |
646 | 733 | $object = new Facture($db); |
647 | 734 | $object->fetch($origin_line->fk_facture); |
648 | - } |
|
649 | - else |
|
735 | + } else |
|
650 | 736 | { |
651 | 737 | return $TTitle; |
652 | 738 | } |
@@ -656,8 +742,11 @@ discard block |
||
656 | 742 | $i = 0; |
657 | 743 | foreach ($object->lines as &$line) |
658 | 744 | { |
659 | - if ($origin_line->id == $line->id) break; |
|
660 | - else $i++; |
|
745 | + if ($origin_line->id == $line->id) { |
|
746 | + break; |
|
747 | + } else { |
|
748 | + $i++; |
|
749 | + } |
|
661 | 750 | } |
662 | 751 | |
663 | 752 | $i--; // Skip la ligne d'origine |
@@ -672,35 +761,43 @@ discard block |
||
672 | 761 | if (self::isSubtotal($object->lines[$y])) |
673 | 762 | { |
674 | 763 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
675 | - } |
|
676 | - elseif (self::isTitle($object->lines[$y])) |
|
764 | + } elseif (self::isTitle($object->lines[$y])) |
|
677 | 765 | { |
678 | 766 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
679 | 767 | { |
680 | 768 | $next_title_lvl_to_skip = 0; |
681 | 769 | continue; |
682 | - } |
|
683 | - else |
|
770 | + } else |
|
684 | 771 | { |
685 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
772 | + if (empty($object->lines[$y]->array_options)) { |
|
773 | + $object->lines[$y]->fetch_optionals(); |
|
774 | + } |
|
686 | 775 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
687 | 776 | |
688 | - if ($object->lines[$y]->qty == 1) break; |
|
777 | + if ($object->lines[$y]->qty == 1) { |
|
778 | + break; |
|
779 | + } |
|
689 | 780 | } |
690 | 781 | } |
691 | 782 | } |
692 | 783 | } |
693 | 784 | |
694 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
785 | + if ($reverse) { |
|
786 | + $TTitle = array_reverse($TTitle, true); |
|
787 | + } |
|
695 | 788 | |
696 | 789 | return $TTitle; |
697 | 790 | } |
698 | 791 | |
699 | 792 | public static function getNiveau(&$line) |
700 | 793 | { |
701 | - if (self::isTitle($line)) return $line->qty; |
|
702 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
703 | - else return 0; |
|
794 | + if (self::isTitle($line)) { |
|
795 | + return $line->qty; |
|
796 | + } elseif (self::isSubtotal($line)) { |
|
797 | + return 100 - $line->qty; |
|
798 | + } else { |
|
799 | + return 0; |
|
800 | + } |
|
704 | 801 | } |
705 | 802 | |
706 | 803 | /** |
@@ -725,10 +822,16 @@ discard block |
||
725 | 822 | $objmarge->marge_droite = 10; |
726 | 823 | |
727 | 824 | $objectref = dol_sanitizeFileName($object->ref); |
728 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
729 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
730 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
731 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
825 | + if ($object->element == 'propal') { |
|
826 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
827 | + } elseif ($object->element == 'commande') { |
|
828 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
829 | + } elseif ($object->element == 'facture') { |
|
830 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
831 | + } elseif ($object->element == 'facturerec') { |
|
832 | + return; |
|
833 | + } |
|
834 | + // no PDF for facturerec |
|
732 | 835 | else |
733 | 836 | { |
734 | 837 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -763,7 +866,9 @@ discard block |
||
763 | 866 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
764 | 867 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
765 | 868 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
766 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
869 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
870 | + $pdf->SetCompression(false); |
|
871 | + } |
|
767 | 872 | |
768 | 873 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
769 | 874 | |
@@ -773,7 +878,9 @@ discard block |
||
773 | 878 | |
774 | 879 | // New page |
775 | 880 | $pdf->AddPage(); |
776 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
881 | + if (! empty($tplidx)) { |
|
882 | + $pdf->useTemplate($tplidx); |
|
883 | + } |
|
777 | 884 | $pagenb++; |
778 | 885 | |
779 | 886 | |
@@ -829,8 +936,10 @@ discard block |
||
829 | 936 | { |
830 | 937 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
831 | 938 | } |
939 | + } else { |
|
940 | + $pdf->SetFont('','', $default_font_size - 1); |
|
832 | 941 | } |
833 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
942 | + // Into loop to work with multipage |
|
834 | 943 | |
835 | 944 | $pdf->SetTextColor(0,0,0); |
836 | 945 | |
@@ -852,9 +961,11 @@ discard block |
||
852 | 961 | $pdf->startTransaction(); |
853 | 962 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
854 | 963 | $pageposafter=$pdf->getPage(); |
855 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
964 | + if ($pageposafter > $pageposbefore) { |
|
965 | + // There is a pagebreak |
|
856 | 966 | { |
857 | 967 | $pdf->rollbackTransaction(true); |
968 | + } |
|
858 | 969 | $pageposafter=$pageposbefore; |
859 | 970 | //print $pageposafter.'-'.$pageposbefore;exit; |
860 | 971 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -863,23 +974,27 @@ discard block |
||
863 | 974 | $pageposafter=$pdf->getPage(); |
864 | 975 | $posyafter=$pdf->GetY(); |
865 | 976 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
866 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
977 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
978 | + // There is no space left for total+free text |
|
867 | 979 | { |
868 | 980 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
869 | 981 | { |
870 | 982 | $pdf->AddPage('','',true); |
871 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
872 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
983 | + } |
|
984 | + if (! empty($tplidx)) { |
|
985 | + $pdf->useTemplate($tplidx); |
|
986 | + } |
|
987 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
988 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
989 | + } |
|
873 | 990 | $pdf->setPage($pageposafter+1); |
874 | 991 | } |
875 | - } |
|
876 | - else |
|
992 | + } else |
|
877 | 993 | { |
878 | 994 | // We found a page break |
879 | 995 | $showpricebeforepagebreak=0; |
880 | 996 | } |
881 | - } |
|
882 | - else // No pagebreak |
|
997 | + } else // No pagebreak |
|
883 | 998 | { |
884 | 999 | $pdf->commitTransaction(); |
885 | 1000 | } |
@@ -919,8 +1034,7 @@ discard block |
||
919 | 1034 | if ($pagenb == 1) |
920 | 1035 | { |
921 | 1036 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
922 | - } |
|
923 | - else |
|
1037 | + } else |
|
924 | 1038 | { |
925 | 1039 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); |
926 | 1040 | } |
@@ -928,7 +1042,9 @@ discard block |
||
928 | 1042 | $pagenb++; |
929 | 1043 | $pdf->setPage($pagenb); |
930 | 1044 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
931 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1045 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
1046 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1047 | + } |
|
932 | 1048 | } |
933 | 1049 | } |
934 | 1050 | } |
@@ -938,8 +1054,7 @@ discard block |
||
938 | 1054 | { |
939 | 1055 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
940 | 1056 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
941 | - } |
|
942 | - else |
|
1057 | + } else |
|
943 | 1058 | { |
944 | 1059 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
945 | 1060 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -953,7 +1068,9 @@ discard block |
||
953 | 1068 | |
954 | 1069 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
955 | 1070 | |
956 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
1071 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
1072 | + unlink($file); |
|
1073 | + } |
|
957 | 1074 | } |
958 | 1075 | |
959 | 1076 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -996,8 +1113,7 @@ discard block |
||
996 | 1113 | { |
997 | 1114 | $height=pdf_getHeightForLogo($logo); |
998 | 1115 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
999 | - } |
|
1000 | - else |
|
1116 | + } else |
|
1001 | 1117 | { |
1002 | 1118 | $pdf->SetTextColor(200,0,0); |
1003 | 1119 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1006,8 +1122,7 @@ discard block |
||
1006 | 1122 | } |
1007 | 1123 | |
1008 | 1124 | $posy+=35; |
1009 | - } |
|
1010 | - else |
|
1125 | + } else |
|
1011 | 1126 | { |
1012 | 1127 | $text=$mysoc->name; |
1013 | 1128 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1021,9 +1136,13 @@ discard block |
||
1021 | 1136 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
1022 | 1137 | |
1023 | 1138 | $key = 'subtotalPropalTitle'; |
1024 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
1025 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
1026 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
1139 | + if ($object->element == 'commande') { |
|
1140 | + $key = 'subtotalCommandeTitle'; |
|
1141 | + } elseif ($object->element == 'facture') { |
|
1142 | + $key = 'subtotalInvoiceTitle'; |
|
1143 | + } elseif ($object->element == 'facturerec') { |
|
1144 | + $key = 'subtotalInvoiceTitle'; |
|
1145 | + } |
|
1027 | 1146 | |
1028 | 1147 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
1029 | 1148 | |
@@ -1058,7 +1177,9 @@ discard block |
||
1058 | 1177 | |
1059 | 1178 | // Force to disable hidetop and hidebottom |
1060 | 1179 | $hidebottom=0; |
1061 | - if ($hidetop) $hidetop=-1; |
|
1180 | + if ($hidetop) { |
|
1181 | + $hidetop=-1; |
|
1182 | + } |
|
1062 | 1183 | |
1063 | 1184 | $currency = !empty($currency) ? $currency : $conf->currency; |
1064 | 1185 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1073,7 +1194,9 @@ discard block |
||
1073 | 1194 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
1074 | 1195 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1075 | 1196 | |
1076 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1197 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1198 | + $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1199 | + } |
|
1077 | 1200 | |
1078 | 1201 | |
1079 | 1202 | $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
@@ -1086,8 +1209,7 @@ discard block |
||
1086 | 1209 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
1087 | 1210 | |
1088 | 1211 | $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
1089 | - } |
|
1090 | - else |
|
1212 | + } else |
|
1091 | 1213 | { |
1092 | 1214 | $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
1093 | 1215 | } |
@@ -1108,10 +1230,12 @@ discard block |
||
1108 | 1230 | |
1109 | 1231 | // Tableau total |
1110 | 1232 | $col1x = 120; $col2x = 170; |
1111 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
1233 | + if ($objmarge->page_largeur < 210) { |
|
1234 | + // To work with US executive format |
|
1112 | 1235 | { |
1113 | 1236 | $col2x-=20; |
1114 | 1237 | } |
1238 | + } |
|
1115 | 1239 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
1116 | 1240 | |
1117 | 1241 | $useborder=0; |
@@ -1133,9 +1257,11 @@ discard block |
||
1133 | 1257 | $atleastoneratenotnull=0; |
1134 | 1258 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
1135 | 1259 | { |
1136 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1260 | + if ($tvakey != 0) { |
|
1261 | + // On affiche pas taux 0 |
|
1137 | 1262 | { |
1138 | 1263 | $atleastoneratenotnull++; |
1264 | + } |
|
1139 | 1265 | |
1140 | 1266 | $index++; |
1141 | 1267 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1188,9 +1314,13 @@ discard block |
||
1188 | 1314 | */ |
1189 | 1315 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
1190 | 1316 | { |
1191 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1317 | + if (empty($hidetop) || $hidetop==-1) { |
|
1318 | + $pdf->line($x, $y, $x+$l, $y); |
|
1319 | + } |
|
1192 | 1320 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
1193 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1321 | + if (empty($hidebottom)) { |
|
1322 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1323 | + } |
|
1194 | 1324 | $pdf->line($x, $y+$h, $x, $y); |
1195 | 1325 | } |
1196 | 1326 | |
@@ -1199,7 +1329,9 @@ discard block |
||
1199 | 1329 | { |
1200 | 1330 | global $conf; |
1201 | 1331 | |
1202 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
1332 | + if (empty($fileoutput)) { |
|
1333 | + $fileoutput = $file[0]; |
|
1334 | + } |
|
1203 | 1335 | |
1204 | 1336 | $pdf=pdf_getInstance(); |
1205 | 1337 | if (class_exists('TCPDF')) |
@@ -1209,7 +1341,9 @@ discard block |
||
1209 | 1341 | } |
1210 | 1342 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
1211 | 1343 | |
1212 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1344 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
1345 | + $pdf->SetCompression(false); |
|
1346 | + } |
|
1213 | 1347 | |
1214 | 1348 | |
1215 | 1349 | foreach($files as $file) |
@@ -1225,7 +1359,9 @@ discard block |
||
1225 | 1359 | } |
1226 | 1360 | |
1227 | 1361 | $pdf->Output($fileoutput,'F'); |
1228 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1362 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1363 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1364 | + } |
|
1229 | 1365 | |
1230 | 1366 | return $pagecount; |
1231 | 1367 | } |
@@ -1238,7 +1374,9 @@ discard block |
||
1238 | 1374 | */ |
1239 | 1375 | public static function hasNcTitle(&$line) |
1240 | 1376 | { |
1241 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
1377 | + if(isset($line->has_nc_title)) { |
|
1378 | + return $line->has_nc_title; |
|
1379 | + } |
|
1242 | 1380 | |
1243 | 1381 | $TTitle = self::getAllTitleFromLine($line); |
1244 | 1382 | foreach ($TTitle as &$line_title) |
@@ -1263,7 +1401,9 @@ discard block |
||
1263 | 1401 | public static function getTitleLabel($line) |
1264 | 1402 | { |
1265 | 1403 | $title = $line->label; |
1266 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
1404 | + if (empty($title)) { |
|
1405 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
1406 | + } |
|
1267 | 1407 | return $title; |
1268 | 1408 | } |
1269 | 1409 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @var $object Facture fournisseur |
40 | 40 | */ |
41 | 41 | else if($object->element=='invoice_supplier') { |
42 | - $object->special_code = TSubtotal::$module_number; |
|
43 | - $rang = $object->line_max() + 1; |
|
44 | - $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
42 | + $object->special_code = TSubtotal::$module_number; |
|
43 | + $rang = $object->line_max() + 1; |
|
44 | + $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
45 | 45 | } |
46 | 46 | /** |
47 | 47 | * @var $object Propal |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @var $object Commande fournisseur |
61 | 61 | */ |
62 | 62 | else if($object->element=='order_supplier') { |
63 | - $object->special_code = TSubtotal::$module_number; |
|
64 | - $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
63 | + $object->special_code = TSubtotal::$module_number; |
|
64 | + $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
65 | 65 | } |
66 | 66 | /** |
67 | 67 | * @var $object Facturerec |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | $createRight = $user->rights->{$object->element}->creer; |
404 | 404 | if($object->element == 'facturerec' ) |
405 | 405 | { |
406 | - $object->statut = 0; // hack for facture rec |
|
407 | - $createRight = $user->rights->facture->creer; |
|
406 | + $object->statut = 0; // hack for facture rec |
|
407 | + $createRight = $user->rights->facture->creer; |
|
408 | 408 | } |
409 | 409 | elseif($object->element == 'order_supplier' ) |
410 | 410 | { |
411 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
411 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
412 | 412 | } |
413 | 413 | elseif($object->element == 'invoice_supplier' ) |
414 | 414 | { |
415 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
415 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | break; |
438 | 438 | |
439 | 439 | case 'supplier_proposal': |
440 | - $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id); |
|
441 | - break; |
|
440 | + $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id); |
|
441 | + break; |
|
442 | 442 | |
443 | 443 | case 'commande': |
444 | 444 | //$desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | break; |
447 | 447 | |
448 | 448 | case 'order_supplier': |
449 | - $object->line = $line; |
|
450 | - $object->line->fk_commande = $object->id; |
|
451 | - $object->line->rang = $object->line_max() +1; |
|
452 | - $res = $object->line->insert(1); |
|
449 | + $object->line = $line; |
|
450 | + $object->line->fk_commande = $object->id; |
|
451 | + $object->line->rang = $object->line_max() +1; |
|
452 | + $res = $object->line->insert(1); |
|
453 | 453 | break; |
454 | 454 | |
455 | 455 | case 'facture': |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | $object->db->commit(); |
503 | 503 | foreach ($TLineAdded as &$line) |
504 | 504 | { |
505 | - // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne |
|
506 | - _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
|
505 | + // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne |
|
506 | + _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
|
507 | 507 | } |
508 | 508 | return count($TLineAdded); |
509 | 509 | } |
@@ -577,33 +577,33 @@ discard block |
||
577 | 577 | |
578 | 578 | switch ($object->element) |
579 | 579 | { |
580 | - case 'propal': |
|
581 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit); |
|
582 | - break; |
|
580 | + case 'propal': |
|
581 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit); |
|
582 | + break; |
|
583 | 583 | |
584 | - case 'supplier_proposal': |
|
585 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
586 | - break; |
|
584 | + case 'supplier_proposal': |
|
585 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
586 | + break; |
|
587 | 587 | |
588 | 588 | case 'commande': |
589 | 589 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $fk_unit); |
590 | 590 | break; |
591 | 591 | |
592 | 592 | case 'order_supplier': |
593 | - $object->special_code = SELF::$module_number; |
|
594 | - if (empty($desc)) $desc = $label; |
|
595 | - $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
596 | - break; |
|
593 | + $object->special_code = SELF::$module_number; |
|
594 | + if (empty($desc)) $desc = $label; |
|
595 | + $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
596 | + break; |
|
597 | 597 | |
598 | 598 | case 'facture': |
599 | 599 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $situation_percent, $fk_unit); |
600 | 600 | break; |
601 | 601 | |
602 | 602 | case 'invoice_supplier': |
603 | - $object->special_code = SELF::$module_number; |
|
604 | - if (empty($desc)) $desc = $label; |
|
605 | - $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
606 | - break; |
|
603 | + $object->special_code = SELF::$module_number; |
|
604 | + if (empty($desc)) $desc = $label; |
|
605 | + $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
606 | + break; |
|
607 | 607 | |
608 | 608 | case 'facturerec': |
609 | 609 | // Add extrafields and get rang |
@@ -994,8 +994,8 @@ discard block |
||
994 | 994 | { |
995 | 995 | if (is_readable($logo)) |
996 | 996 | { |
997 | - $height=pdf_getHeightForLogo($logo); |
|
998 | - $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
997 | + $height=pdf_getHeightForLogo($logo); |
|
998 | + $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
999 | 999 | } |
1000 | 1000 | else |
1001 | 1001 | { |
@@ -1186,13 +1186,13 @@ discard block |
||
1186 | 1186 | * @param int $hidebottom Hide bottom |
1187 | 1187 | * @return void |
1188 | 1188 | */ |
1189 | - private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
1190 | - { |
|
1191 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1192 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
1193 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1194 | - $pdf->line($x, $y+$h, $x, $y); |
|
1195 | - } |
|
1189 | + private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
1190 | + { |
|
1191 | + if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1192 | + $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
1193 | + if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1194 | + $pdf->line($x, $y+$h, $x, $y); |
|
1195 | + } |
|
1196 | 1196 | |
1197 | 1197 | |
1198 | 1198 | public static function concat(&$outputlangs, $files, $fileoutput='') |
@@ -1202,14 +1202,14 @@ discard block |
||
1202 | 1202 | if (empty($fileoutput)) $fileoutput = $file[0]; |
1203 | 1203 | |
1204 | 1204 | $pdf=pdf_getInstance(); |
1205 | - if (class_exists('TCPDF')) |
|
1206 | - { |
|
1207 | - $pdf->setPrintHeader(false); |
|
1208 | - $pdf->setPrintFooter(false); |
|
1209 | - } |
|
1210 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
1205 | + if (class_exists('TCPDF')) |
|
1206 | + { |
|
1207 | + $pdf->setPrintHeader(false); |
|
1208 | + $pdf->setPrintFooter(false); |
|
1209 | + } |
|
1210 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
1211 | 1211 | |
1212 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1212 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1213 | 1213 | |
1214 | 1214 | |
1215 | 1215 | foreach($files as $file) |
@@ -5,28 +5,28 @@ discard block |
||
5 | 5 | |
6 | 6 | static $module_number = 104777; |
7 | 7 | |
8 | - static function addSubTotalLine(&$object, $label, $qty, $rang=-1) { |
|
8 | + static function addSubTotalLine(&$object, $label, $qty, $rang = -1) { |
|
9 | 9 | |
10 | 10 | $res = 0; |
11 | 11 | |
12 | - if( (float)DOL_VERSION <= 3.4 ) { |
|
12 | + if ((float) DOL_VERSION <= 3.4) { |
|
13 | 13 | /** |
14 | 14 | * @var $object Facture |
15 | 15 | */ |
16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
16 | + if ($object->element == 'facture') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number); |
|
17 | 17 | /** |
18 | 18 | * @var $object Propal |
19 | 19 | */ |
20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
20 | + else if ($object->element == 'propal') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number); |
|
21 | 21 | /** |
22 | 22 | * @var $object Commande |
23 | 23 | */ |
24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
24 | + else if ($object->element == 'commande') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | else { |
28 | 28 | $desc = ''; |
29 | - if ((float) DOL_VERSION < 6 || $qty==50) { |
|
29 | + if ((float) DOL_VERSION < 6 || $qty == 50) { |
|
30 | 30 | $desc = $label; |
31 | 31 | $label = ''; |
32 | 32 | } |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var $object Facture |
36 | 36 | */ |
37 | - if($object->element=='facture') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
37 | + if ($object->element == 'facture') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, $rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
38 | 38 | /** |
39 | 39 | * @var $object Facture fournisseur |
40 | 40 | */ |
41 | - else if($object->element=='invoice_supplier') { |
|
41 | + else if ($object->element == 'invoice_supplier') { |
|
42 | 42 | $object->special_code = TSubtotal::$module_number; |
43 | 43 | $rang = $object->line_max() + 1; |
44 | - $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
44 | + $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang); |
|
45 | 45 | } |
46 | 46 | /** |
47 | 47 | * @var $object Propal |
48 | 48 | */ |
49 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
49 | + else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
50 | 50 | /** |
51 | 51 | * @var $object Propal Fournisseur |
52 | 52 | */ |
53 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
53 | + else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @var $object Commande |
57 | 57 | */ |
58 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
58 | + else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
59 | 59 | /** |
60 | 60 | * @var $object Commande fournisseur |
61 | 61 | */ |
62 | - else if($object->element=='order_supplier') { |
|
62 | + else if ($object->element == 'order_supplier') { |
|
63 | 63 | $object->special_code = TSubtotal::$module_number; |
64 | - $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
64 | + $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9); |
|
65 | 65 | } |
66 | 66 | /** |
67 | 67 | * @var $object Facturerec |
68 | 68 | */ |
69 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
69 | + else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -77,20 +77,20 @@ discard block |
||
77 | 77 | |
78 | 78 | public static function generateDoc(&$object) |
79 | 79 | { |
80 | - global $conf,$langs,$db; |
|
80 | + global $conf, $langs, $db; |
|
81 | 81 | |
82 | 82 | if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
83 | 83 | { |
84 | - $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
85 | - $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
86 | - $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
84 | + $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
85 | + $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
86 | + $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
87 | 87 | |
88 | 88 | // Define output language |
89 | 89 | $outputlangs = $langs; |
90 | 90 | $newlang = GETPOST('lang_id', 'alpha'); |
91 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
91 | + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
92 | 92 | $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
93 | - if (! empty($newlang)) { |
|
93 | + if (!empty($newlang)) { |
|
94 | 94 | $outputlangs = new Translate("", $conf); |
95 | 95 | $outputlangs->setDefaultLang($newlang); |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | else |
106 | 106 | { |
107 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
107 | + if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @param type $rang_start |
117 | 117 | * @param type $move_to |
118 | 118 | */ |
119 | - public static function updateRang(&$object, $rang_start, $move_to=1) |
|
119 | + public static function updateRang(&$object, $rang_start, $move_to = 1) |
|
120 | 120 | { |
121 | 121 | if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
122 | 122 | |
123 | - $row=new GenericObject($object->db); |
|
123 | + $row = new GenericObject($object->db); |
|
124 | 124 | $row->table_element_line = $object->table_element_line; |
125 | 125 | $row->fk_element = $object->fk_element; |
126 | 126 | $row->id = $object->id; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | if ($line->rang < $rang_start) continue; |
131 | 131 | |
132 | - $row->updateRangOfLine($line->id, $line->rang+$move_to); |
|
132 | + $row->updateRangOfLine($line->id, $line->rang + $move_to); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
160 | 160 | |
161 | - self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
|
161 | + self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add); |
|
162 | 162 | |
163 | 163 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
164 | 164 | if ($rang_to_add != -1) |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - public static function addTitle(&$object, $label, $level, $rang=-1) |
|
173 | + public static function addTitle(&$object, $label, $level, $rang = -1) |
|
174 | 174 | { |
175 | 175 | self::addSubTotalLine($object, $label, $level, $rang); |
176 | 176 | } |
177 | 177 | |
178 | - public static function addTotal(&$object, $label, $level, $rang=-1) |
|
178 | + public static function addTotal(&$object, $label, $level, $rang = -1) |
|
179 | 179 | { |
180 | - self::addSubTotalLine($object, $label, (100-$level), $rang); |
|
180 | + self::addSubTotalLine($object, $label, (100 - $level), $rang); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return array |
190 | 190 | */ |
191 | - public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false) |
|
191 | + public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false) |
|
192 | 192 | { |
193 | 193 | $TTitle = self::getAllTitleFromDocument($object, $get_block_total); |
194 | 194 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param boolean $return_rang_on_false si true alors renvoi le rang où devrait ce trouver le sous-total |
210 | 210 | * @return boolean |
211 | 211 | */ |
212 | - public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
|
212 | + public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false) |
|
213 | 213 | { |
214 | 214 | if (empty($object->lines) || !is_array($object->lines)) return false; |
215 | 215 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | return ($return_rang_on_false) ? -1 : false; |
236 | 236 | } |
237 | 237 | |
238 | - public static function getAllTitleFromDocument(&$object, $get_block_total=false) |
|
238 | + public static function getAllTitleFromDocument(&$object, $get_block_total = false) |
|
239 | 239 | { |
240 | 240 | $TRes = array(); |
241 | 241 | if (!empty($object->lines)) |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | - public static function isTitle(&$line, $level=-1) |
|
358 | + public static function isTitle(&$line, $level = -1) |
|
359 | 359 | { |
360 | 360 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
361 | - if($res && $level > -1) { |
|
361 | + if ($res && $level > -1) { |
|
362 | 362 | return $line->qty == $level; |
363 | 363 | } else return $res; |
364 | 364 | |
@@ -379,43 +379,43 @@ discard block |
||
379 | 379 | return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line); |
380 | 380 | } |
381 | 381 | |
382 | - public static function getFreeTextHtml(&$line, $readonly=0) |
|
382 | + public static function getFreeTextHtml(&$line, $readonly = 0) |
|
383 | 383 | { |
384 | 384 | global $conf; |
385 | 385 | |
386 | 386 | // Copie du fichier "objectline_edit.tpl.php" |
387 | 387 | // editeur wysiwyg |
388 | 388 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
389 | - $nbrows=ROWS_2; |
|
390 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
391 | - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
|
392 | - $toolbarname='dolibarr_details'; |
|
393 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
394 | - $text = !empty($line->description)?$line->description:$line->label; |
|
395 | - $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
|
389 | + $nbrows = ROWS_2; |
|
390 | + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
391 | + $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); |
|
392 | + $toolbarname = 'dolibarr_details'; |
|
393 | + if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes'; |
|
394 | + $text = !empty($line->description) ? $line->description : $line->label; |
|
395 | + $doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly); |
|
396 | 396 | return $doleditor->Create(1); |
397 | 397 | } |
398 | 398 | |
399 | - public static function duplicateLines(&$object, $lineid, $withBlockLine=false) |
|
399 | + public static function duplicateLines(&$object, $lineid, $withBlockLine = false) |
|
400 | 400 | { |
401 | - global $db,$user,$conf; |
|
401 | + global $db, $user, $conf; |
|
402 | 402 | |
403 | 403 | $createRight = $user->rights->{$object->element}->creer; |
404 | - if($object->element == 'facturerec' ) |
|
404 | + if ($object->element == 'facturerec') |
|
405 | 405 | { |
406 | 406 | $object->statut = 0; // hack for facture rec |
407 | 407 | $createRight = $user->rights->facture->creer; |
408 | 408 | } |
409 | - elseif($object->element == 'order_supplier' ) |
|
409 | + elseif ($object->element == 'order_supplier') |
|
410 | 410 | { |
411 | 411 | $createRight = $user->rights->fournisseur->commande->creer; |
412 | 412 | } |
413 | - elseif($object->element == 'invoice_supplier' ) |
|
413 | + elseif ($object->element == 'invoice_supplier') |
|
414 | 414 | { |
415 | 415 | $createRight = $user->rights->fournisseur->facture->creer; |
416 | 416 | } |
417 | 417 | |
418 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
|
418 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
|
419 | 419 | { |
420 | 420 | dol_include_once('/subtotal/lib/subtotal.lib.php'); |
421 | 421 | |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | case 'order_supplier': |
449 | 449 | $object->line = $line; |
450 | 450 | $object->line->fk_commande = $object->id; |
451 | - $object->line->rang = $object->line_max() +1; |
|
451 | + $object->line->rang = $object->line_max() + 1; |
|
452 | 452 | $res = $object->line->insert(1); |
453 | 453 | break; |
454 | 454 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | { |
489 | 489 | $object->line_from = $line; |
490 | 490 | // Call trigger |
491 | - $result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line |
|
491 | + $result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line |
|
492 | 492 | if ($result < 0) |
493 | 493 | { |
494 | 494 | $object->db->rollback(); |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false) |
|
521 | + public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false) |
|
522 | 522 | { |
523 | 523 | global $langs; |
524 | 524 | |
@@ -530,17 +530,17 @@ discard block |
||
530 | 530 | |
531 | 531 | $TLine = array(); |
532 | 532 | $add_line = false; |
533 | - $under_title_found=false; |
|
533 | + $under_title_found = false; |
|
534 | 534 | |
535 | 535 | foreach ($object->lines as $key => &$line) |
536 | 536 | { |
537 | 537 | if (!$under_title_found && !empty($TTitle_under_search)) |
538 | 538 | { |
539 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
539 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true; |
|
540 | 540 | } |
541 | 541 | else |
542 | 542 | { |
543 | - if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
|
543 | + if (($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search)))) |
|
544 | 544 | { |
545 | 545 | if ($key_is_id) $level = $line->qty; |
546 | 546 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | if ($withBlockLine) $TLine[] = $line; |
549 | 549 | continue; |
550 | 550 | } |
551 | - elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
551 | + elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level)) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
552 | 552 | { |
553 | 553 | if ($withBlockLine) $TLine[] = $line; |
554 | 554 | break; |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | |
557 | 557 | if ($add_line) |
558 | 558 | { |
559 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
559 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue; |
|
560 | 560 | else $TLine[] = $line; |
561 | 561 | } |
562 | 562 | } |
@@ -565,12 +565,12 @@ discard block |
||
565 | 565 | return $TLine; |
566 | 566 | } |
567 | 567 | |
568 | - public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false) |
|
568 | + public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false) |
|
569 | 569 | { |
570 | 570 | return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true); |
571 | 571 | } |
572 | 572 | |
573 | - public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null) |
|
573 | + public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null) |
|
574 | 574 | { |
575 | 575 | $res = 0; |
576 | 576 | $object->db->begin(); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | break; |
583 | 583 | |
584 | 584 | case 'supplier_proposal': |
585 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
585 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit); |
|
586 | 586 | break; |
587 | 587 | |
588 | 588 | case 'commande': |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | $factureRecLine->fetch($rowid); |
612 | 612 | $factureRecLine->array_options = $array_options; |
613 | 613 | $factureRecLine->insertExtraFields(); |
614 | - $rang=$factureRecLine->rang; |
|
614 | + $rang = $factureRecLine->rang; |
|
615 | 615 | |
616 | - $fk_product=0; $fk_remise_except=''; $pu_ttc=0; |
|
616 | + $fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0; |
|
617 | 617 | $res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit); |
618 | 618 | break; |
619 | 619 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | global $db, $object; |
630 | 630 | |
631 | 631 | $TTitle = array(); |
632 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
632 | + if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
633 | 633 | else { |
634 | 634 | if ($origin_line->element == 'propaldet') |
635 | 635 | { |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public static function addRecapPage(&$parameters, &$origin_pdf) |
711 | 711 | { |
712 | - global $user,$conf,$langs; |
|
712 | + global $user, $conf, $langs; |
|
713 | 713 | |
714 | 714 | $origin_file = $parameters['file']; |
715 | 715 | $outputlangs = $parameters['outputlangs']; |
@@ -725,21 +725,21 @@ discard block |
||
725 | 725 | $objmarge->marge_droite = 10; |
726 | 726 | |
727 | 727 | $objectref = dol_sanitizeFileName($object->ref); |
728 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
729 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
730 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
728 | + if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref; |
|
729 | + elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref; |
|
730 | + elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref; |
|
731 | 731 | elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
732 | 732 | else |
733 | 733 | { |
734 | 734 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
735 | 735 | return -1; |
736 | 736 | } |
737 | - $file = $dir . '/' . $objectref . '_recap.pdf'; |
|
737 | + $file = $dir.'/'.$objectref.'_recap.pdf'; |
|
738 | 738 | |
739 | 739 | // $pdf=pdf_getInstance($origin_pdf->format); |
740 | - $pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait |
|
741 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
742 | - $pdf->SetAutoPageBreak(1,0); |
|
740 | + $pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait |
|
741 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
742 | + $pdf->SetAutoPageBreak(1, 0); |
|
743 | 743 | |
744 | 744 | if (class_exists('TCPDF')) |
745 | 745 | { |
@@ -748,49 +748,49 @@ discard block |
||
748 | 748 | } |
749 | 749 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
750 | 750 | // Set path to the background PDF File |
751 | - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
751 | + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
752 | 752 | { |
753 | 753 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
754 | 754 | $tplidx = $pdf->importPage(1); |
755 | 755 | } |
756 | 756 | |
757 | 757 | $pdf->Open(); |
758 | - $pagenb=0; |
|
759 | - $pdf->SetDrawColor(128,128,128); |
|
758 | + $pagenb = 0; |
|
759 | + $pdf->SetDrawColor(128, 128, 128); |
|
760 | 760 | |
761 | 761 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
762 | 762 | $pdf->SetSubject($outputlangs->transnoentities("subtotalRecap")); |
763 | 763 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
764 | 764 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
765 | 765 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
766 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
766 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
767 | 767 | |
768 | - $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
|
768 | + $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
|
769 | 769 | |
770 | - $pagenb=0; |
|
771 | - $pdf->SetDrawColor(128,128,128); |
|
770 | + $pagenb = 0; |
|
771 | + $pdf->SetDrawColor(128, 128, 128); |
|
772 | 772 | |
773 | 773 | |
774 | 774 | // New page |
775 | 775 | $pdf->AddPage(); |
776 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
776 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
777 | 777 | $pagenb++; |
778 | 778 | |
779 | 779 | |
780 | 780 | self::pagehead($objmarge, $pdf, $object, 1, $outputlangs); |
781 | - $pdf->SetFont('','', $default_font_size - 1); |
|
782 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
783 | - $pdf->SetTextColor(0,0,0); |
|
781 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
782 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
783 | + $pdf->SetTextColor(0, 0, 0); |
|
784 | 784 | |
785 | - $heightforinfotot = 25; // Height reserved to output the info and total part |
|
786 | - $heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
785 | + $heightforinfotot = 25; // Height reserved to output the info and total part |
|
786 | + $heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
787 | 787 | |
788 | 788 | $posx_designation = 25; |
789 | 789 | $posx_options = 150; |
790 | 790 | $posx_montant = 170; |
791 | 791 | |
792 | 792 | $tab_top = 72; |
793 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier |
|
793 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier |
|
794 | 794 | |
795 | 795 | $TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array()); |
796 | 796 | |
@@ -804,14 +804,14 @@ discard block |
||
804 | 804 | $nexY = $tab_top + 10; |
805 | 805 | |
806 | 806 | $nblignes = count($TLine); |
807 | - foreach($TLine as $i => &$line) |
|
807 | + foreach ($TLine as $i => &$line) |
|
808 | 808 | { |
809 | 809 | $curY = $nexY; |
810 | 810 | |
811 | 811 | if (self::getNiveau($line) == 1) |
812 | 812 | { |
813 | - $pdf->SetFont('','B', $default_font_size - 1); // Into loop to work with multipage |
|
814 | - $curY+=2; |
|
813 | + $pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage |
|
814 | + $curY += 2; |
|
815 | 815 | |
816 | 816 | $TTot['total_ht'] += $line->total_ht; |
817 | 817 | $TTot['total_tva'] += $line->total_tva; |
@@ -830,67 +830,67 @@ discard block |
||
830 | 830 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
831 | 831 | } |
832 | 832 | } |
833 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
833 | + else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
834 | 834 | |
835 | - $pdf->SetTextColor(0,0,0); |
|
835 | + $pdf->SetTextColor(0, 0, 0); |
|
836 | 836 | |
837 | 837 | $pdf->setTopMargin($tab_top_newpage + 10); |
838 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
839 | - $pageposbefore=$pdf->getPage(); |
|
838 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
839 | + $pageposbefore = $pdf->getPage(); |
|
840 | 840 | |
841 | - $showpricebeforepagebreak=1; |
|
841 | + $showpricebeforepagebreak = 1; |
|
842 | 842 | |
843 | 843 | $decalage = (self::getNiveau($line) - 1) * 2; |
844 | 844 | |
845 | 845 | // Print: Designation |
846 | 846 | $label = $line->label; |
847 | - if( (float)DOL_VERSION < 6 ) { |
|
847 | + if ((float) DOL_VERSION < 6) { |
|
848 | 848 | $label = !empty($line->label) ? $line->label : $line->desc; |
849 | 849 | } |
850 | 850 | |
851 | 851 | |
852 | 852 | $pdf->startTransaction(); |
853 | - $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
|
854 | - $pageposafter=$pdf->getPage(); |
|
853 | + $pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true); |
|
854 | + $pageposafter = $pdf->getPage(); |
|
855 | 855 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
856 | 856 | { |
857 | 857 | $pdf->rollbackTransaction(true); |
858 | - $pageposafter=$pageposbefore; |
|
858 | + $pageposafter = $pageposbefore; |
|
859 | 859 | //print $pageposafter.'-'.$pageposbefore;exit; |
860 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
861 | - $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
|
860 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
861 | + $pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true); |
|
862 | 862 | |
863 | - $pageposafter=$pdf->getPage(); |
|
864 | - $posyafter=$pdf->GetY(); |
|
863 | + $pageposafter = $pdf->getPage(); |
|
864 | + $posyafter = $pdf->GetY(); |
|
865 | 865 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
866 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
866 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot))) // There is no space left for total+free text |
|
867 | 867 | { |
868 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
868 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
869 | 869 | { |
870 | - $pdf->AddPage('','',true); |
|
871 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
870 | + $pdf->AddPage('', '', true); |
|
871 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
872 | 872 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
873 | - $pdf->setPage($pageposafter+1); |
|
873 | + $pdf->setPage($pageposafter + 1); |
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | else |
877 | 877 | { |
878 | 878 | // We found a page break |
879 | - $showpricebeforepagebreak=0; |
|
879 | + $showpricebeforepagebreak = 0; |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | else // No pagebreak |
883 | 883 | { |
884 | 884 | $pdf->commitTransaction(); |
885 | 885 | } |
886 | - $posYAfterDescription=$pdf->GetY(); |
|
886 | + $posYAfterDescription = $pdf->GetY(); |
|
887 | 887 | |
888 | 888 | $nexY = $pdf->GetY(); |
889 | - $pageposafter=$pdf->getPage(); |
|
889 | + $pageposafter = $pdf->getPage(); |
|
890 | 890 | |
891 | 891 | $pdf->setPage($pageposbefore); |
892 | 892 | $pdf->setTopMargin($objmarge->marge_haute); |
893 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
893 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
894 | 894 | |
895 | 895 | // We suppose that a too long description or photo were moved completely on next page |
896 | 896 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | if (!empty($line->total_options)) |
904 | 904 | { |
905 | 905 | $pdf->SetXY($posx_options, $curY); |
906 | - $pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0); |
|
906 | + $pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | // Print: Montant |
910 | 910 | $pdf->SetXY($posx_montant, $curY); |
911 | - $pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0); |
|
911 | + $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0); |
|
912 | 912 | |
913 | - $nexY+=2; // Passe espace entre les lignes |
|
913 | + $nexY += 2; // Passe espace entre les lignes |
|
914 | 914 | |
915 | 915 | // Detect if some page were added automatically and output _tableau for past pages |
916 | 916 | while ($pagenb < $pageposafter) |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | |
928 | 928 | $pagenb++; |
929 | 929 | $pdf->setPage($pagenb); |
930 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
930 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
931 | 931 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
932 | 932 | } |
933 | 933 | } |
@@ -937,19 +937,19 @@ discard block |
||
937 | 937 | if ($pagenb == 1) |
938 | 938 | { |
939 | 939 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
940 | - $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
940 | + $bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
941 | 941 | } |
942 | 942 | else |
943 | 943 | { |
944 | 944 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
945 | - $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
945 | + $bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | // Affiche zone totaux |
949 | - $posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot); |
|
949 | + $posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot); |
|
950 | 950 | |
951 | 951 | $pdf->Close(); |
952 | - $pdf->Output($file,'F'); |
|
952 | + $pdf->Output($file, 'F'); |
|
953 | 953 | |
954 | 954 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
955 | 955 | |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | $level = $line->qty; // TODO à améliorer |
962 | 962 | |
963 | 963 | $pdf->SetXY($objmarge->marge_gauche, $curY); |
964 | - $pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0); |
|
964 | + $pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
@@ -975,50 +975,50 @@ discard block |
||
975 | 975 | */ |
976 | 976 | private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs) |
977 | 977 | { |
978 | - global $conf,$mysoc; |
|
978 | + global $conf, $mysoc; |
|
979 | 979 | |
980 | 980 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
981 | 981 | |
982 | - pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur); |
|
982 | + pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur); |
|
983 | 983 | |
984 | - $pdf->SetTextColor(0,0,60); |
|
985 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
984 | + $pdf->SetTextColor(0, 0, 60); |
|
985 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
986 | 986 | |
987 | - $posy=$objmarge->marge_haute; |
|
988 | - $posx=$objmarge->page_largeur-$objmarge->marge_droite-100; |
|
987 | + $posy = $objmarge->marge_haute; |
|
988 | + $posx = $objmarge->page_largeur - $objmarge->marge_droite - 100; |
|
989 | 989 | |
990 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
990 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
991 | 991 | |
992 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
992 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
993 | 993 | if ($mysoc->logo) |
994 | 994 | { |
995 | 995 | if (is_readable($logo)) |
996 | 996 | { |
997 | - $height=pdf_getHeightForLogo($logo); |
|
998 | - $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
997 | + $height = pdf_getHeightForLogo($logo); |
|
998 | + $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
999 | 999 | } |
1000 | 1000 | else |
1001 | 1001 | { |
1002 | - $pdf->SetTextColor(200,0,0); |
|
1003 | - $pdf->SetFont('','B',$default_font_size - 2); |
|
1004 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1002 | + $pdf->SetTextColor(200, 0, 0); |
|
1003 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
1004 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
1005 | 1005 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1006 | 1006 | } |
1007 | 1007 | |
1008 | - $posy+=35; |
|
1008 | + $posy += 35; |
|
1009 | 1009 | } |
1010 | 1010 | else |
1011 | 1011 | { |
1012 | - $text=$mysoc->name; |
|
1012 | + $text = $mysoc->name; |
|
1013 | 1013 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
1014 | 1014 | |
1015 | - $posy+=15; |
|
1015 | + $posy += 15; |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | |
1019 | - $pdf->SetTextColor(0,0,0); |
|
1020 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
1021 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
1019 | + $pdf->SetTextColor(0, 0, 0); |
|
1020 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
1021 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
1022 | 1022 | |
1023 | 1023 | $key = 'subtotalPropalTitle'; |
1024 | 1024 | if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
@@ -1027,14 +1027,14 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
1029 | 1029 | |
1030 | - $pdf->SetFont('','', $default_font_size); |
|
1031 | - $pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy); |
|
1030 | + $pdf->SetFont('', '', $default_font_size); |
|
1031 | + $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy); |
|
1032 | 1032 | $pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R'); |
1033 | 1033 | |
1034 | 1034 | $posy += 8; |
1035 | 1035 | |
1036 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
1037 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
1036 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
1037 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
1038 | 1038 | $pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L'); |
1039 | 1039 | |
1040 | 1040 | } |
@@ -1052,44 +1052,44 @@ discard block |
||
1052 | 1052 | * @param string $currency Currency code |
1053 | 1053 | * @return void |
1054 | 1054 | */ |
1055 | - private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1055 | + private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
1056 | 1056 | { |
1057 | 1057 | global $conf; |
1058 | 1058 | |
1059 | 1059 | // Force to disable hidetop and hidebottom |
1060 | - $hidebottom=0; |
|
1061 | - if ($hidetop) $hidetop=-1; |
|
1060 | + $hidebottom = 0; |
|
1061 | + if ($hidetop) $hidetop = -1; |
|
1062 | 1062 | |
1063 | 1063 | $currency = !empty($currency) ? $currency : $conf->currency; |
1064 | 1064 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1065 | 1065 | |
1066 | 1066 | // Amount in (at tab_top - 1) |
1067 | - $pdf->SetTextColor(0,0,0); |
|
1068 | - $pdf->SetFont('','',$default_font_size); |
|
1067 | + $pdf->SetTextColor(0, 0, 0); |
|
1068 | + $pdf->SetFont('', '', $default_font_size); |
|
1069 | 1069 | |
1070 | 1070 | if (empty($hidetop)) |
1071 | 1071 | { |
1072 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1073 | - $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
|
1072 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1073 | + $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5); |
|
1074 | 1074 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1075 | 1075 | |
1076 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1076 | + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite - $objmarge->marge_gauche, 8, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1077 | 1077 | |
1078 | 1078 | |
1079 | - $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
|
1079 | + $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
|
1080 | 1080 | |
1081 | - $pdf->SetXY($posx_designation, $tab_top+2); |
|
1082 | - $pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1083 | - $pdf->SetXY($posx_options, $tab_top+2); |
|
1084 | - $pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R'); |
|
1085 | - $pdf->SetXY($posx_montant, $tab_top+2); |
|
1086 | - $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
|
1081 | + $pdf->SetXY($posx_designation, $tab_top + 2); |
|
1082 | + $pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L'); |
|
1083 | + $pdf->SetXY($posx_options, $tab_top + 2); |
|
1084 | + $pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R'); |
|
1085 | + $pdf->SetXY($posx_montant, $tab_top + 2); |
|
1086 | + $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R'); |
|
1087 | 1087 | |
1088 | - $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
|
1088 | + $pdf->line($objmarge->marge_gauche, $tab_top + 8, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top + 8); // line prend une position y en 2eme param et 4eme param |
|
1089 | 1089 | } |
1090 | 1090 | else |
1091 | 1091 | { |
1092 | - $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
|
1092 | + $pdf->line($objmarge->marge_gauche, $tab_top - 2, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top - 2); // line prend une position y en 2eme param et 4eme param |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | } |
@@ -1098,29 +1098,29 @@ discard block |
||
1098 | 1098 | { |
1099 | 1099 | global $conf; |
1100 | 1100 | |
1101 | - $pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param |
|
1101 | + $pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param |
|
1102 | 1102 | |
1103 | 1103 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1104 | 1104 | |
1105 | - $tab2_top = $posy+2; |
|
1105 | + $tab2_top = $posy + 2; |
|
1106 | 1106 | $tab2_hl = 4; |
1107 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1107 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1108 | 1108 | |
1109 | 1109 | // Tableau total |
1110 | 1110 | $col1x = 120; $col2x = 170; |
1111 | 1111 | if ($objmarge->page_largeur < 210) // To work with US executive format |
1112 | 1112 | { |
1113 | - $col2x-=20; |
|
1113 | + $col2x -= 20; |
|
1114 | 1114 | } |
1115 | 1115 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
1116 | 1116 | |
1117 | - $useborder=0; |
|
1117 | + $useborder = 0; |
|
1118 | 1118 | $index = 0; |
1119 | 1119 | |
1120 | 1120 | // Total HT |
1121 | - $pdf->SetFillColor(255,255,255); |
|
1121 | + $pdf->SetFillColor(255, 255, 255); |
|
1122 | 1122 | $pdf->SetXY($col1x, $tab2_top + 0); |
1123 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
1123 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
1124 | 1124 | |
1125 | 1125 | // $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht']; |
1126 | 1126 | $total_ht = $TTot['total_ht']; |
@@ -1128,10 +1128,10 @@ discard block |
||
1128 | 1128 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1); |
1129 | 1129 | |
1130 | 1130 | // Show VAT by rates and total |
1131 | - $pdf->SetFillColor(248,248,248); |
|
1131 | + $pdf->SetFillColor(248, 248, 248); |
|
1132 | 1132 | |
1133 | - $atleastoneratenotnull=0; |
|
1134 | - foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
|
1133 | + $atleastoneratenotnull = 0; |
|
1134 | + foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval) |
|
1135 | 1135 | { |
1136 | 1136 | if ($tvakey != 0) // On affiche pas taux 0 |
1137 | 1137 | { |
@@ -1140,15 +1140,15 @@ discard block |
||
1140 | 1140 | $index++; |
1141 | 1141 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1142 | 1142 | |
1143 | - $tvacompl=''; |
|
1144 | - if (preg_match('/\*/',$tvakey)) |
|
1143 | + $tvacompl = ''; |
|
1144 | + if (preg_match('/\*/', $tvakey)) |
|
1145 | 1145 | { |
1146 | - $tvakey=str_replace('*','',$tvakey); |
|
1146 | + $tvakey = str_replace('*', '', $tvakey); |
|
1147 | 1147 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
1148 | 1148 | } |
1149 | - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; |
|
1150 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
1151 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1149 | + $totalvat = $outputlangs->transnoentities("TotalVAT").' '; |
|
1150 | + $totalvat .= vatrate($tvakey, 1).$tvacompl; |
|
1151 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1152 | 1152 | |
1153 | 1153 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1154 | 1154 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -1158,16 +1158,16 @@ discard block |
||
1158 | 1158 | // Total TTC |
1159 | 1159 | $index++; |
1160 | 1160 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1161 | - $pdf->SetTextColor(0,0,60); |
|
1162 | - $pdf->SetFillColor(224,224,224); |
|
1163 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1161 | + $pdf->SetTextColor(0, 0, 60); |
|
1162 | + $pdf->SetFillColor(224, 224, 224); |
|
1163 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1164 | 1164 | |
1165 | 1165 | // $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc']; |
1166 | 1166 | $total_ttc = $TTot['total_ttc']; |
1167 | 1167 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
1168 | 1168 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
1169 | 1169 | |
1170 | - $pdf->SetTextColor(0,0,0); |
|
1170 | + $pdf->SetTextColor(0, 0, 0); |
|
1171 | 1171 | |
1172 | 1172 | $index++; |
1173 | 1173 | return ($tab2_top + ($tab2_hl * $index)); |
@@ -1186,22 +1186,22 @@ discard block |
||
1186 | 1186 | * @param int $hidebottom Hide bottom |
1187 | 1187 | * @return void |
1188 | 1188 | */ |
1189 | - private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
1189 | + private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) |
|
1190 | 1190 | { |
1191 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1192 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
1193 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1194 | - $pdf->line($x, $y+$h, $x, $y); |
|
1191 | + if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y); |
|
1192 | + $pdf->line($x + $l, $y, $x + $l, $y + $h); |
|
1193 | + if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h); |
|
1194 | + $pdf->line($x, $y + $h, $x, $y); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | |
1198 | - public static function concat(&$outputlangs, $files, $fileoutput='') |
|
1198 | + public static function concat(&$outputlangs, $files, $fileoutput = '') |
|
1199 | 1199 | { |
1200 | 1200 | global $conf; |
1201 | 1201 | |
1202 | 1202 | if (empty($fileoutput)) $fileoutput = $file[0]; |
1203 | 1203 | |
1204 | - $pdf=pdf_getInstance(); |
|
1204 | + $pdf = pdf_getInstance(); |
|
1205 | 1205 | if (class_exists('TCPDF')) |
1206 | 1206 | { |
1207 | 1207 | $pdf->setPrintHeader(false); |
@@ -1209,10 +1209,10 @@ discard block |
||
1209 | 1209 | } |
1210 | 1210 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
1211 | 1211 | |
1212 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1212 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1213 | 1213 | |
1214 | 1214 | |
1215 | - foreach($files as $file) |
|
1215 | + foreach ($files as $file) |
|
1216 | 1216 | { |
1217 | 1217 | $pagecount = $pdf->setSourceFile($file); |
1218 | 1218 | for ($i = 1; $i <= $pagecount; $i++) |
@@ -1224,8 +1224,8 @@ discard block |
||
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | |
1227 | - $pdf->Output($fileoutput,'F'); |
|
1228 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1227 | + $pdf->Output($fileoutput, 'F'); |
|
1228 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1229 | 1229 | |
1230 | 1230 | return $pagecount; |
1231 | 1231 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | */ |
1239 | 1239 | public static function hasNcTitle(&$line) |
1240 | 1240 | { |
1241 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
1241 | + if (isset($line->has_nc_title)) return $line->has_nc_title; |
|
1242 | 1242 | |
1243 | 1243 | $TTitle = self::getAllTitleFromLine($line); |
1244 | 1244 | foreach ($TTitle as &$line_title) |
@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | |
26 | 26 | function subtotalAdminPrepareHead() |
27 | 27 | { |
28 | - global $langs, $conf; |
|
28 | + global $langs, $conf; |
|
29 | 29 | |
30 | - $langs->load("subtotal@subtotal"); |
|
30 | + $langs->load("subtotal@subtotal"); |
|
31 | 31 | |
32 | - $h = 0; |
|
33 | - $head = array(); |
|
32 | + $h = 0; |
|
33 | + $head = array(); |
|
34 | 34 | |
35 | - $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1); |
|
36 | - $head[$h][1] = $langs->trans("Parameters"); |
|
37 | - $head[$h][2] = 'settings'; |
|
38 | - $h++; |
|
39 | - $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1); |
|
40 | - $head[$h][1] = $langs->trans("About"); |
|
41 | - $head[$h][2] = 'about'; |
|
42 | - $h++; |
|
35 | + $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1); |
|
36 | + $head[$h][1] = $langs->trans("Parameters"); |
|
37 | + $head[$h][2] = 'settings'; |
|
38 | + $h++; |
|
39 | + $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1); |
|
40 | + $head[$h][1] = $langs->trans("About"); |
|
41 | + $head[$h][2] = 'about'; |
|
42 | + $h++; |
|
43 | 43 | |
44 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false); |
|
44 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false); |
|
45 | 45 | |
46 | - return $head; |
|
46 | + return $head; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | function getHtmlSelectTitle(&$object, $showLabel=false) |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | $classname = ucfirst($element); |
243 | 243 | |
244 | 244 | switch ($element) { |
245 | - case 'supplier_proposal': |
|
246 | - $classname = 'SupplierProposal'; |
|
247 | - break; |
|
245 | + case 'supplier_proposal': |
|
246 | + $classname = 'SupplierProposal'; |
|
247 | + break; |
|
248 | 248 | |
249 | - case 'order_supplier': |
|
250 | - $classname = 'CommandeFournisseur'; |
|
251 | - break; |
|
249 | + case 'order_supplier': |
|
250 | + $classname = 'CommandeFournisseur'; |
|
251 | + break; |
|
252 | 252 | |
253 | - case 'invoice_supplier': |
|
254 | - $classname = 'FactureFournisseur'; |
|
255 | - break; |
|
253 | + case 'invoice_supplier': |
|
254 | + $classname = 'FactureFournisseur'; |
|
255 | + break; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | $object = new $classname($db); // Propal | Commande | Facture |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | function doUpdate(&$object, &$line, $subtotal_nc) |
313 | 313 | { |
314 | - global $user; |
|
314 | + global $user; |
|
315 | 315 | |
316 | 316 | if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
317 | 317 | // Update extrafield et total |
@@ -41,21 +41,21 @@ discard block |
||
41 | 41 | $head[$h][2] = 'about'; |
42 | 42 | $h++; |
43 | 43 | |
44 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false); |
|
44 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel = false); |
|
45 | 45 | |
46 | 46 | return $head; |
47 | 47 | } |
48 | 48 | |
49 | -function getHtmlSelectTitle(&$object, $showLabel=false) |
|
49 | +function getHtmlSelectTitle(&$object, $showLabel = false) |
|
50 | 50 | { |
51 | 51 | global $langs; |
52 | 52 | |
53 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; |
|
53 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; |
|
54 | 54 | dol_include_once('/subtotal/class/subtotal.class.php'); |
55 | 55 | $TTitle = TSubtotal::getAllTitleFromDocument($object); |
56 | 56 | $html = ''; |
57 | - if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
58 | - $html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>'; |
|
57 | + if ($showLabel) $html .= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
58 | + $html .= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>'; |
|
59 | 59 | |
60 | 60 | $nbsp = ' '; |
61 | 61 | foreach ($TTitle as &$line) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | function getTFreeText() |
72 | 72 | { |
73 | - global $db,$conf; |
|
73 | + global $db, $conf; |
|
74 | 74 | |
75 | 75 | $TFreeText = array(); |
76 | 76 | |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | return $TFreeText; |
89 | 89 | } |
90 | 90 | |
91 | -function getHtmlSelectFreeText($withEmpty=true) |
|
91 | +function getHtmlSelectFreeText($withEmpty = true) |
|
92 | 92 | { |
93 | 93 | global $langs; |
94 | 94 | |
95 | 95 | $TFreeText = getTFreeText(); |
96 | 96 | $html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>'; |
97 | - $html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">'; |
|
98 | - if ($withEmpty) $html.= '<option value=""></option>'; |
|
97 | + $html .= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">'; |
|
98 | + if ($withEmpty) $html .= '<option value=""></option>'; |
|
99 | 99 | |
100 | 100 | $TFreeTextContents = array(); |
101 | 101 | foreach ($TFreeText as $id => $tab) |
102 | 102 | { |
103 | - $html.= '<option value="'.$id.'">'.$tab->label.'</option>'; |
|
103 | + $html .= '<option value="'.$id.'">'.$tab->label.'</option>'; |
|
104 | 104 | $TFreeTextContents[$id] = $tab->content; |
105 | 105 | } |
106 | 106 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | function _updateSubtotalLine(&$object, &$line) |
129 | 129 | { |
130 | 130 | $label = GETPOST('line-title'); |
131 | - $description = ($line->qty>90) ? '' : GETPOST('line-description'); |
|
131 | + $description = ($line->qty > 90) ? '' : GETPOST('line-description'); |
|
132 | 132 | $pagebreak = (int) GETPOST('line-pagebreak'); |
133 | 133 | |
134 | 134 | $level = GETPOST('subtotal_level', 'int'); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | function _updateSubtotalBloc($object, $line) |
147 | 147 | { |
148 | - global $conf,$langs; |
|
148 | + global $conf, $langs; |
|
149 | 149 | |
150 | 150 | $subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int'); |
151 | 151 | $subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int'); |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * @param $lineid = title lineid |
225 | 225 | * @param $subtotal_nc 0 = "Compris" prise en compte des totaux des lignes; 1 = "Non compris" non prise en compte des totaux du bloc; null = update de toutes les lignes |
226 | 226 | */ |
227 | -function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null) |
|
227 | +function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null) |
|
228 | 228 | { |
229 | - global $db,$langs,$tmp_object_nc; |
|
229 | + global $db, $langs, $tmp_object_nc; |
|
230 | 230 | |
231 | 231 | $error = 0; |
232 | 232 | if (empty($element)) $error++; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | { |
267 | 267 | foreach ($object->lines as &$l) |
268 | 268 | { |
269 | - if($l->id == $lineid) { |
|
269 | + if ($l->id == $lineid) { |
|
270 | 270 | $line = $l; |
271 | 271 | break; |
272 | 272 | } |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | { |
277 | 277 | $db->begin(); |
278 | 278 | |
279 | - if(TSubtotal::isModSubtotalLine($line)) |
|
279 | + if (TSubtotal::isModSubtotalLine($line)) |
|
280 | 280 | { |
281 | - if(TSubtotal::isTitle($line)) { |
|
281 | + if (TSubtotal::isTitle($line)) { |
|
282 | 282 | // Update le contenu du titre (ainsi que le titre lui même) |
283 | 283 | $TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true); |
284 | - foreach($TTitleBlock as &$line_block) |
|
284 | + foreach ($TTitleBlock as &$line_block) |
|
285 | 285 | { |
286 | 286 | $res = doUpdate($object, $line_block, $subtotal_nc); |
287 | 287 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
317 | 317 | // Update extrafield et total |
318 | - if(! empty($subtotal_nc)) { |
|
318 | + if (!empty($subtotal_nc)) { |
|
319 | 319 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
320 | 320 | $line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0; |
321 | 321 |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | dol_include_once('/subtotal/class/subtotal.class.php'); |
55 | 55 | $TTitle = TSubtotal::getAllTitleFromDocument($object); |
56 | 56 | $html = ''; |
57 | - if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
57 | + if ($showLabel) { |
|
58 | + $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
59 | + } |
|
58 | 60 | $html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>'; |
59 | 61 | |
60 | 62 | $nbsp = ' '; |
@@ -95,7 +97,9 @@ discard block |
||
95 | 97 | $TFreeText = getTFreeText(); |
96 | 98 | $html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>'; |
97 | 99 | $html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">'; |
98 | - if ($withEmpty) $html.= '<option value=""></option>'; |
|
100 | + if ($withEmpty) { |
|
101 | + $html.= '<option value=""></option>'; |
|
102 | + } |
|
99 | 103 | |
100 | 104 | $TFreeTextContents = array(); |
101 | 105 | foreach ($TFreeText as $id => $tab) |
@@ -134,8 +138,13 @@ discard block |
||
134 | 138 | $level = GETPOST('subtotal_level', 'int'); |
135 | 139 | if (!empty($level)) |
136 | 140 | { |
137 | - if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total |
|
138 | - else $line->qty = $level; |
|
141 | + if ($line->qty > 90) { |
|
142 | + $line->qty = 100 - $level; |
|
143 | + } |
|
144 | + // Si on edit une ligne sous-total |
|
145 | + else { |
|
146 | + $line->qty = $level; |
|
147 | + } |
|
139 | 148 | } |
140 | 149 | |
141 | 150 | $res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options); |
@@ -162,13 +171,18 @@ discard block |
||
162 | 171 | { |
163 | 172 | $subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer |
164 | 173 | |
165 | - if (!empty($showBlockExtrafields)) $line->array_options = $array_options; |
|
166 | - if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx; |
|
174 | + if (!empty($showBlockExtrafields)) { |
|
175 | + $line->array_options = $array_options; |
|
176 | + } |
|
177 | + if ($subtotal_tva_tx == '') { |
|
178 | + $subtotal_tva_tx = $line->tva_tx; |
|
179 | + } |
|
167 | 180 | if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) |
168 | 181 | { |
169 | 182 | $subtotal_progress = $subtotal_progress_init; |
170 | - if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent; |
|
171 | - else |
|
183 | + if ($subtotal_progress == '') { |
|
184 | + $subtotal_progress = $line->situation_percent; |
|
185 | + } else |
|
172 | 186 | { |
173 | 187 | $prev_percent = $line->get_prev_progress($object->id); |
174 | 188 | if ($subtotal_progress < $prev_percent) |
@@ -181,14 +195,21 @@ discard block |
||
181 | 195 | |
182 | 196 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit); |
183 | 197 | |
184 | - if ($res > 0) $success_updated_line++; |
|
185 | - else $error_updated_line++; |
|
198 | + if ($res > 0) { |
|
199 | + $success_updated_line++; |
|
200 | + } else { |
|
201 | + $error_updated_line++; |
|
202 | + } |
|
186 | 203 | } |
187 | 204 | } |
188 | 205 | |
189 | - if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
206 | + if ($nb_progress_not_updated > 0) { |
|
207 | + setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
208 | + } |
|
190 | 209 | |
191 | - if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
210 | + if ($success_updated_line > 0) { |
|
211 | + setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
212 | + } |
|
192 | 213 | if ($error_updated_line > 0) |
193 | 214 | { |
194 | 215 | setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors'); |
@@ -229,15 +250,16 @@ discard block |
||
229 | 250 | global $db,$langs,$tmp_object_nc; |
230 | 251 | |
231 | 252 | $error = 0; |
232 | - if (empty($element)) $error++; |
|
253 | + if (empty($element)) { |
|
254 | + $error++; |
|
255 | + } |
|
233 | 256 | |
234 | 257 | if (!$error) |
235 | 258 | { |
236 | 259 | if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid) |
237 | 260 | { |
238 | 261 | $object = $tmp_object_nc; |
239 | - } |
|
240 | - else |
|
262 | + } else |
|
241 | 263 | { |
242 | 264 | $classname = ucfirst($element); |
243 | 265 | |
@@ -257,8 +279,11 @@ discard block |
||
257 | 279 | |
258 | 280 | $object = new $classname($db); // Propal | Commande | Facture |
259 | 281 | $res = $object->fetch($elementid); |
260 | - if ($res < 0) $error++; |
|
261 | - else $tmp_object_nc = $object; |
|
282 | + if ($res < 0) { |
|
283 | + $error++; |
|
284 | + } else { |
|
285 | + $tmp_object_nc = $object; |
|
286 | + } |
|
262 | 287 | } |
263 | 288 | } |
264 | 289 | |
@@ -286,21 +311,21 @@ discard block |
||
286 | 311 | $res = doUpdate($object, $line_block, $subtotal_nc); |
287 | 312 | } |
288 | 313 | } |
289 | - } |
|
290 | - else |
|
314 | + } else |
|
291 | 315 | { |
292 | 316 | $res = doUpdate($object, $line, $subtotal_nc); |
293 | 317 | } |
294 | 318 | |
295 | 319 | $res = $object->update_price(1); |
296 | - if ($res <= 0) $error++; |
|
320 | + if ($res <= 0) { |
|
321 | + $error++; |
|
322 | + } |
|
297 | 323 | |
298 | 324 | if (!$error) |
299 | 325 | { |
300 | 326 | setEventMessage($langs->trans('subtotal_update_nc_success')); |
301 | 327 | $db->commit(); |
302 | - } |
|
303 | - else |
|
328 | + } else |
|
304 | 329 | { |
305 | 330 | setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors'); |
306 | 331 | $db->rollback(); |
@@ -313,7 +338,9 @@ discard block |
||
313 | 338 | { |
314 | 339 | global $user; |
315 | 340 | |
316 | - if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
|
341 | + if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) { |
|
342 | + return 1; |
|
343 | + } |
|
317 | 344 | // Update extrafield et total |
318 | 345 | if(! empty($subtotal_nc)) { |
319 | 346 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
@@ -322,8 +349,7 @@ discard block |
||
322 | 349 | $line->array_options['options_subtotal_nc'] = 1; |
323 | 350 | |
324 | 351 | $res = $line->update($user); |
325 | - } |
|
326 | - else { |
|
352 | + } else { |
|
327 | 353 | $line->array_options['options_subtotal_nc'] = 0; |
328 | 354 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); |
329 | 355 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | dol_include_once('/supplier_proposal/class/supplier_proposal.class.php'); |
11 | 11 | dol_include_once('/fourn/class/fournisseur.facture.class.php'); |
12 | 12 | |
13 | - $get=GETPOST('get'); |
|
14 | - $set=GETPOST('set'); |
|
13 | + $get = GETPOST('get'); |
|
14 | + $set = GETPOST('set'); |
|
15 | 15 | |
16 | 16 | switch ($get) { |
17 | 17 | default: |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | switch ($set) { |
22 | 22 | case 'updateLineNC': // Gestion du Compris/Non Compris via les titres et/ou lignes |
23 | - echo json_encode( _updateLineNC(GETPOST('element'), GETPOST('elementid'), GETPOST('lineid'), GETPOST('subtotal_nc')) ); |
|
23 | + echo json_encode(_updateLineNC(GETPOST('element'), GETPOST('elementid'), GETPOST('lineid'), GETPOST('subtotal_nc'))); |
|
24 | 24 | |
25 | 25 | break; |
26 | 26 | default: |