@@ -32,151 +32,151 @@ |
||
32 | 32 | class modECM extends DolibarrModules |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
39 | - */ |
|
40 | - function __construct($db) |
|
41 | - { |
|
42 | - $this->db = $db; |
|
43 | - |
|
44 | - // Id for module (must be unique). |
|
45 | - // Use here a free id. |
|
46 | - $this->numero = 2500; |
|
47 | - |
|
48 | - // Family can be 'crm','financial','hr','projects','product','ecm','technic','other' |
|
49 | - // It is used to sort modules in module setup page |
|
50 | - $this->family = "ecm"; |
|
51 | - $this->module_position = '10'; |
|
52 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | - // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) |
|
55 | - $this->description = "Electronic Content Management"; |
|
56 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
57 | - $this->version = 'dolibarr'; |
|
58 | - // Key used in llx_const table to save module status enabled/disabled (XXX is id value) |
|
59 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
60 | - // Name of png file (without png) used for this module |
|
61 | - $this->picto='dir'; |
|
62 | - |
|
63 | - // Data directories to create when module is enabled |
|
64 | - $this->dirs = array("/ecm/temp"); |
|
65 | - |
|
66 | - // Config pages. Put here list of php page names stored in admmin directory used to setup module |
|
67 | - $this->config_page_url = array('ecm.php'); |
|
68 | - |
|
69 | - // Dependencies |
|
70 | - $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
72 | - |
|
73 | - // Constants |
|
74 | - $this->const = array(); // List of parameters |
|
75 | - $r=0; |
|
76 | - |
|
77 | - $this->const[$r][0] = "ECM_AUTO_TREE_ENABLED"; |
|
78 | - $this->const[$r][1] = "chaine"; |
|
79 | - $this->const[$r][2] = "1"; |
|
80 | - $this->const[$r][3] = 'Auto tree is enabled by default'; |
|
81 | - $this->const[$r][4] = 0; |
|
82 | - |
|
83 | - // Boxes |
|
84 | - $this->boxes = array(); // List of boxes |
|
85 | - $r=0; |
|
86 | - |
|
87 | - // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
88 | - // Example: |
|
35 | + /** |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | + */ |
|
40 | + function __construct($db) |
|
41 | + { |
|
42 | + $this->db = $db; |
|
43 | + |
|
44 | + // Id for module (must be unique). |
|
45 | + // Use here a free id. |
|
46 | + $this->numero = 2500; |
|
47 | + |
|
48 | + // Family can be 'crm','financial','hr','projects','product','ecm','technic','other' |
|
49 | + // It is used to sort modules in module setup page |
|
50 | + $this->family = "ecm"; |
|
51 | + $this->module_position = '10'; |
|
52 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
53 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) |
|
55 | + $this->description = "Electronic Content Management"; |
|
56 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
57 | + $this->version = 'dolibarr'; |
|
58 | + // Key used in llx_const table to save module status enabled/disabled (XXX is id value) |
|
59 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
60 | + // Name of png file (without png) used for this module |
|
61 | + $this->picto='dir'; |
|
62 | + |
|
63 | + // Data directories to create when module is enabled |
|
64 | + $this->dirs = array("/ecm/temp"); |
|
65 | + |
|
66 | + // Config pages. Put here list of php page names stored in admmin directory used to setup module |
|
67 | + $this->config_page_url = array('ecm.php'); |
|
68 | + |
|
69 | + // Dependencies |
|
70 | + $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
72 | + |
|
73 | + // Constants |
|
74 | + $this->const = array(); // List of parameters |
|
75 | + $r=0; |
|
76 | + |
|
77 | + $this->const[$r][0] = "ECM_AUTO_TREE_ENABLED"; |
|
78 | + $this->const[$r][1] = "chaine"; |
|
79 | + $this->const[$r][2] = "1"; |
|
80 | + $this->const[$r][3] = 'Auto tree is enabled by default'; |
|
81 | + $this->const[$r][4] = 0; |
|
82 | + |
|
83 | + // Boxes |
|
84 | + $this->boxes = array(); // List of boxes |
|
85 | + $r=0; |
|
86 | + |
|
87 | + // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
|
88 | + // Example: |
|
89 | 89 | //$this->boxes[$r][1] = "myboxa.php"; |
90 | - //$r++; |
|
90 | + //$r++; |
|
91 | 91 | //$this->boxes[$r][1] = "myboxb.php"; |
92 | - //$r++; |
|
93 | - |
|
94 | - // Permissions |
|
95 | - $this->rights_class = 'ecm'; // Permission key |
|
96 | - $this->rights = array(); // Permission array used by this module |
|
97 | - |
|
98 | - $r++; |
|
99 | - $this->rights[$r][0] = 2501; |
|
100 | - $this->rights[$r][1] = 'Consulter/Télécharger les documents'; |
|
101 | - $this->rights[$r][2] = 'r'; |
|
102 | - $this->rights[$r][3] = 0; |
|
103 | - $this->rights[$r][4] = 'read'; |
|
104 | - |
|
105 | - $r++; |
|
106 | - $this->rights[$r][0] = 2503; |
|
107 | - $this->rights[$r][1] = 'Soumettre ou supprimer des documents'; |
|
108 | - $this->rights[$r][2] = 'w'; |
|
109 | - $this->rights[$r][3] = 0; |
|
110 | - $this->rights[$r][4] = 'upload'; |
|
111 | - |
|
112 | - $r++; |
|
113 | - $this->rights[$r][0] = 2515; |
|
114 | - $this->rights[$r][1] = 'Administrer les rubriques de documents'; |
|
115 | - $this->rights[$r][2] = 'w'; |
|
116 | - $this->rights[$r][3] = 0; |
|
117 | - $this->rights[$r][4] = 'setup'; |
|
92 | + //$r++; |
|
93 | + |
|
94 | + // Permissions |
|
95 | + $this->rights_class = 'ecm'; // Permission key |
|
96 | + $this->rights = array(); // Permission array used by this module |
|
97 | + |
|
98 | + $r++; |
|
99 | + $this->rights[$r][0] = 2501; |
|
100 | + $this->rights[$r][1] = 'Consulter/Télécharger les documents'; |
|
101 | + $this->rights[$r][2] = 'r'; |
|
102 | + $this->rights[$r][3] = 0; |
|
103 | + $this->rights[$r][4] = 'read'; |
|
104 | + |
|
105 | + $r++; |
|
106 | + $this->rights[$r][0] = 2503; |
|
107 | + $this->rights[$r][1] = 'Soumettre ou supprimer des documents'; |
|
108 | + $this->rights[$r][2] = 'w'; |
|
109 | + $this->rights[$r][3] = 0; |
|
110 | + $this->rights[$r][4] = 'upload'; |
|
111 | + |
|
112 | + $r++; |
|
113 | + $this->rights[$r][0] = 2515; |
|
114 | + $this->rights[$r][1] = 'Administrer les rubriques de documents'; |
|
115 | + $this->rights[$r][2] = 'w'; |
|
116 | + $this->rights[$r][3] = 0; |
|
117 | + $this->rights[$r][4] = 'setup'; |
|
118 | 118 | |
119 | 119 | |
120 | 120 | // Menus |
121 | - //------ |
|
122 | - $this->menus = array(); // List of menus to add |
|
123 | - $r=0; |
|
124 | - |
|
125 | - // Top menu |
|
126 | - $this->menu[$r]=array('fk_menu'=>0, |
|
127 | - 'type'=>'top', |
|
128 | - 'titre'=>'MenuECM', |
|
129 | - 'mainmenu'=>'ecm', |
|
130 | - 'url'=>'/ecm/index.php', |
|
131 | - 'langs'=>'ecm', |
|
132 | - 'position'=>82, |
|
133 | - 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup', |
|
134 | - 'enabled'=>'$conf->ecm->enabled', |
|
135 | - 'target'=>'', |
|
136 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
137 | - $r++; |
|
138 | - |
|
139 | - // Left menu linked to top menu |
|
140 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm', |
|
141 | - 'type'=>'left', |
|
142 | - 'titre'=>'ECMArea', |
|
143 | - 'mainmenu'=>'ecm', |
|
144 | - 'leftmenu'=>'ecm', |
|
145 | - 'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm', |
|
146 | - 'langs'=>'ecm', |
|
147 | - 'position'=>101, |
|
148 | - 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
149 | - 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
150 | - 'target'=>'', |
|
151 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
152 | - $r++; |
|
153 | - |
|
154 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
155 | - 'type'=>'left', |
|
156 | - 'titre'=>'ECMSectionsManual', |
|
157 | - 'mainmenu'=>'ecm', |
|
158 | - 'leftmenu'=>'ecm_manual', |
|
159 | - 'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm', |
|
160 | - 'langs'=>'ecm', |
|
161 | - 'position'=>102, |
|
162 | - 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
163 | - 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
164 | - 'target'=>'', |
|
165 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
166 | - $r++; |
|
167 | - |
|
168 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
169 | - 'type'=>'left', |
|
170 | - 'titre'=>'ECMSectionsAuto', |
|
171 | - 'mainmenu'=>'ecm', |
|
172 | - 'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm', |
|
173 | - 'langs'=>'ecm', |
|
174 | - 'position'=>103, |
|
175 | - 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
176 | - 'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)', |
|
177 | - 'target'=>'', |
|
178 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
179 | - $r++; |
|
180 | - } |
|
121 | + //------ |
|
122 | + $this->menus = array(); // List of menus to add |
|
123 | + $r=0; |
|
124 | + |
|
125 | + // Top menu |
|
126 | + $this->menu[$r]=array('fk_menu'=>0, |
|
127 | + 'type'=>'top', |
|
128 | + 'titre'=>'MenuECM', |
|
129 | + 'mainmenu'=>'ecm', |
|
130 | + 'url'=>'/ecm/index.php', |
|
131 | + 'langs'=>'ecm', |
|
132 | + 'position'=>82, |
|
133 | + 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup', |
|
134 | + 'enabled'=>'$conf->ecm->enabled', |
|
135 | + 'target'=>'', |
|
136 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
137 | + $r++; |
|
138 | + |
|
139 | + // Left menu linked to top menu |
|
140 | + $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm', |
|
141 | + 'type'=>'left', |
|
142 | + 'titre'=>'ECMArea', |
|
143 | + 'mainmenu'=>'ecm', |
|
144 | + 'leftmenu'=>'ecm', |
|
145 | + 'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm', |
|
146 | + 'langs'=>'ecm', |
|
147 | + 'position'=>101, |
|
148 | + 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
149 | + 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
150 | + 'target'=>'', |
|
151 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
152 | + $r++; |
|
153 | + |
|
154 | + $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
155 | + 'type'=>'left', |
|
156 | + 'titre'=>'ECMSectionsManual', |
|
157 | + 'mainmenu'=>'ecm', |
|
158 | + 'leftmenu'=>'ecm_manual', |
|
159 | + 'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm', |
|
160 | + 'langs'=>'ecm', |
|
161 | + 'position'=>102, |
|
162 | + 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
163 | + 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
164 | + 'target'=>'', |
|
165 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
166 | + $r++; |
|
167 | + |
|
168 | + $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
169 | + 'type'=>'left', |
|
170 | + 'titre'=>'ECMSectionsAuto', |
|
171 | + 'mainmenu'=>'ecm', |
|
172 | + 'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm', |
|
173 | + 'langs'=>'ecm', |
|
174 | + 'position'=>103, |
|
175 | + 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
|
176 | + 'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)', |
|
177 | + 'target'=>'', |
|
178 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
179 | + $r++; |
|
180 | + } |
|
181 | 181 | } |
182 | 182 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief Description and activation file for module ECM |
24 | 24 | */ |
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 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->family = "ecm"; |
51 | 51 | $this->module_position = '10'; |
52 | 52 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
53 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
54 | 54 | // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) |
55 | 55 | $this->description = "Electronic Content Management"; |
56 | 56 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | // Key used in llx_const table to save module status enabled/disabled (XXX is id value) |
59 | 59 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
60 | 60 | // Name of png file (without png) used for this module |
61 | - $this->picto='dir'; |
|
61 | + $this->picto = 'dir'; |
|
62 | 62 | |
63 | 63 | // Data directories to create when module is enabled |
64 | 64 | $this->dirs = array("/ecm/temp"); |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $this->config_page_url = array('ecm.php'); |
68 | 68 | |
69 | 69 | // Dependencies |
70 | - $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
70 | + $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array(); // List of modules id to disable if this one is disabled |
|
72 | 72 | |
73 | 73 | // Constants |
74 | - $this->const = array(); // List of parameters |
|
75 | - $r=0; |
|
74 | + $this->const = array(); // List of parameters |
|
75 | + $r = 0; |
|
76 | 76 | |
77 | 77 | $this->const[$r][0] = "ECM_AUTO_TREE_ENABLED"; |
78 | 78 | $this->const[$r][1] = "chaine"; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $this->const[$r][4] = 0; |
82 | 82 | |
83 | 83 | // Boxes |
84 | - $this->boxes = array(); // List of boxes |
|
85 | - $r=0; |
|
84 | + $this->boxes = array(); // List of boxes |
|
85 | + $r = 0; |
|
86 | 86 | |
87 | 87 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
88 | 88 | // Example: |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | //$r++; |
93 | 93 | |
94 | 94 | // Permissions |
95 | - $this->rights_class = 'ecm'; // Permission key |
|
96 | - $this->rights = array(); // Permission array used by this module |
|
95 | + $this->rights_class = 'ecm'; // Permission key |
|
96 | + $this->rights = array(); // Permission array used by this module |
|
97 | 97 | |
98 | 98 | $r++; |
99 | 99 | $this->rights[$r][0] = 2501; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | |
120 | 120 | // Menus |
121 | 121 | //------ |
122 | - $this->menus = array(); // List of menus to add |
|
123 | - $r=0; |
|
122 | + $this->menus = array(); // List of menus to add |
|
123 | + $r = 0; |
|
124 | 124 | |
125 | 125 | // Top menu |
126 | - $this->menu[$r]=array('fk_menu'=>0, |
|
126 | + $this->menu[$r] = array('fk_menu'=>0, |
|
127 | 127 | 'type'=>'top', |
128 | 128 | 'titre'=>'MenuECM', |
129 | 129 | 'mainmenu'=>'ecm', |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup', |
134 | 134 | 'enabled'=>'$conf->ecm->enabled', |
135 | 135 | 'target'=>'', |
136 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
136 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
137 | 137 | $r++; |
138 | 138 | |
139 | 139 | // Left menu linked to top menu |
140 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm', |
|
140 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm', |
|
141 | 141 | 'type'=>'left', |
142 | 142 | 'titre'=>'ECMArea', |
143 | 143 | 'mainmenu'=>'ecm', |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
149 | 149 | 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
150 | 150 | 'target'=>'', |
151 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
151 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
152 | 152 | $r++; |
153 | 153 | |
154 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
154 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
155 | 155 | 'type'=>'left', |
156 | 156 | 'titre'=>'ECMSectionsManual', |
157 | 157 | 'mainmenu'=>'ecm', |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
163 | 163 | 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
164 | 164 | 'target'=>'', |
165 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
165 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
166 | 166 | $r++; |
167 | 167 | |
168 | - $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
168 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm', |
|
169 | 169 | 'type'=>'left', |
170 | 170 | 'titre'=>'ECMSectionsAuto', |
171 | 171 | 'mainmenu'=>'ecm', |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload', |
176 | 176 | 'enabled'=>'($user->rights->ecm->read || $user->rights->ecm->upload) && ! empty($conf->global->ECM_AUTO_TREE_ENABLED)', |
177 | 177 | 'target'=>'', |
178 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
178 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
179 | 179 | $r++; |
180 | 180 | } |
181 | 181 | } |
@@ -32,106 +32,106 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class pdf_squille extends ModelePdfReception |
34 | 34 | { |
35 | - var $emetteur; // Objet societe qui emet |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Constructor |
|
40 | - * |
|
41 | - * @param DoliDB $db Database handler |
|
42 | - */ |
|
43 | - function __construct($db=0) |
|
44 | - { |
|
45 | - global $conf,$langs,$mysoc; |
|
46 | - |
|
47 | - $this->db = $db; |
|
48 | - $this->name = "squille"; |
|
49 | - $this->description = $langs->trans("DocumentModelStandardPDF"); |
|
50 | - |
|
51 | - $this->type = 'pdf'; |
|
52 | - $formatarray=pdf_getFormat(); |
|
53 | - $this->page_largeur = $formatarray['width']; |
|
54 | - $this->page_hauteur = $formatarray['height']; |
|
55 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
56 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
57 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
58 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
59 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
60 | - |
|
61 | - $this->option_logo = 1; |
|
62 | - |
|
63 | - // Get source company |
|
64 | - $this->emetteur=$mysoc; |
|
65 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
66 | - |
|
67 | - // Define position of columns |
|
68 | - $this->posxdesc=$this->marge_gauche+1; |
|
69 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
70 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
71 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
72 | - $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
73 | - |
|
74 | - if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
75 | - |
|
76 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
77 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
78 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
79 | - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
80 | - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
81 | - } |
|
82 | - |
|
83 | - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
84 | - |
|
85 | - if ($this->page_largeur < 210) // To work with US executive format |
|
86 | - { |
|
87 | - $this->posxweightvol-=20; |
|
88 | - $this->posxpicture-=20; |
|
89 | - $this->posxqtyordered-=20; |
|
90 | - $this->posxqtytoship-=20; |
|
91 | - } |
|
35 | + var $emetteur; // Objet societe qui emet |
|
92 | 36 | |
93 | - if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
94 | - { |
|
95 | - $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
|
96 | - $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
|
97 | - $this->posxqtyordered = $this->posxqtytoship; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
102 | - /** |
|
103 | - * Function to build pdf onto disk |
|
104 | - * |
|
105 | - * @param Object $object Object reception to generate (or id if old method) |
|
106 | - * @param Translate $outputlangs Lang output object |
|
37 | + |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + * |
|
41 | + * @param DoliDB $db Database handler |
|
42 | + */ |
|
43 | + function __construct($db=0) |
|
44 | + { |
|
45 | + global $conf,$langs,$mysoc; |
|
46 | + |
|
47 | + $this->db = $db; |
|
48 | + $this->name = "squille"; |
|
49 | + $this->description = $langs->trans("DocumentModelStandardPDF"); |
|
50 | + |
|
51 | + $this->type = 'pdf'; |
|
52 | + $formatarray=pdf_getFormat(); |
|
53 | + $this->page_largeur = $formatarray['width']; |
|
54 | + $this->page_hauteur = $formatarray['height']; |
|
55 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
56 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
57 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
58 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
59 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
60 | + |
|
61 | + $this->option_logo = 1; |
|
62 | + |
|
63 | + // Get source company |
|
64 | + $this->emetteur=$mysoc; |
|
65 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
66 | + |
|
67 | + // Define position of columns |
|
68 | + $this->posxdesc=$this->marge_gauche+1; |
|
69 | + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
70 | + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
71 | + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
72 | + $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
73 | + |
|
74 | + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
75 | + |
|
76 | + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
77 | + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
78 | + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
79 | + $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
80 | + $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
81 | + } |
|
82 | + |
|
83 | + $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
84 | + |
|
85 | + if ($this->page_largeur < 210) // To work with US executive format |
|
86 | + { |
|
87 | + $this->posxweightvol-=20; |
|
88 | + $this->posxpicture-=20; |
|
89 | + $this->posxqtyordered-=20; |
|
90 | + $this->posxqtytoship-=20; |
|
91 | + } |
|
92 | + |
|
93 | + if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
94 | + { |
|
95 | + $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
|
96 | + $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
|
97 | + $this->posxqtyordered = $this->posxqtytoship; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
102 | + /** |
|
103 | + * Function to build pdf onto disk |
|
104 | + * |
|
105 | + * @param Object $object Object reception to generate (or id if old method) |
|
106 | + * @param Translate $outputlangs Lang output object |
|
107 | 107 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
108 | 108 | * @param int $hidedetails Do not show line details |
109 | 109 | * @param int $hidedesc Do not show desc |
110 | 110 | * @param int $hideref Do not show ref |
111 | 111 | * @return int 1=OK, 0=KO |
112 | - */ |
|
113 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
114 | - { |
|
115 | - // phpcs:enable |
|
116 | - global $user,$conf,$langs,$hookmanager; |
|
117 | - |
|
118 | - $object->fetch_thirdparty(); |
|
119 | - |
|
120 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
121 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
122 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
123 | - |
|
124 | - $outputlangs->load("main"); |
|
125 | - $outputlangs->load("dict"); |
|
126 | - $outputlangs->load("companies"); |
|
127 | - $outputlangs->load("bills"); |
|
128 | - $outputlangs->load("products"); |
|
129 | - $outputlangs->load("propal"); |
|
130 | - $outputlangs->load("deliveries"); |
|
112 | + */ |
|
113 | + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
114 | + { |
|
115 | + // phpcs:enable |
|
116 | + global $user,$conf,$langs,$hookmanager; |
|
117 | + |
|
118 | + $object->fetch_thirdparty(); |
|
119 | + |
|
120 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
121 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
122 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
123 | + |
|
124 | + $outputlangs->load("main"); |
|
125 | + $outputlangs->load("dict"); |
|
126 | + $outputlangs->load("companies"); |
|
127 | + $outputlangs->load("bills"); |
|
128 | + $outputlangs->load("products"); |
|
129 | + $outputlangs->load("propal"); |
|
130 | + $outputlangs->load("deliveries"); |
|
131 | 131 | $outputlangs->load("receptions"); |
132 | - $outputlangs->load("productbatch"); |
|
132 | + $outputlangs->load("productbatch"); |
|
133 | 133 | |
134 | - $nblignes = count($object->lines); |
|
134 | + $nblignes = count($object->lines); |
|
135 | 135 | |
136 | 136 | // Loop on each lines to detect if there is at least one image to show |
137 | 137 | $realpatharray=array(); |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | { |
144 | 144 | if (empty($object->lines[$i]->fk_product)) continue; |
145 | 145 | |
146 | - $objphoto = new Product($this->db); |
|
147 | - $objphoto->fetch($object->lines[$i]->fk_product); |
|
146 | + $objphoto = new Product($this->db); |
|
147 | + $objphoto->fetch($object->lines[$i]->fk_product); |
|
148 | 148 | |
149 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
150 | - $dir = $conf->product->dir_output.'/'.$pdir; |
|
149 | + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
150 | + $dir = $conf->product->dir_output.'/'.$pdir; |
|
151 | 151 | |
152 | - $realpath=''; |
|
152 | + $realpath=''; |
|
153 | 153 | |
154 | 154 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
155 | 155 | { |
@@ -179,51 +179,51 @@ discard block |
||
179 | 179 | |
180 | 180 | if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
181 | 181 | |
182 | - if ($conf->reception->dir_output) |
|
183 | - { |
|
184 | - // Definition de $dir et $file |
|
185 | - if ($object->specimen) |
|
186 | - { |
|
187 | - $dir = $conf->reception->dir_output; |
|
188 | - $file = $dir . "/SPECIMEN.pdf"; |
|
189 | - } |
|
190 | - else |
|
191 | - { |
|
192 | - $rcpref = dol_sanitizeFileName($object->ref); |
|
193 | - $dir = $conf->reception->dir_output."/" . $rcpref; |
|
194 | - $file = $dir . "/" . $rcpref . ".pdf"; |
|
195 | - } |
|
196 | - |
|
197 | - if (! file_exists($dir)) |
|
198 | - { |
|
199 | - if (dol_mkdir($dir) < 0) |
|
200 | - { |
|
201 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | - return 0; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - if (file_exists($dir)) |
|
207 | - { |
|
208 | - // Add pdfgeneration hook |
|
209 | - if (! is_object($hookmanager)) |
|
210 | - { |
|
211 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | - $hookmanager=new HookManager($this->db); |
|
213 | - } |
|
214 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | - global $action; |
|
217 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | - |
|
219 | - // Set nblignes with the new facture lines content after hook |
|
220 | - $nblignes = count($object->lines); |
|
221 | - |
|
222 | - $pdf=pdf_getInstance($this->format); |
|
223 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
224 | - $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
226 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
182 | + if ($conf->reception->dir_output) |
|
183 | + { |
|
184 | + // Definition de $dir et $file |
|
185 | + if ($object->specimen) |
|
186 | + { |
|
187 | + $dir = $conf->reception->dir_output; |
|
188 | + $file = $dir . "/SPECIMEN.pdf"; |
|
189 | + } |
|
190 | + else |
|
191 | + { |
|
192 | + $rcpref = dol_sanitizeFileName($object->ref); |
|
193 | + $dir = $conf->reception->dir_output."/" . $rcpref; |
|
194 | + $file = $dir . "/" . $rcpref . ".pdf"; |
|
195 | + } |
|
196 | + |
|
197 | + if (! file_exists($dir)) |
|
198 | + { |
|
199 | + if (dol_mkdir($dir) < 0) |
|
200 | + { |
|
201 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | + return 0; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + if (file_exists($dir)) |
|
207 | + { |
|
208 | + // Add pdfgeneration hook |
|
209 | + if (! is_object($hookmanager)) |
|
210 | + { |
|
211 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | + $hookmanager=new HookManager($this->db); |
|
213 | + } |
|
214 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | + global $action; |
|
217 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | + |
|
219 | + // Set nblignes with the new facture lines content after hook |
|
220 | + $nblignes = count($object->lines); |
|
221 | + |
|
222 | + $pdf=pdf_getInstance($this->format); |
|
223 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
224 | + $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
226 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | 227 | $pdf->SetAutoPageBreak(1,0); |
228 | 228 | |
229 | 229 | if (class_exists('TCPDF')) |
@@ -239,803 +239,803 @@ discard block |
||
239 | 239 | $tplidx = $pdf->importPage(1); |
240 | 240 | } |
241 | 241 | |
242 | - $pdf->Open(); |
|
243 | - $pagenb=0; |
|
244 | - $pdf->SetDrawColor(128,128,128); |
|
245 | - |
|
246 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
247 | - |
|
248 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
249 | - $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
|
250 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
251 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
252 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
|
253 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
254 | - |
|
255 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
256 | - |
|
257 | - // New page |
|
258 | - $pdf->AddPage(); |
|
259 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
260 | - $pagenb++; |
|
261 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
262 | - $pdf->SetFont('','', $default_font_size - 1); |
|
263 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | - $pdf->SetTextColor(0,0,0); |
|
265 | - |
|
266 | - $tab_top = 90; |
|
267 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
268 | - $tab_height = 130; |
|
269 | - $tab_height_newpage = 150; |
|
270 | - |
|
271 | - // Incoterm |
|
272 | - $height_incoterms = 0; |
|
273 | - if ($conf->incoterm->enabled) |
|
274 | - { |
|
275 | - $desc_incoterms = $object->getIncotermsForPDF(); |
|
276 | - if ($desc_incoterms) |
|
277 | - { |
|
278 | - $tab_top = 88; |
|
279 | - |
|
280 | - $pdf->SetFont('','', $default_font_size - 1); |
|
281 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
282 | - $nexY = $pdf->GetY(); |
|
283 | - $height_incoterms=$nexY-$tab_top; |
|
284 | - |
|
285 | - // Rect prend une longueur en 3eme param |
|
286 | - $pdf->SetDrawColor(192,192,192); |
|
287 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
288 | - |
|
289 | - $tab_top = $nexY+6; |
|
290 | - $height_incoterms += 4; |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
295 | - { |
|
296 | - $tab_top = 88 + $height_incoterms; |
|
297 | - $tab_top_alt = $tab_top; |
|
298 | - |
|
299 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
300 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
301 | - |
|
302 | - $tab_top_alt = $pdf->GetY(); |
|
303 | - //$tab_top_alt += 1; |
|
304 | - |
|
305 | - // Tracking number |
|
306 | - if (! empty($object->tracking_number)) |
|
307 | - { |
|
308 | - $object->getUrlTrackingStatus($object->tracking_number); |
|
309 | - if (! empty($object->tracking_url)) |
|
310 | - { |
|
311 | - if ($object->reception_method_id > 0) |
|
312 | - { |
|
313 | - // Get code using getLabelFromKey |
|
314 | - $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
|
315 | - $label=''; |
|
316 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | - $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
318 | - //var_dump($object->tracking_url != $object->tracking_number);exit; |
|
319 | - if ($object->tracking_url != $object->tracking_number) |
|
320 | - { |
|
321 | - $label.=" : "; |
|
322 | - $label.=$object->tracking_url; |
|
323 | - } |
|
324 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
325 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
326 | - |
|
327 | - $tab_top_alt = $pdf->GetY(); |
|
328 | - } |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - // Notes |
|
333 | - if (! empty($object->note_public)) |
|
334 | - { |
|
335 | - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
337 | - } |
|
338 | - |
|
339 | - $nexY = $pdf->GetY(); |
|
340 | - $height_note=$nexY-$tab_top; |
|
341 | - |
|
342 | - // Rect prend une longueur en 3eme param |
|
343 | - $pdf->SetDrawColor(192,192,192); |
|
344 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
345 | - |
|
346 | - $tab_height = $tab_height - $height_note; |
|
347 | - $tab_top = $nexY+6; |
|
348 | - } |
|
349 | - else |
|
350 | - { |
|
351 | - $height_note=0; |
|
352 | - } |
|
353 | - |
|
354 | - $iniY = $tab_top + 7; |
|
355 | - $curY = $tab_top + 7; |
|
356 | - $nexY = $tab_top + 7; |
|
357 | - $fk_commandefourndet=0; |
|
358 | - $totalOrdered=0; |
|
359 | - // Loop on each lines |
|
360 | - for ($i = 0; $i < $nblignes; $i++) |
|
361 | - { |
|
362 | - $curY = $nexY; |
|
363 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
364 | - $pdf->SetTextColor(0,0,0); |
|
365 | - |
|
366 | - // Define size of image if we need it |
|
367 | - $imglinesize=array(); |
|
368 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
369 | - |
|
370 | - $pdf->setTopMargin($tab_top_newpage); |
|
371 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | - $pageposbefore=$pdf->getPage(); |
|
373 | - |
|
374 | - $showpricebeforepagebreak=1; |
|
375 | - $posYAfterImage=0; |
|
376 | - $posYAfterDescription=0; |
|
377 | - |
|
378 | - // We start with Photo of product line |
|
379 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
380 | - { |
|
381 | - $pdf->AddPage('','',true); |
|
382 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
384 | - $pdf->setPage($pageposbefore+1); |
|
385 | - |
|
386 | - $curY = $tab_top_newpage; |
|
387 | - $showpricebeforepagebreak=0; |
|
388 | - } |
|
389 | - |
|
390 | - if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
|
391 | - { |
|
392 | - $curX = $this->posxpicture-1; |
|
393 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
394 | - // $pdf->Image does not increase value return by getY, so we save it manually |
|
395 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
396 | - } |
|
397 | - |
|
398 | - // Description of product line |
|
399 | - $curX = $this->posxdesc-1; |
|
400 | - |
|
401 | - $pdf->startTransaction(); |
|
402 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
403 | - |
|
404 | - $pageposafter=$pdf->getPage(); |
|
405 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
406 | - { |
|
407 | - $pdf->rollbackTransaction(true); |
|
408 | - $pageposafter=$pageposbefore; |
|
409 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
410 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
411 | - |
|
412 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
413 | - |
|
414 | - $pageposafter=$pdf->getPage(); |
|
415 | - $posyafter=$pdf->GetY(); |
|
416 | - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
418 | - { |
|
419 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
420 | - { |
|
421 | - $pdf->AddPage('','',true); |
|
422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
424 | - $pdf->setPage($pageposafter+1); |
|
425 | - } |
|
426 | - } |
|
427 | - else |
|
428 | - { |
|
429 | - // We found a page break |
|
430 | - $showpricebeforepagebreak=0; |
|
431 | - } |
|
432 | - } |
|
433 | - else // No pagebreak |
|
434 | - { |
|
435 | - $pdf->commitTransaction(); |
|
436 | - } |
|
437 | - $posYAfterDescription=$pdf->GetY(); |
|
438 | - |
|
439 | - $nexY = $pdf->GetY(); |
|
440 | - $pageposafter=$pdf->getPage(); |
|
441 | - |
|
442 | - $pdf->setPage($pageposbefore); |
|
443 | - $pdf->setTopMargin($this->marge_haute); |
|
444 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
445 | - |
|
446 | - // We suppose that a too long description or photo were moved completely on next page |
|
447 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
448 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
449 | - } |
|
450 | - |
|
451 | - // We suppose that a too long description is moved completely on next page |
|
452 | - if ($pageposafter > $pageposbefore) { |
|
453 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
454 | - } |
|
455 | - |
|
456 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
457 | - |
|
458 | - $pdf->SetXY($this->posxweightvol, $curY); |
|
459 | - $weighttxt=''; |
|
460 | - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) |
|
461 | - { |
|
462 | - $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight"); |
|
463 | - } |
|
464 | - $voltxt=''; |
|
465 | - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) |
|
466 | - { |
|
467 | - $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume"); |
|
468 | - } |
|
469 | - |
|
470 | - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
471 | - //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
|
472 | - |
|
473 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
474 | - { |
|
475 | - $pdf->SetXY($this->posxqtyordered, $curY); |
|
476 | - if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ |
|
477 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
478 | - $totalOrdered+=$object->lines[$i]->qty_asked; |
|
479 | - } |
|
480 | - $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; |
|
481 | - } |
|
482 | - |
|
483 | - $pdf->SetXY($this->posxqtytoship, $curY); |
|
484 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C'); |
|
485 | - |
|
486 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
487 | - { |
|
488 | - $pdf->SetXY($this->posxpuht, $curY); |
|
489 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
490 | - |
|
491 | - $pdf->SetXY($this->posxtotalht, $curY); |
|
492 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
493 | - } |
|
494 | - |
|
495 | - $nexY+=3; |
|
496 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
497 | - |
|
498 | - // Add line |
|
499 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
500 | - { |
|
501 | - $pdf->setPage($pageposafter); |
|
502 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
503 | - //$pdf->SetDrawColor(190,190,200); |
|
504 | - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
505 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
506 | - } |
|
507 | - |
|
508 | - // Detect if some page were added automatically and output _tableau for past pages |
|
509 | - while ($pagenb < $pageposafter) |
|
510 | - { |
|
511 | - $pdf->setPage($pagenb); |
|
512 | - if ($pagenb == 1) |
|
513 | - { |
|
514 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
515 | - } |
|
516 | - else |
|
517 | - { |
|
518 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
519 | - } |
|
520 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
521 | - $pagenb++; |
|
522 | - $pdf->setPage($pagenb); |
|
523 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
524 | - } |
|
525 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
526 | - { |
|
527 | - if ($pagenb == 1) |
|
528 | - { |
|
529 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
530 | - } |
|
531 | - else |
|
532 | - { |
|
533 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
534 | - } |
|
535 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
536 | - // New page |
|
537 | - $pdf->AddPage(); |
|
538 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
539 | - $pagenb++; |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - // Show square |
|
544 | - if ($pagenb == 1) |
|
545 | - { |
|
546 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
547 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
548 | - } |
|
549 | - else |
|
550 | - { |
|
551 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
552 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
553 | - } |
|
554 | - |
|
555 | - // Affiche zone totaux |
|
556 | - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
557 | - |
|
558 | - // Pied de page |
|
559 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
560 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
561 | - |
|
562 | - $pdf->Close(); |
|
563 | - |
|
564 | - $pdf->Output($file,'F'); |
|
565 | - |
|
566 | - // Add pdfgeneration hook |
|
567 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
568 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
569 | - global $action; |
|
570 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
571 | - |
|
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
574 | - |
|
575 | - return 1; // No error |
|
576 | - } |
|
577 | - else |
|
578 | - { |
|
579 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
580 | - return 0; |
|
581 | - } |
|
582 | - } |
|
583 | - else |
|
584 | - { |
|
585 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
586 | - return 0; |
|
587 | - } |
|
588 | - } |
|
589 | - |
|
590 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
591 | - /** |
|
592 | - * Show total to pay |
|
593 | - * |
|
594 | - * @param PDF $pdf Object PDF |
|
595 | - * @param Facture $object Object invoice |
|
596 | - * @param int $deja_regle Montant deja regle |
|
597 | - * @param int $posy Position depart |
|
598 | - * @param Translate $outputlangs Objet langs |
|
599 | - * @param int $totalOrdered Total ordered |
|
600 | - * @return int Position pour suite |
|
601 | - */ |
|
602 | - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) |
|
603 | - { |
|
604 | - // phpcs:enable |
|
605 | - global $conf,$mysoc; |
|
242 | + $pdf->Open(); |
|
243 | + $pagenb=0; |
|
244 | + $pdf->SetDrawColor(128,128,128); |
|
245 | + |
|
246 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
247 | + |
|
248 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
249 | + $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
|
250 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
251 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
252 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
|
253 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
254 | + |
|
255 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
256 | + |
|
257 | + // New page |
|
258 | + $pdf->AddPage(); |
|
259 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
260 | + $pagenb++; |
|
261 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
262 | + $pdf->SetFont('','', $default_font_size - 1); |
|
263 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | + $pdf->SetTextColor(0,0,0); |
|
265 | + |
|
266 | + $tab_top = 90; |
|
267 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
268 | + $tab_height = 130; |
|
269 | + $tab_height_newpage = 150; |
|
270 | + |
|
271 | + // Incoterm |
|
272 | + $height_incoterms = 0; |
|
273 | + if ($conf->incoterm->enabled) |
|
274 | + { |
|
275 | + $desc_incoterms = $object->getIncotermsForPDF(); |
|
276 | + if ($desc_incoterms) |
|
277 | + { |
|
278 | + $tab_top = 88; |
|
279 | + |
|
280 | + $pdf->SetFont('','', $default_font_size - 1); |
|
281 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
282 | + $nexY = $pdf->GetY(); |
|
283 | + $height_incoterms=$nexY-$tab_top; |
|
284 | + |
|
285 | + // Rect prend une longueur en 3eme param |
|
286 | + $pdf->SetDrawColor(192,192,192); |
|
287 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
288 | + |
|
289 | + $tab_top = $nexY+6; |
|
290 | + $height_incoterms += 4; |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
295 | + { |
|
296 | + $tab_top = 88 + $height_incoterms; |
|
297 | + $tab_top_alt = $tab_top; |
|
298 | + |
|
299 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
300 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
301 | + |
|
302 | + $tab_top_alt = $pdf->GetY(); |
|
303 | + //$tab_top_alt += 1; |
|
304 | + |
|
305 | + // Tracking number |
|
306 | + if (! empty($object->tracking_number)) |
|
307 | + { |
|
308 | + $object->getUrlTrackingStatus($object->tracking_number); |
|
309 | + if (! empty($object->tracking_url)) |
|
310 | + { |
|
311 | + if ($object->reception_method_id > 0) |
|
312 | + { |
|
313 | + // Get code using getLabelFromKey |
|
314 | + $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
|
315 | + $label=''; |
|
316 | + if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | + $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
318 | + //var_dump($object->tracking_url != $object->tracking_number);exit; |
|
319 | + if ($object->tracking_url != $object->tracking_number) |
|
320 | + { |
|
321 | + $label.=" : "; |
|
322 | + $label.=$object->tracking_url; |
|
323 | + } |
|
324 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
325 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
326 | + |
|
327 | + $tab_top_alt = $pdf->GetY(); |
|
328 | + } |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + // Notes |
|
333 | + if (! empty($object->note_public)) |
|
334 | + { |
|
335 | + $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
337 | + } |
|
338 | + |
|
339 | + $nexY = $pdf->GetY(); |
|
340 | + $height_note=$nexY-$tab_top; |
|
341 | + |
|
342 | + // Rect prend une longueur en 3eme param |
|
343 | + $pdf->SetDrawColor(192,192,192); |
|
344 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
345 | + |
|
346 | + $tab_height = $tab_height - $height_note; |
|
347 | + $tab_top = $nexY+6; |
|
348 | + } |
|
349 | + else |
|
350 | + { |
|
351 | + $height_note=0; |
|
352 | + } |
|
353 | + |
|
354 | + $iniY = $tab_top + 7; |
|
355 | + $curY = $tab_top + 7; |
|
356 | + $nexY = $tab_top + 7; |
|
357 | + $fk_commandefourndet=0; |
|
358 | + $totalOrdered=0; |
|
359 | + // Loop on each lines |
|
360 | + for ($i = 0; $i < $nblignes; $i++) |
|
361 | + { |
|
362 | + $curY = $nexY; |
|
363 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
364 | + $pdf->SetTextColor(0,0,0); |
|
365 | + |
|
366 | + // Define size of image if we need it |
|
367 | + $imglinesize=array(); |
|
368 | + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
369 | + |
|
370 | + $pdf->setTopMargin($tab_top_newpage); |
|
371 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | + $pageposbefore=$pdf->getPage(); |
|
373 | + |
|
374 | + $showpricebeforepagebreak=1; |
|
375 | + $posYAfterImage=0; |
|
376 | + $posYAfterDescription=0; |
|
377 | + |
|
378 | + // We start with Photo of product line |
|
379 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
380 | + { |
|
381 | + $pdf->AddPage('','',true); |
|
382 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
384 | + $pdf->setPage($pageposbefore+1); |
|
385 | + |
|
386 | + $curY = $tab_top_newpage; |
|
387 | + $showpricebeforepagebreak=0; |
|
388 | + } |
|
389 | + |
|
390 | + if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
|
391 | + { |
|
392 | + $curX = $this->posxpicture-1; |
|
393 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
394 | + // $pdf->Image does not increase value return by getY, so we save it manually |
|
395 | + $posYAfterImage=$curY+$imglinesize['height']; |
|
396 | + } |
|
397 | + |
|
398 | + // Description of product line |
|
399 | + $curX = $this->posxdesc-1; |
|
400 | + |
|
401 | + $pdf->startTransaction(); |
|
402 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
403 | + |
|
404 | + $pageposafter=$pdf->getPage(); |
|
405 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
406 | + { |
|
407 | + $pdf->rollbackTransaction(true); |
|
408 | + $pageposafter=$pageposbefore; |
|
409 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
410 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
411 | + |
|
412 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
413 | + |
|
414 | + $pageposafter=$pdf->getPage(); |
|
415 | + $posyafter=$pdf->GetY(); |
|
416 | + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
|
417 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
418 | + { |
|
419 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
420 | + { |
|
421 | + $pdf->AddPage('','',true); |
|
422 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
424 | + $pdf->setPage($pageposafter+1); |
|
425 | + } |
|
426 | + } |
|
427 | + else |
|
428 | + { |
|
429 | + // We found a page break |
|
430 | + $showpricebeforepagebreak=0; |
|
431 | + } |
|
432 | + } |
|
433 | + else // No pagebreak |
|
434 | + { |
|
435 | + $pdf->commitTransaction(); |
|
436 | + } |
|
437 | + $posYAfterDescription=$pdf->GetY(); |
|
438 | + |
|
439 | + $nexY = $pdf->GetY(); |
|
440 | + $pageposafter=$pdf->getPage(); |
|
441 | + |
|
442 | + $pdf->setPage($pageposbefore); |
|
443 | + $pdf->setTopMargin($this->marge_haute); |
|
444 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
445 | + |
|
446 | + // We suppose that a too long description or photo were moved completely on next page |
|
447 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
448 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
449 | + } |
|
450 | + |
|
451 | + // We suppose that a too long description is moved completely on next page |
|
452 | + if ($pageposafter > $pageposbefore) { |
|
453 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
454 | + } |
|
455 | + |
|
456 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
457 | + |
|
458 | + $pdf->SetXY($this->posxweightvol, $curY); |
|
459 | + $weighttxt=''; |
|
460 | + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) |
|
461 | + { |
|
462 | + $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight"); |
|
463 | + } |
|
464 | + $voltxt=''; |
|
465 | + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) |
|
466 | + { |
|
467 | + $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume"); |
|
468 | + } |
|
469 | + |
|
470 | + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
471 | + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
|
472 | + |
|
473 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
474 | + { |
|
475 | + $pdf->SetXY($this->posxqtyordered, $curY); |
|
476 | + if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ |
|
477 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
478 | + $totalOrdered+=$object->lines[$i]->qty_asked; |
|
479 | + } |
|
480 | + $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; |
|
481 | + } |
|
482 | + |
|
483 | + $pdf->SetXY($this->posxqtytoship, $curY); |
|
484 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C'); |
|
485 | + |
|
486 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
487 | + { |
|
488 | + $pdf->SetXY($this->posxpuht, $curY); |
|
489 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
490 | + |
|
491 | + $pdf->SetXY($this->posxtotalht, $curY); |
|
492 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
493 | + } |
|
494 | + |
|
495 | + $nexY+=3; |
|
496 | + if ($weighttxt && $voltxt) $nexY+=2; |
|
497 | + |
|
498 | + // Add line |
|
499 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
500 | + { |
|
501 | + $pdf->setPage($pageposafter); |
|
502 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
503 | + //$pdf->SetDrawColor(190,190,200); |
|
504 | + $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
505 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
506 | + } |
|
507 | + |
|
508 | + // Detect if some page were added automatically and output _tableau for past pages |
|
509 | + while ($pagenb < $pageposafter) |
|
510 | + { |
|
511 | + $pdf->setPage($pagenb); |
|
512 | + if ($pagenb == 1) |
|
513 | + { |
|
514 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
515 | + } |
|
516 | + else |
|
517 | + { |
|
518 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
519 | + } |
|
520 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
521 | + $pagenb++; |
|
522 | + $pdf->setPage($pagenb); |
|
523 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
524 | + } |
|
525 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
526 | + { |
|
527 | + if ($pagenb == 1) |
|
528 | + { |
|
529 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
530 | + } |
|
531 | + else |
|
532 | + { |
|
533 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
534 | + } |
|
535 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
536 | + // New page |
|
537 | + $pdf->AddPage(); |
|
538 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
539 | + $pagenb++; |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + // Show square |
|
544 | + if ($pagenb == 1) |
|
545 | + { |
|
546 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
547 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
548 | + } |
|
549 | + else |
|
550 | + { |
|
551 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
552 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
553 | + } |
|
554 | + |
|
555 | + // Affiche zone totaux |
|
556 | + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
557 | + |
|
558 | + // Pied de page |
|
559 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
560 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
561 | + |
|
562 | + $pdf->Close(); |
|
563 | + |
|
564 | + $pdf->Output($file,'F'); |
|
565 | + |
|
566 | + // Add pdfgeneration hook |
|
567 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
568 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
569 | + global $action; |
|
570 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
571 | + |
|
572 | + if (! empty($conf->global->MAIN_UMASK)) |
|
573 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
574 | + |
|
575 | + return 1; // No error |
|
576 | + } |
|
577 | + else |
|
578 | + { |
|
579 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
580 | + return 0; |
|
581 | + } |
|
582 | + } |
|
583 | + else |
|
584 | + { |
|
585 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
586 | + return 0; |
|
587 | + } |
|
588 | + } |
|
589 | + |
|
590 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
591 | + /** |
|
592 | + * Show total to pay |
|
593 | + * |
|
594 | + * @param PDF $pdf Object PDF |
|
595 | + * @param Facture $object Object invoice |
|
596 | + * @param int $deja_regle Montant deja regle |
|
597 | + * @param int $posy Position depart |
|
598 | + * @param Translate $outputlangs Objet langs |
|
599 | + * @param int $totalOrdered Total ordered |
|
600 | + * @return int Position pour suite |
|
601 | + */ |
|
602 | + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) |
|
603 | + { |
|
604 | + // phpcs:enable |
|
605 | + global $conf,$mysoc; |
|
606 | 606 | |
607 | 607 | $sign=1; |
608 | 608 | |
609 | 609 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
610 | 610 | |
611 | - $tab2_top = $posy; |
|
612 | - $tab2_hl = 4; |
|
613 | - $pdf->SetFont('','B', $default_font_size - 1); |
|
611 | + $tab2_top = $posy; |
|
612 | + $tab2_hl = 4; |
|
613 | + $pdf->SetFont('','B', $default_font_size - 1); |
|
614 | 614 | |
615 | - // Tableau total |
|
616 | - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
617 | - /*if ($this->page_largeur < 210) // To work with US executive format |
|
615 | + // Tableau total |
|
616 | + $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
617 | + /*if ($this->page_largeur < 210) // To work with US executive format |
|
618 | 618 | { |
619 | 619 | $col2x-=20; |
620 | 620 | }*/ |
621 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | - else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
621 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | + else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
623 | 623 | |
624 | - $useborder=0; |
|
625 | - $index = 0; |
|
624 | + $useborder=0; |
|
625 | + $index = 0; |
|
626 | 626 | |
627 | - $totalWeighttoshow=''; |
|
628 | - $totalVolumetoshow=''; |
|
627 | + $totalWeighttoshow=''; |
|
628 | + $totalVolumetoshow=''; |
|
629 | 629 | |
630 | - // Load dim data |
|
631 | - $tmparray=$object->getTotalWeightVolume(); |
|
632 | - $totalWeight=$tmparray['weight']; |
|
633 | - $totalVolume=$tmparray['volume']; |
|
634 | - $totalToShip=$tmparray['toship']; |
|
630 | + // Load dim data |
|
631 | + $tmparray=$object->getTotalWeightVolume(); |
|
632 | + $totalWeight=$tmparray['weight']; |
|
633 | + $totalVolume=$tmparray['volume']; |
|
634 | + $totalToShip=$tmparray['toship']; |
|
635 | 635 | |
636 | 636 | |
637 | - // Set trueVolume and volume_units not currently stored into database |
|
638 | - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
|
639 | - { |
|
640 | - $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | - $object->volume_units=$object->size_units * 3; |
|
642 | - } |
|
637 | + // Set trueVolume and volume_units not currently stored into database |
|
638 | + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
|
639 | + { |
|
640 | + $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | + $object->volume_units=$object->size_units * 3; |
|
642 | + } |
|
643 | 643 | |
644 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
644 | + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | + if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | + if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | + if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
648 | 648 | |
649 | - $pdf->SetFillColor(255,255,255); |
|
650 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
651 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
649 | + $pdf->SetFillColor(255,255,255); |
|
650 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
651 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
652 | 652 | |
653 | 653 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
654 | 654 | { |
655 | 655 | $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); |
656 | - $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); |
|
656 | + $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); |
|
657 | 657 | } |
658 | 658 | |
659 | - $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
|
660 | - $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
|
659 | + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
|
660 | + $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
|
661 | + |
|
662 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
661 | 663 | |
662 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
664 | + $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
|
665 | + $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
|
663 | 666 | |
664 | - $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
|
665 | - $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
|
667 | + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); |
|
668 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); |
|
669 | + } |
|
666 | 670 | |
667 | - $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); |
|
668 | - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); |
|
669 | - } |
|
671 | + // Total Weight |
|
672 | + if ($totalWeighttoshow) |
|
673 | + { |
|
674 | + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
675 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); |
|
670 | 676 | |
671 | - // Total Weight |
|
672 | - if ($totalWeighttoshow) |
|
673 | - { |
|
674 | - $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
675 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); |
|
677 | + $index++; |
|
678 | + } |
|
679 | + if ($totalVolumetoshow) |
|
680 | + { |
|
681 | + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
682 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); |
|
676 | 683 | |
677 | - $index++; |
|
678 | - } |
|
679 | - if ($totalVolumetoshow) |
|
680 | - { |
|
681 | - $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); |
|
682 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); |
|
683 | - |
|
684 | - $index++; |
|
685 | - } |
|
686 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
687 | - |
|
688 | - $pdf->SetTextColor(0,0,0); |
|
689 | - |
|
690 | - return ($tab2_top + ($tab2_hl * $index)); |
|
691 | - } |
|
692 | - |
|
693 | - /** |
|
694 | - * Show table for lines |
|
695 | - * |
|
696 | - * @param PDF $pdf Object PDF |
|
697 | - * @param string $tab_top Top position of table |
|
698 | - * @param string $tab_height Height of table (rectangle) |
|
699 | - * @param int $nexY Y |
|
700 | - * @param Translate $outputlangs Langs object |
|
701 | - * @param int $hidetop Hide top bar of array |
|
702 | - * @param int $hidebottom Hide bottom bar of array |
|
703 | - * @return void |
|
704 | - */ |
|
705 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
706 | - { |
|
707 | - global $conf; |
|
708 | - |
|
709 | - // Force to disable hidetop and hidebottom |
|
710 | - $hidebottom=0; |
|
711 | - if ($hidetop) $hidetop=-1; |
|
712 | - |
|
713 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
714 | - |
|
715 | - // Amount in (at tab_top - 1) |
|
716 | - $pdf->SetTextColor(0,0,0); |
|
717 | - $pdf->SetFont('','',$default_font_size - 2); |
|
718 | - |
|
719 | - // Output Rect |
|
720 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
721 | - |
|
722 | - $pdf->SetDrawColor(128,128,128); |
|
723 | - $pdf->SetFont('','', $default_font_size - 1); |
|
724 | - |
|
725 | - if (empty($hidetop)) |
|
726 | - { |
|
727 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
684 | + $index++; |
|
685 | + } |
|
686 | + if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
728 | 687 | |
729 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
730 | - $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
|
731 | - } |
|
688 | + $pdf->SetTextColor(0,0,0); |
|
732 | 689 | |
733 | - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
734 | - if (empty($hidetop)) |
|
735 | - { |
|
736 | - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
737 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
738 | - } |
|
690 | + return ($tab2_top + ($tab2_hl * $index)); |
|
691 | + } |
|
692 | + |
|
693 | + /** |
|
694 | + * Show table for lines |
|
695 | + * |
|
696 | + * @param PDF $pdf Object PDF |
|
697 | + * @param string $tab_top Top position of table |
|
698 | + * @param string $tab_height Height of table (rectangle) |
|
699 | + * @param int $nexY Y |
|
700 | + * @param Translate $outputlangs Langs object |
|
701 | + * @param int $hidetop Hide top bar of array |
|
702 | + * @param int $hidebottom Hide bottom bar of array |
|
703 | + * @return void |
|
704 | + */ |
|
705 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
706 | + { |
|
707 | + global $conf; |
|
708 | + |
|
709 | + // Force to disable hidetop and hidebottom |
|
710 | + $hidebottom=0; |
|
711 | + if ($hidetop) $hidetop=-1; |
|
712 | + |
|
713 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
714 | + |
|
715 | + // Amount in (at tab_top - 1) |
|
716 | + $pdf->SetTextColor(0,0,0); |
|
717 | + $pdf->SetFont('','',$default_font_size - 2); |
|
718 | + |
|
719 | + // Output Rect |
|
720 | + $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
721 | + |
|
722 | + $pdf->SetDrawColor(128,128,128); |
|
723 | + $pdf->SetFont('','', $default_font_size - 1); |
|
724 | + |
|
725 | + if (empty($hidetop)) |
|
726 | + { |
|
727 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
728 | + |
|
729 | + $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
730 | + $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
|
731 | + } |
|
732 | + |
|
733 | + $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
734 | + if (empty($hidetop)) |
|
735 | + { |
|
736 | + $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
737 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
738 | + } |
|
739 | 739 | |
740 | 740 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
741 | 741 | { |
742 | 742 | $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); |
743 | - if (empty($hidetop)) |
|
744 | - { |
|
745 | - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
746 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
747 | - } |
|
743 | + if (empty($hidetop)) |
|
744 | + { |
|
745 | + $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
746 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
751 | - if (empty($hidetop)) |
|
752 | - { |
|
753 | - $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
754 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C'); |
|
755 | - } |
|
756 | - |
|
757 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
758 | - |
|
759 | - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
760 | - if (empty($hidetop)) |
|
761 | - { |
|
762 | - $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
763 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
764 | - } |
|
765 | - |
|
766 | - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
767 | - if (empty($hidetop)) |
|
768 | - { |
|
769 | - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
770 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
771 | - } |
|
772 | - } |
|
773 | - } |
|
774 | - |
|
775 | - /** |
|
776 | - * Show top header of page. |
|
777 | - * |
|
778 | - * @param PDF $pdf Object PDF |
|
779 | - * @param Object $object Object to show |
|
780 | - * @param int $showaddress 0=no, 1=yes |
|
781 | - * @param Translate $outputlangs Object lang for output |
|
782 | - * @return void |
|
783 | - */ |
|
784 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
785 | - { |
|
786 | - global $conf,$langs,$mysoc; |
|
787 | - |
|
788 | - $langs->load("orders"); |
|
789 | - |
|
790 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
791 | - |
|
792 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
793 | - |
|
794 | - // Show Draft Watermark |
|
795 | - if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) |
|
796 | - { |
|
797 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK); |
|
798 | - } |
|
750 | + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
751 | + if (empty($hidetop)) |
|
752 | + { |
|
753 | + $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
754 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C'); |
|
755 | + } |
|
799 | 756 | |
800 | - //Prepare la suite |
|
801 | - $pdf->SetTextColor(0,0,60); |
|
802 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
757 | + if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
803 | 758 | |
804 | - $w = 110; |
|
759 | + $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
760 | + if (empty($hidetop)) |
|
761 | + { |
|
762 | + $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
763 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
764 | + } |
|
805 | 765 | |
806 | - $posy=$this->marge_haute; |
|
807 | - $posx=$this->page_largeur-$this->marge_droite-$w; |
|
766 | + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
767 | + if (empty($hidetop)) |
|
768 | + { |
|
769 | + $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
770 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
771 | + } |
|
772 | + } |
|
773 | + } |
|
808 | 774 | |
809 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
775 | + /** |
|
776 | + * Show top header of page. |
|
777 | + * |
|
778 | + * @param PDF $pdf Object PDF |
|
779 | + * @param Object $object Object to show |
|
780 | + * @param int $showaddress 0=no, 1=yes |
|
781 | + * @param Translate $outputlangs Object lang for output |
|
782 | + * @return void |
|
783 | + */ |
|
784 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
785 | + { |
|
786 | + global $conf,$langs,$mysoc; |
|
787 | + |
|
788 | + $langs->load("orders"); |
|
810 | 789 | |
811 | - // Logo |
|
812 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
813 | - if ($this->emetteur->logo) |
|
814 | - { |
|
815 | - if (is_readable($logo)) |
|
816 | - { |
|
817 | - $height=pdf_getHeightForLogo($logo); |
|
818 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
819 | - } |
|
820 | - else |
|
821 | - { |
|
822 | - $pdf->SetTextColor(200,0,0); |
|
823 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
824 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
825 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
826 | - } |
|
827 | - } |
|
828 | - else |
|
829 | - { |
|
830 | - $text=$this->emetteur->name; |
|
831 | - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
832 | - } |
|
790 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
833 | 791 | |
834 | - // Show barcode |
|
835 | - if (! empty($conf->barcode->enabled)) |
|
836 | - { |
|
837 | - $posx=105; |
|
838 | - } |
|
839 | - else |
|
840 | - { |
|
841 | - $posx=$this->marge_gauche+3; |
|
842 | - } |
|
843 | - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
|
844 | - if (! empty($conf->barcode->enabled)) |
|
845 | - { |
|
846 | - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
847 | - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
848 | - //$pdf->Image($logo,10, 5, 0, 24); |
|
849 | - } |
|
792 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
850 | 793 | |
851 | - $pdf->SetDrawColor(128,128,128); |
|
852 | - if (! empty($conf->barcode->enabled)) |
|
853 | - { |
|
854 | - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
855 | - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
856 | - //$pdf->Image($logo,10, 5, 0, 24); |
|
857 | - } |
|
794 | + // Show Draft Watermark |
|
795 | + if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) |
|
796 | + { |
|
797 | + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK); |
|
798 | + } |
|
858 | 799 | |
800 | + //Prepare la suite |
|
801 | + $pdf->SetTextColor(0,0,60); |
|
802 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
859 | 803 | |
860 | - $posx=$this->page_largeur - $w - $this->marge_droite; |
|
861 | - $posy=$this->marge_haute; |
|
804 | + $w = 110; |
|
862 | 805 | |
863 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
864 | - $pdf->SetXY($posx,$posy); |
|
865 | - $pdf->SetTextColor(0,0,60); |
|
866 | - $title=$outputlangs->transnoentities("ReceptionSheet"); |
|
867 | - $pdf->MultiCell($w, 4, $title, '', 'R'); |
|
806 | + $posy=$this->marge_haute; |
|
807 | + $posx=$this->page_largeur-$this->marge_droite-$w; |
|
868 | 808 | |
869 | - $pdf->SetFont('','', $default_font_size + 1); |
|
809 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
870 | 810 | |
871 | - $posy+=5; |
|
811 | + // Logo |
|
812 | + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
813 | + if ($this->emetteur->logo) |
|
814 | + { |
|
815 | + if (is_readable($logo)) |
|
816 | + { |
|
817 | + $height=pdf_getHeightForLogo($logo); |
|
818 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
819 | + } |
|
820 | + else |
|
821 | + { |
|
822 | + $pdf->SetTextColor(200,0,0); |
|
823 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
824 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
825 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
826 | + } |
|
827 | + } |
|
828 | + else |
|
829 | + { |
|
830 | + $text=$this->emetteur->name; |
|
831 | + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
832 | + } |
|
872 | 833 | |
873 | - $pdf->SetXY($posx,$posy); |
|
874 | - $pdf->SetTextColor(0,0,60); |
|
875 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); |
|
834 | + // Show barcode |
|
835 | + if (! empty($conf->barcode->enabled)) |
|
836 | + { |
|
837 | + $posx=105; |
|
838 | + } |
|
839 | + else |
|
840 | + { |
|
841 | + $posx=$this->marge_gauche+3; |
|
842 | + } |
|
843 | + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
|
844 | + if (! empty($conf->barcode->enabled)) |
|
845 | + { |
|
846 | + // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
847 | + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
848 | + //$pdf->Image($logo,10, 5, 0, 24); |
|
849 | + } |
|
876 | 850 | |
877 | - // Date planned delivery |
|
878 | - if (! empty($object->date_delivery)) |
|
879 | - { |
|
880 | - $posy+=4; |
|
881 | - $pdf->SetXY($posx,$posy); |
|
882 | - $pdf->SetTextColor(0,0,60); |
|
883 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
884 | - } |
|
851 | + $pdf->SetDrawColor(128,128,128); |
|
852 | + if (! empty($conf->barcode->enabled)) |
|
853 | + { |
|
854 | + // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
|
855 | + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
|
856 | + //$pdf->Image($logo,10, 5, 0, 24); |
|
857 | + } |
|
885 | 858 | |
886 | - if (! empty($object->thirdparty->code_fournisseur)) |
|
887 | - { |
|
888 | - $posy+=4; |
|
889 | - $pdf->SetXY($posx,$posy); |
|
890 | - $pdf->SetTextColor(0,0,60); |
|
891 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
892 | - } |
|
893 | 859 | |
860 | + $posx=$this->page_largeur - $w - $this->marge_droite; |
|
861 | + $posy=$this->marge_haute; |
|
894 | 862 | |
895 | - $pdf->SetFont('','', $default_font_size + 3); |
|
896 | - $Yoff=25; |
|
863 | + $pdf->SetFont('','B', $default_font_size + 2); |
|
864 | + $pdf->SetXY($posx,$posy); |
|
865 | + $pdf->SetTextColor(0,0,60); |
|
866 | + $title=$outputlangs->transnoentities("ReceptionSheet"); |
|
867 | + $pdf->MultiCell($w, 4, $title, '', 'R'); |
|
897 | 868 | |
898 | - // Add list of linked orders |
|
899 | - $origin = $object->origin; |
|
900 | - $origin_id = $object->origin_id; |
|
869 | + $pdf->SetFont('','', $default_font_size + 1); |
|
901 | 870 | |
902 | - // TODO move to external function |
|
903 | - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
904 | - { |
|
905 | - $outputlangs->load('orders'); |
|
906 | - |
|
907 | - $classname = 'CommandeFournisseur'; |
|
908 | - $linkedobject = new $classname($this->db); |
|
909 | - $result=$linkedobject->fetch($origin_id); |
|
910 | - if ($result >= 0) |
|
911 | - { |
|
912 | - //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
|
913 | - |
|
914 | - $pdf->SetFont('','', $default_font_size - 2); |
|
915 | - $text=$linkedobject->ref; |
|
916 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
917 | - $Yoff = $Yoff+8; |
|
918 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
919 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | - $Yoff = $Yoff+3; |
|
921 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
922 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
923 | - } |
|
924 | - } |
|
925 | - |
|
926 | - if ($showaddress) |
|
927 | - { |
|
928 | - // Sender properties |
|
929 | - $carac_emetteur=''; |
|
930 | - // Add internal contact of origin element if defined |
|
931 | - $arrayidcontact=array(); |
|
932 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
934 | - if (count($arrayidcontact) > 0) |
|
935 | - { |
|
936 | - $object->fetch_user(reset($arrayidcontact)); |
|
937 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
938 | - } |
|
939 | - |
|
940 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
941 | - |
|
942 | - // Show sender |
|
943 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | - $posx=$this->marge_gauche; |
|
945 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
946 | - |
|
947 | - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
949 | - |
|
950 | - // Show sender frame |
|
951 | - $pdf->SetTextColor(0,0,0); |
|
952 | - $pdf->SetFont('','', $default_font_size - 2); |
|
953 | - $pdf->SetXY($posx,$posy-5); |
|
954 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | - $pdf->SetXY($posx,$posy); |
|
956 | - $pdf->SetFillColor(230,230,230); |
|
957 | - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
|
958 | - $pdf->SetTextColor(0,0,60); |
|
959 | - $pdf->SetFillColor(255,255,255); |
|
960 | - |
|
961 | - // If RECEPTION contact defined, we use it |
|
962 | - $usecontact=false; |
|
963 | - $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
964 | - |
|
965 | - if (count($arrayidcontact) > 0) |
|
966 | - { |
|
967 | - $usecontact=true; |
|
968 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
969 | - } |
|
970 | - |
|
971 | - //Recipient name |
|
972 | - // On peut utiliser le nom de la societe du contact |
|
973 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
974 | - $thirdparty = $object->contact; |
|
975 | - } else { |
|
976 | - $thirdparty = $object->thirdparty; |
|
977 | - } |
|
978 | - |
|
979 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
980 | - |
|
981 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
982 | - |
|
983 | - // Show recipient name |
|
984 | - $pdf->SetXY($posx+2,$posy+3); |
|
985 | - $pdf->SetFont('','B', $default_font_size); |
|
986 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); |
|
987 | - |
|
988 | - $posy = $pdf->getY(); |
|
989 | - |
|
990 | - // Show recipient information |
|
991 | - $pdf->SetFont('','', $default_font_size - 1); |
|
992 | - $pdf->SetXY($posx+2,$posy); |
|
993 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); |
|
994 | - |
|
995 | - // Show recipient |
|
996 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
998 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1001 | - |
|
1002 | - // Show recipient frame |
|
1003 | - $pdf->SetTextColor(0,0,0); |
|
1004 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1005 | - $pdf->SetXY($posx+2,$posy-5); |
|
1006 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
|
1007 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1008 | - |
|
1009 | - |
|
1010 | - |
|
1011 | - // Show sender name |
|
1012 | - $pdf->SetXY($posx+2,$posy+3); |
|
1013 | - $pdf->SetFont('','B',$default_font_size); |
|
1014 | - $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1015 | - $posy=$pdf->getY(); |
|
1016 | - |
|
1017 | - // Show sender information |
|
1018 | - $pdf->SetXY($posx+2,$posy); |
|
1019 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1020 | - $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); |
|
1021 | - } |
|
1022 | - |
|
1023 | - $pdf->SetTextColor(0,0,0); |
|
1024 | - } |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * Show footer of page. Need this->emetteur object |
|
871 | + $posy+=5; |
|
872 | + |
|
873 | + $pdf->SetXY($posx,$posy); |
|
874 | + $pdf->SetTextColor(0,0,60); |
|
875 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); |
|
876 | + |
|
877 | + // Date planned delivery |
|
878 | + if (! empty($object->date_delivery)) |
|
879 | + { |
|
880 | + $posy+=4; |
|
881 | + $pdf->SetXY($posx,$posy); |
|
882 | + $pdf->SetTextColor(0,0,60); |
|
883 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
884 | + } |
|
885 | + |
|
886 | + if (! empty($object->thirdparty->code_fournisseur)) |
|
887 | + { |
|
888 | + $posy+=4; |
|
889 | + $pdf->SetXY($posx,$posy); |
|
890 | + $pdf->SetTextColor(0,0,60); |
|
891 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
892 | + } |
|
893 | + |
|
894 | + |
|
895 | + $pdf->SetFont('','', $default_font_size + 3); |
|
896 | + $Yoff=25; |
|
897 | + |
|
898 | + // Add list of linked orders |
|
899 | + $origin = $object->origin; |
|
900 | + $origin_id = $object->origin_id; |
|
901 | + |
|
902 | + // TODO move to external function |
|
903 | + if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
904 | + { |
|
905 | + $outputlangs->load('orders'); |
|
906 | + |
|
907 | + $classname = 'CommandeFournisseur'; |
|
908 | + $linkedobject = new $classname($this->db); |
|
909 | + $result=$linkedobject->fetch($origin_id); |
|
910 | + if ($result >= 0) |
|
911 | + { |
|
912 | + //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
|
913 | + |
|
914 | + $pdf->SetFont('','', $default_font_size - 2); |
|
915 | + $text=$linkedobject->ref; |
|
916 | + if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
917 | + $Yoff = $Yoff+8; |
|
918 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
919 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | + $Yoff = $Yoff+3; |
|
921 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
922 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
923 | + } |
|
924 | + } |
|
925 | + |
|
926 | + if ($showaddress) |
|
927 | + { |
|
928 | + // Sender properties |
|
929 | + $carac_emetteur=''; |
|
930 | + // Add internal contact of origin element if defined |
|
931 | + $arrayidcontact=array(); |
|
932 | + if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | + if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
934 | + if (count($arrayidcontact) > 0) |
|
935 | + { |
|
936 | + $object->fetch_user(reset($arrayidcontact)); |
|
937 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
938 | + } |
|
939 | + |
|
940 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
941 | + |
|
942 | + // Show sender |
|
943 | + $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | + $posx=$this->marge_gauche; |
|
945 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
946 | + |
|
947 | + $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | + $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
949 | + |
|
950 | + // Show sender frame |
|
951 | + $pdf->SetTextColor(0,0,0); |
|
952 | + $pdf->SetFont('','', $default_font_size - 2); |
|
953 | + $pdf->SetXY($posx,$posy-5); |
|
954 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | + $pdf->SetXY($posx,$posy); |
|
956 | + $pdf->SetFillColor(230,230,230); |
|
957 | + $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
|
958 | + $pdf->SetTextColor(0,0,60); |
|
959 | + $pdf->SetFillColor(255,255,255); |
|
960 | + |
|
961 | + // If RECEPTION contact defined, we use it |
|
962 | + $usecontact=false; |
|
963 | + $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
964 | + |
|
965 | + if (count($arrayidcontact) > 0) |
|
966 | + { |
|
967 | + $usecontact=true; |
|
968 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
969 | + } |
|
970 | + |
|
971 | + //Recipient name |
|
972 | + // On peut utiliser le nom de la societe du contact |
|
973 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
974 | + $thirdparty = $object->contact; |
|
975 | + } else { |
|
976 | + $thirdparty = $object->thirdparty; |
|
977 | + } |
|
978 | + |
|
979 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
980 | + |
|
981 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
982 | + |
|
983 | + // Show recipient name |
|
984 | + $pdf->SetXY($posx+2,$posy+3); |
|
985 | + $pdf->SetFont('','B', $default_font_size); |
|
986 | + $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); |
|
987 | + |
|
988 | + $posy = $pdf->getY(); |
|
989 | + |
|
990 | + // Show recipient information |
|
991 | + $pdf->SetFont('','', $default_font_size - 1); |
|
992 | + $pdf->SetXY($posx+2,$posy); |
|
993 | + $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); |
|
994 | + |
|
995 | + // Show recipient |
|
996 | + $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
998 | + $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | + $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1001 | + |
|
1002 | + // Show recipient frame |
|
1003 | + $pdf->SetTextColor(0,0,0); |
|
1004 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1005 | + $pdf->SetXY($posx+2,$posy-5); |
|
1006 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
|
1007 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1008 | + |
|
1009 | + |
|
1010 | + |
|
1011 | + // Show sender name |
|
1012 | + $pdf->SetXY($posx+2,$posy+3); |
|
1013 | + $pdf->SetFont('','B',$default_font_size); |
|
1014 | + $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1015 | + $posy=$pdf->getY(); |
|
1016 | + |
|
1017 | + // Show sender information |
|
1018 | + $pdf->SetXY($posx+2,$posy); |
|
1019 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1020 | + $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); |
|
1021 | + } |
|
1022 | + |
|
1023 | + $pdf->SetTextColor(0,0,0); |
|
1024 | + } |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * Show footer of page. Need this->emetteur object |
|
1028 | 1028 | * |
1029 | - * @param PDF $pdf PDF |
|
1030 | - * @param Object $object Object to show |
|
1031 | - * @param Translate $outputlangs Object lang for output |
|
1032 | - * @param int $hidefreetext 1=Hide free text |
|
1033 | - * @return int Return height of bottom margin including footer text |
|
1034 | - */ |
|
1035 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1036 | - { |
|
1037 | - global $conf; |
|
1038 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | - return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1040 | - } |
|
1029 | + * @param PDF $pdf PDF |
|
1030 | + * @param Object $object Object to show |
|
1031 | + * @param Translate $outputlangs Object lang for output |
|
1032 | + * @param int $hidefreetext 1=Hide free text |
|
1033 | + * @return int Return height of bottom margin including footer text |
|
1034 | + */ |
|
1035 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1036 | + { |
|
1037 | + global $conf; |
|
1038 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | + return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1040 | + } |
|
1041 | 1041 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class pdf_squille extends ModelePdfReception |
34 | 34 | { |
35 | - var $emetteur; // Objet societe qui emet |
|
35 | + var $emetteur; // Objet societe qui emet |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -40,57 +40,57 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param DoliDB $db Database handler |
42 | 42 | */ |
43 | - function __construct($db=0) |
|
43 | + function __construct($db = 0) |
|
44 | 44 | { |
45 | - global $conf,$langs,$mysoc; |
|
45 | + global $conf, $langs, $mysoc; |
|
46 | 46 | |
47 | 47 | $this->db = $db; |
48 | 48 | $this->name = "squille"; |
49 | 49 | $this->description = $langs->trans("DocumentModelStandardPDF"); |
50 | 50 | |
51 | 51 | $this->type = 'pdf'; |
52 | - $formatarray=pdf_getFormat(); |
|
52 | + $formatarray = pdf_getFormat(); |
|
53 | 53 | $this->page_largeur = $formatarray['width']; |
54 | 54 | $this->page_hauteur = $formatarray['height']; |
55 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
56 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
57 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
58 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
59 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
55 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
56 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
57 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
58 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
59 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
60 | 60 | |
61 | 61 | $this->option_logo = 1; |
62 | 62 | |
63 | 63 | // Get source company |
64 | - $this->emetteur=$mysoc; |
|
65 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
64 | + $this->emetteur = $mysoc; |
|
65 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
66 | 66 | |
67 | 67 | // Define position of columns |
68 | - $this->posxdesc=$this->marge_gauche+1; |
|
69 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
70 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
71 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
72 | - $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
68 | + $this->posxdesc = $this->marge_gauche + 1; |
|
69 | + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; |
|
70 | + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; |
|
71 | + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; |
|
72 | + $this->posxpuht = $this->page_largeur - $this->marge_droite; |
|
73 | 73 | |
74 | 74 | if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
75 | 75 | |
76 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
77 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
78 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
79 | - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
80 | - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
76 | + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; |
|
77 | + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; |
|
78 | + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; |
|
79 | + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; |
|
80 | + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; |
|
81 | 81 | } |
82 | 82 | |
83 | - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
83 | + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
84 | 84 | |
85 | 85 | if ($this->page_largeur < 210) // To work with US executive format |
86 | 86 | { |
87 | - $this->posxweightvol-=20; |
|
88 | - $this->posxpicture-=20; |
|
89 | - $this->posxqtyordered-=20; |
|
90 | - $this->posxqtytoship-=20; |
|
87 | + $this->posxweightvol -= 20; |
|
88 | + $this->posxpicture -= 20; |
|
89 | + $this->posxqtyordered -= 20; |
|
90 | + $this->posxqtytoship -= 20; |
|
91 | 91 | } |
92 | 92 | |
93 | - if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
93 | + if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
|
94 | 94 | { |
95 | 95 | $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
96 | 96 | $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | * @param int $hideref Do not show ref |
111 | 111 | * @return int 1=OK, 0=KO |
112 | 112 | */ |
113 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
113 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
114 | 114 | { |
115 | 115 | // phpcs:enable |
116 | - global $user,$conf,$langs,$hookmanager; |
|
116 | + global $user, $conf, $langs, $hookmanager; |
|
117 | 117 | |
118 | 118 | $object->fetch_thirdparty(); |
119 | 119 | |
120 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
120 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
121 | 121 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
122 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
122 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
123 | 123 | |
124 | 124 | $outputlangs->load("main"); |
125 | 125 | $outputlangs->load("dict"); |
@@ -134,50 +134,50 @@ discard block |
||
134 | 134 | $nblignes = count($object->lines); |
135 | 135 | |
136 | 136 | // Loop on each lines to detect if there is at least one image to show |
137 | - $realpatharray=array(); |
|
138 | - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) |
|
137 | + $realpatharray = array(); |
|
138 | + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) |
|
139 | 139 | { |
140 | 140 | $objphoto = new Product($this->db); |
141 | 141 | |
142 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
142 | + for ($i = 0; $i < $nblignes; $i++) |
|
143 | 143 | { |
144 | 144 | if (empty($object->lines[$i]->fk_product)) continue; |
145 | 145 | |
146 | 146 | $objphoto = new Product($this->db); |
147 | 147 | $objphoto->fetch($object->lines[$i]->fk_product); |
148 | 148 | |
149 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
149 | + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; |
|
150 | 150 | $dir = $conf->product->dir_output.'/'.$pdir; |
151 | 151 | |
152 | - $realpath=''; |
|
152 | + $realpath = ''; |
|
153 | 153 | |
154 | - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
154 | + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) |
|
155 | 155 | { |
156 | 156 | if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
157 | 157 | { |
158 | 158 | if ($obj['photo_vignette']) |
159 | 159 | { |
160 | - $filename= $obj['photo_vignette']; |
|
160 | + $filename = $obj['photo_vignette']; |
|
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - $filename=$obj['photo']; |
|
164 | + $filename = $obj['photo']; |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | else |
168 | 168 | { |
169 | - $filename=$obj['photo']; |
|
169 | + $filename = $obj['photo']; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $realpath = $dir.$filename; |
173 | 173 | break; |
174 | 174 | } |
175 | 175 | |
176 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
176 | + if ($realpath) $realpatharray[$i] = $realpath; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
|
180 | + if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; |
|
181 | 181 | |
182 | 182 | if ($conf->reception->dir_output) |
183 | 183 | { |
@@ -185,20 +185,20 @@ discard block |
||
185 | 185 | if ($object->specimen) |
186 | 186 | { |
187 | 187 | $dir = $conf->reception->dir_output; |
188 | - $file = $dir . "/SPECIMEN.pdf"; |
|
188 | + $file = $dir."/SPECIMEN.pdf"; |
|
189 | 189 | } |
190 | 190 | else |
191 | 191 | { |
192 | 192 | $rcpref = dol_sanitizeFileName($object->ref); |
193 | - $dir = $conf->reception->dir_output."/" . $rcpref; |
|
194 | - $file = $dir . "/" . $rcpref . ".pdf"; |
|
193 | + $dir = $conf->reception->dir_output."/".$rcpref; |
|
194 | + $file = $dir."/".$rcpref.".pdf"; |
|
195 | 195 | } |
196 | 196 | |
197 | - if (! file_exists($dir)) |
|
197 | + if (!file_exists($dir)) |
|
198 | 198 | { |
199 | 199 | if (dol_mkdir($dir) < 0) |
200 | 200 | { |
201 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
201 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
202 | 202 | return 0; |
203 | 203 | } |
204 | 204 | } |
@@ -206,25 +206,25 @@ discard block |
||
206 | 206 | if (file_exists($dir)) |
207 | 207 | { |
208 | 208 | // Add pdfgeneration hook |
209 | - if (! is_object($hookmanager)) |
|
209 | + if (!is_object($hookmanager)) |
|
210 | 210 | { |
211 | 211 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
212 | - $hookmanager=new HookManager($this->db); |
|
212 | + $hookmanager = new HookManager($this->db); |
|
213 | 213 | } |
214 | 214 | $hookmanager->initHooks(array('pdfgeneration')); |
215 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
215 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
216 | 216 | global $action; |
217 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
217 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
218 | 218 | |
219 | 219 | // Set nblignes with the new facture lines content after hook |
220 | 220 | $nblignes = count($object->lines); |
221 | 221 | |
222 | - $pdf=pdf_getInstance($this->format); |
|
222 | + $pdf = pdf_getInstance($this->format); |
|
223 | 223 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
224 | - $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
226 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | - $pdf->SetAutoPageBreak(1,0); |
|
224 | + $heightforinfotot = 8; // Height reserved to output the info and total part |
|
225 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
226 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | + $pdf->SetAutoPageBreak(1, 0); |
|
228 | 228 | |
229 | 229 | if (class_exists('TCPDF')) |
230 | 230 | { |
@@ -233,38 +233,38 @@ discard block |
||
233 | 233 | } |
234 | 234 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
235 | 235 | // Set path to the background PDF File |
236 | - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
236 | + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
237 | 237 | { |
238 | 238 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
239 | 239 | $tplidx = $pdf->importPage(1); |
240 | 240 | } |
241 | 241 | |
242 | 242 | $pdf->Open(); |
243 | - $pagenb=0; |
|
244 | - $pdf->SetDrawColor(128,128,128); |
|
243 | + $pagenb = 0; |
|
244 | + $pdf->SetDrawColor(128, 128, 128); |
|
245 | 245 | |
246 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
246 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
247 | 247 | |
248 | 248 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
249 | 249 | $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
250 | 250 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
251 | 251 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
252 | 252 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
253 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
253 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
254 | 254 | |
255 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
255 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
256 | 256 | |
257 | 257 | // New page |
258 | 258 | $pdf->AddPage(); |
259 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
259 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
260 | 260 | $pagenb++; |
261 | 261 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
262 | - $pdf->SetFont('','', $default_font_size - 1); |
|
263 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | - $pdf->SetTextColor(0,0,0); |
|
262 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
263 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
264 | + $pdf->SetTextColor(0, 0, 0); |
|
265 | 265 | |
266 | 266 | $tab_top = 90; |
267 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
267 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); |
|
268 | 268 | $tab_height = 130; |
269 | 269 | $tab_height_newpage = 150; |
270 | 270 | |
@@ -277,52 +277,52 @@ discard block |
||
277 | 277 | { |
278 | 278 | $tab_top = 88; |
279 | 279 | |
280 | - $pdf->SetFont('','', $default_font_size - 1); |
|
281 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
280 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
281 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
282 | 282 | $nexY = $pdf->GetY(); |
283 | - $height_incoterms=$nexY-$tab_top; |
|
283 | + $height_incoterms = $nexY - $tab_top; |
|
284 | 284 | |
285 | 285 | // Rect prend une longueur en 3eme param |
286 | - $pdf->SetDrawColor(192,192,192); |
|
287 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
286 | + $pdf->SetDrawColor(192, 192, 192); |
|
287 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); |
|
288 | 288 | |
289 | - $tab_top = $nexY+6; |
|
289 | + $tab_top = $nexY + 6; |
|
290 | 290 | $height_incoterms += 4; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
294 | + if (!empty($object->note_public) || !empty($object->tracking_number)) |
|
295 | 295 | { |
296 | 296 | $tab_top = 88 + $height_incoterms; |
297 | 297 | $tab_top_alt = $tab_top; |
298 | 298 | |
299 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
300 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
299 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
300 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); |
|
301 | 301 | |
302 | 302 | $tab_top_alt = $pdf->GetY(); |
303 | 303 | //$tab_top_alt += 1; |
304 | 304 | |
305 | 305 | // Tracking number |
306 | - if (! empty($object->tracking_number)) |
|
306 | + if (!empty($object->tracking_number)) |
|
307 | 307 | { |
308 | 308 | $object->getUrlTrackingStatus($object->tracking_number); |
309 | - if (! empty($object->tracking_url)) |
|
309 | + if (!empty($object->tracking_url)) |
|
310 | 310 | { |
311 | 311 | if ($object->reception_method_id > 0) |
312 | 312 | { |
313 | 313 | // Get code using getLabelFromKey |
314 | - $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
|
315 | - $label=''; |
|
316 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | - $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
314 | + $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code'); |
|
315 | + $label = ''; |
|
316 | + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
317 | + $label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
|
318 | 318 | //var_dump($object->tracking_url != $object->tracking_number);exit; |
319 | 319 | if ($object->tracking_url != $object->tracking_number) |
320 | 320 | { |
321 | - $label.=" : "; |
|
322 | - $label.=$object->tracking_url; |
|
321 | + $label .= " : "; |
|
322 | + $label .= $object->tracking_url; |
|
323 | 323 | } |
324 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
325 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
324 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
325 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
326 | 326 | |
327 | 327 | $tab_top_alt = $pdf->GetY(); |
328 | 328 | } |
@@ -330,118 +330,118 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | // Notes |
333 | - if (! empty($object->note_public)) |
|
333 | + if (!empty($object->note_public)) |
|
334 | 334 | { |
335 | - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
335 | + $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
336 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | $nexY = $pdf->GetY(); |
340 | - $height_note=$nexY-$tab_top; |
|
340 | + $height_note = $nexY - $tab_top; |
|
341 | 341 | |
342 | 342 | // Rect prend une longueur en 3eme param |
343 | - $pdf->SetDrawColor(192,192,192); |
|
344 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
343 | + $pdf->SetDrawColor(192, 192, 192); |
|
344 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
345 | 345 | |
346 | 346 | $tab_height = $tab_height - $height_note; |
347 | - $tab_top = $nexY+6; |
|
347 | + $tab_top = $nexY + 6; |
|
348 | 348 | } |
349 | 349 | else |
350 | 350 | { |
351 | - $height_note=0; |
|
351 | + $height_note = 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | $iniY = $tab_top + 7; |
355 | 355 | $curY = $tab_top + 7; |
356 | 356 | $nexY = $tab_top + 7; |
357 | - $fk_commandefourndet=0; |
|
358 | - $totalOrdered=0; |
|
357 | + $fk_commandefourndet = 0; |
|
358 | + $totalOrdered = 0; |
|
359 | 359 | // Loop on each lines |
360 | 360 | for ($i = 0; $i < $nblignes; $i++) |
361 | 361 | { |
362 | 362 | $curY = $nexY; |
363 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
364 | - $pdf->SetTextColor(0,0,0); |
|
363 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
364 | + $pdf->SetTextColor(0, 0, 0); |
|
365 | 365 | |
366 | 366 | // Define size of image if we need it |
367 | - $imglinesize=array(); |
|
368 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
367 | + $imglinesize = array(); |
|
368 | + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); |
|
369 | 369 | |
370 | 370 | $pdf->setTopMargin($tab_top_newpage); |
371 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | - $pageposbefore=$pdf->getPage(); |
|
371 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
372 | + $pageposbefore = $pdf->getPage(); |
|
373 | 373 | |
374 | - $showpricebeforepagebreak=1; |
|
375 | - $posYAfterImage=0; |
|
376 | - $posYAfterDescription=0; |
|
374 | + $showpricebeforepagebreak = 1; |
|
375 | + $posYAfterImage = 0; |
|
376 | + $posYAfterDescription = 0; |
|
377 | 377 | |
378 | 378 | // We start with Photo of product line |
379 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
379 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page |
|
380 | 380 | { |
381 | - $pdf->AddPage('','',true); |
|
382 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
381 | + $pdf->AddPage('', '', true); |
|
382 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | 383 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
384 | - $pdf->setPage($pageposbefore+1); |
|
384 | + $pdf->setPage($pageposbefore + 1); |
|
385 | 385 | |
386 | 386 | $curY = $tab_top_newpage; |
387 | - $showpricebeforepagebreak=0; |
|
387 | + $showpricebeforepagebreak = 0; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
391 | 391 | { |
392 | - $curX = $this->posxpicture-1; |
|
393 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
392 | + $curX = $this->posxpicture - 1; |
|
393 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
394 | 394 | // $pdf->Image does not increase value return by getY, so we save it manually |
395 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
395 | + $posYAfterImage = $curY + $imglinesize['height']; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | // Description of product line |
399 | - $curX = $this->posxdesc-1; |
|
399 | + $curX = $this->posxdesc - 1; |
|
400 | 400 | |
401 | 401 | $pdf->startTransaction(); |
402 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
402 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); |
|
403 | 403 | |
404 | - $pageposafter=$pdf->getPage(); |
|
404 | + $pageposafter = $pdf->getPage(); |
|
405 | 405 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
406 | 406 | { |
407 | 407 | $pdf->rollbackTransaction(true); |
408 | - $pageposafter=$pageposbefore; |
|
408 | + $pageposafter = $pageposbefore; |
|
409 | 409 | //print $pageposafter.'-'.$pageposbefore;exit; |
410 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
410 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
411 | 411 | |
412 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
412 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); |
|
413 | 413 | |
414 | - $pageposafter=$pdf->getPage(); |
|
415 | - $posyafter=$pdf->GetY(); |
|
414 | + $pageposafter = $pdf->getPage(); |
|
415 | + $posyafter = $pdf->GetY(); |
|
416 | 416 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
417 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
418 | 418 | { |
419 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
419 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
420 | 420 | { |
421 | - $pdf->AddPage('','',true); |
|
422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
421 | + $pdf->AddPage('', '', true); |
|
422 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | 423 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
424 | - $pdf->setPage($pageposafter+1); |
|
424 | + $pdf->setPage($pageposafter + 1); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | else |
428 | 428 | { |
429 | 429 | // We found a page break |
430 | - $showpricebeforepagebreak=0; |
|
430 | + $showpricebeforepagebreak = 0; |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | else // No pagebreak |
434 | 434 | { |
435 | 435 | $pdf->commitTransaction(); |
436 | 436 | } |
437 | - $posYAfterDescription=$pdf->GetY(); |
|
437 | + $posYAfterDescription = $pdf->GetY(); |
|
438 | 438 | |
439 | 439 | $nexY = $pdf->GetY(); |
440 | - $pageposafter=$pdf->getPage(); |
|
440 | + $pageposafter = $pdf->getPage(); |
|
441 | 441 | |
442 | 442 | $pdf->setPage($pageposbefore); |
443 | 443 | $pdf->setTopMargin($this->marge_haute); |
444 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
444 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
445 | 445 | |
446 | 446 | // We suppose that a too long description or photo were moved completely on next page |
447 | 447 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
@@ -453,55 +453,55 @@ discard block |
||
453 | 453 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
454 | 454 | } |
455 | 455 | |
456 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
456 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
457 | 457 | |
458 | 458 | $pdf->SetXY($this->posxweightvol, $curY); |
459 | - $weighttxt=''; |
|
459 | + $weighttxt = ''; |
|
460 | 460 | if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) |
461 | 461 | { |
462 | - $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units,"weight"); |
|
462 | + $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units, "weight"); |
|
463 | 463 | } |
464 | - $voltxt=''; |
|
464 | + $voltxt = ''; |
|
465 | 465 | if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) |
466 | 466 | { |
467 | - $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0,"volume"); |
|
467 | + $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, "volume"); |
|
468 | 468 | } |
469 | 469 | |
470 | - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
470 | + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C'); |
|
471 | 471 | //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
472 | 472 | |
473 | 473 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
474 | 474 | { |
475 | 475 | $pdf->SetXY($this->posxqtyordered, $curY); |
476 | - if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ |
|
477 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
478 | - $totalOrdered+=$object->lines[$i]->qty_asked; |
|
476 | + if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) { |
|
477 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); |
|
478 | + $totalOrdered += $object->lines[$i]->qty_asked; |
|
479 | 479 | } |
480 | 480 | $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; |
481 | 481 | } |
482 | 482 | |
483 | 483 | $pdf->SetXY($this->posxqtytoship, $curY); |
484 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,'','C'); |
|
484 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C'); |
|
485 | 485 | |
486 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
486 | + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) |
|
487 | 487 | { |
488 | 488 | $pdf->SetXY($this->posxpuht, $curY); |
489 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
489 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); |
|
490 | 490 | |
491 | 491 | $pdf->SetXY($this->posxtotalht, $curY); |
492 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
492 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); |
|
493 | 493 | } |
494 | 494 | |
495 | - $nexY+=3; |
|
496 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
495 | + $nexY += 3; |
|
496 | + if ($weighttxt && $voltxt) $nexY += 2; |
|
497 | 497 | |
498 | 498 | // Add line |
499 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
499 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
500 | 500 | { |
501 | 501 | $pdf->setPage($pageposafter); |
502 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
502 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
503 | 503 | //$pdf->SetDrawColor(190,190,200); |
504 | - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
504 | + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); |
|
505 | 505 | $pdf->SetLineStyle(array('dash'=>0)); |
506 | 506 | } |
507 | 507 | |
@@ -517,12 +517,12 @@ discard block |
||
517 | 517 | { |
518 | 518 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
519 | 519 | } |
520 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
520 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
521 | 521 | $pagenb++; |
522 | 522 | $pdf->setPage($pagenb); |
523 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
523 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
524 | 524 | } |
525 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
525 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
526 | 526 | { |
527 | 527 | if ($pagenb == 1) |
528 | 528 | { |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | { |
533 | 533 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
534 | 534 | } |
535 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
535 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
536 | 536 | // New page |
537 | 537 | $pdf->AddPage(); |
538 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
538 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
539 | 539 | $pagenb++; |
540 | 540 | } |
541 | 541 | } |
@@ -544,45 +544,45 @@ discard block |
||
544 | 544 | if ($pagenb == 1) |
545 | 545 | { |
546 | 546 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
547 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
547 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
548 | 548 | } |
549 | 549 | else |
550 | 550 | { |
551 | 551 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
552 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
552 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Affiche zone totaux |
556 | - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
556 | + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); |
|
557 | 557 | |
558 | 558 | // Pied de page |
559 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
560 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
559 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
560 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
561 | 561 | |
562 | 562 | $pdf->Close(); |
563 | 563 | |
564 | - $pdf->Output($file,'F'); |
|
564 | + $pdf->Output($file, 'F'); |
|
565 | 565 | |
566 | 566 | // Add pdfgeneration hook |
567 | 567 | $hookmanager->initHooks(array('pdfgeneration')); |
568 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
568 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
569 | 569 | global $action; |
570 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
570 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
571 | 571 | |
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
572 | + if (!empty($conf->global->MAIN_UMASK)) |
|
573 | 573 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
574 | 574 | |
575 | - return 1; // No error |
|
575 | + return 1; // No error |
|
576 | 576 | } |
577 | 577 | else |
578 | 578 | { |
579 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
579 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
580 | 580 | return 0; |
581 | 581 | } |
582 | 582 | } |
583 | 583 | else |
584 | 584 | { |
585 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
585 | + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); |
|
586 | 586 | return 0; |
587 | 587 | } |
588 | 588 | } |
@@ -602,18 +602,18 @@ discard block |
||
602 | 602 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) |
603 | 603 | { |
604 | 604 | // phpcs:enable |
605 | - global $conf,$mysoc; |
|
605 | + global $conf, $mysoc; |
|
606 | 606 | |
607 | - $sign=1; |
|
607 | + $sign = 1; |
|
608 | 608 | |
609 | 609 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
610 | 610 | |
611 | 611 | $tab2_top = $posy; |
612 | 612 | $tab2_hl = 4; |
613 | - $pdf->SetFont('','B', $default_font_size - 1); |
|
613 | + $pdf->SetFont('', 'B', $default_font_size - 1); |
|
614 | 614 | |
615 | 615 | // Tableau total |
616 | - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
616 | + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; |
|
617 | 617 | /*if ($this->page_largeur < 210) // To work with US executive format |
618 | 618 | { |
619 | 619 | $col2x-=20; |
@@ -621,34 +621,34 @@ discard block |
||
621 | 621 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
622 | 622 | else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
623 | 623 | |
624 | - $useborder=0; |
|
624 | + $useborder = 0; |
|
625 | 625 | $index = 0; |
626 | 626 | |
627 | - $totalWeighttoshow=''; |
|
628 | - $totalVolumetoshow=''; |
|
627 | + $totalWeighttoshow = ''; |
|
628 | + $totalVolumetoshow = ''; |
|
629 | 629 | |
630 | 630 | // Load dim data |
631 | - $tmparray=$object->getTotalWeightVolume(); |
|
632 | - $totalWeight=$tmparray['weight']; |
|
633 | - $totalVolume=$tmparray['volume']; |
|
634 | - $totalToShip=$tmparray['toship']; |
|
631 | + $tmparray = $object->getTotalWeightVolume(); |
|
632 | + $totalWeight = $tmparray['weight']; |
|
633 | + $totalVolume = $tmparray['volume']; |
|
634 | + $totalToShip = $tmparray['toship']; |
|
635 | 635 | |
636 | 636 | |
637 | 637 | // Set trueVolume and volume_units not currently stored into database |
638 | 638 | if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
639 | 639 | { |
640 | - $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | - $object->volume_units=$object->size_units * 3; |
|
640 | + $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
641 | + $object->volume_units = $object->size_units * 3; |
|
642 | 642 | } |
643 | 643 | |
644 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
644 | + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
648 | 648 | |
649 | - $pdf->SetFillColor(255,255,255); |
|
649 | + $pdf->SetFillColor(255, 255, 255); |
|
650 | 650 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
651 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
651 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
652 | 652 | |
653 | 653 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
654 | 654 | { |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
660 | 660 | $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
661 | 661 | |
662 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
662 | + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
663 | 663 | |
664 | 664 | $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
665 | 665 | $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | |
684 | 684 | $index++; |
685 | 685 | } |
686 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
686 | + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; |
|
687 | 687 | |
688 | - $pdf->SetTextColor(0,0,0); |
|
688 | + $pdf->SetTextColor(0, 0, 0); |
|
689 | 689 | |
690 | 690 | return ($tab2_top + ($tab2_hl * $index)); |
691 | 691 | } |
@@ -702,72 +702,72 @@ discard block |
||
702 | 702 | * @param int $hidebottom Hide bottom bar of array |
703 | 703 | * @return void |
704 | 704 | */ |
705 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
705 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
706 | 706 | { |
707 | 707 | global $conf; |
708 | 708 | |
709 | 709 | // Force to disable hidetop and hidebottom |
710 | - $hidebottom=0; |
|
711 | - if ($hidetop) $hidetop=-1; |
|
710 | + $hidebottom = 0; |
|
711 | + if ($hidetop) $hidetop = -1; |
|
712 | 712 | |
713 | 713 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
714 | 714 | |
715 | 715 | // Amount in (at tab_top - 1) |
716 | - $pdf->SetTextColor(0,0,0); |
|
717 | - $pdf->SetFont('','',$default_font_size - 2); |
|
716 | + $pdf->SetTextColor(0, 0, 0); |
|
717 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
718 | 718 | |
719 | 719 | // Output Rect |
720 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
720 | + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
721 | 721 | |
722 | - $pdf->SetDrawColor(128,128,128); |
|
723 | - $pdf->SetFont('','', $default_font_size - 1); |
|
722 | + $pdf->SetDrawColor(128, 128, 128); |
|
723 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
724 | 724 | |
725 | 725 | if (empty($hidetop)) |
726 | 726 | { |
727 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
727 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); |
|
728 | 728 | |
729 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
729 | + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); |
|
730 | 730 | $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
731 | 731 | } |
732 | 732 | |
733 | - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
733 | + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); |
|
734 | 734 | if (empty($hidetop)) |
735 | 735 | { |
736 | - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
737 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
736 | + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); |
|
737 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) |
741 | 741 | { |
742 | - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); |
|
742 | + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); |
|
743 | 743 | if (empty($hidetop)) |
744 | 744 | { |
745 | - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
746 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
745 | + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); |
|
746 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); |
|
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
750 | + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); |
|
751 | 751 | if (empty($hidetop)) |
752 | 752 | { |
753 | - $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
754 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"),'','C'); |
|
753 | + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); |
|
754 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C'); |
|
755 | 755 | } |
756 | 756 | |
757 | - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
757 | + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { |
|
758 | 758 | |
759 | - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
759 | + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); |
|
760 | 760 | if (empty($hidetop)) |
761 | 761 | { |
762 | - $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
763 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
762 | + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); |
|
763 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); |
|
764 | 764 | } |
765 | 765 | |
766 | - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
766 | + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); |
|
767 | 767 | if (empty($hidetop)) |
768 | 768 | { |
769 | - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
770 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
769 | + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); |
|
770 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | } |
@@ -783,73 +783,73 @@ discard block |
||
783 | 783 | */ |
784 | 784 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
785 | 785 | { |
786 | - global $conf,$langs,$mysoc; |
|
786 | + global $conf, $langs, $mysoc; |
|
787 | 787 | |
788 | 788 | $langs->load("orders"); |
789 | 789 | |
790 | 790 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
791 | 791 | |
792 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
792 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
793 | 793 | |
794 | 794 | // Show Draft Watermark |
795 | - if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) |
|
795 | + if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) |
|
796 | 796 | { |
797 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->RECEPTION_DRAFT_WATERMARK); |
|
797 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | //Prepare la suite |
801 | - $pdf->SetTextColor(0,0,60); |
|
802 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
801 | + $pdf->SetTextColor(0, 0, 60); |
|
802 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
803 | 803 | |
804 | 804 | $w = 110; |
805 | 805 | |
806 | - $posy=$this->marge_haute; |
|
807 | - $posx=$this->page_largeur-$this->marge_droite-$w; |
|
806 | + $posy = $this->marge_haute; |
|
807 | + $posx = $this->page_largeur - $this->marge_droite - $w; |
|
808 | 808 | |
809 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
809 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
810 | 810 | |
811 | 811 | // Logo |
812 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
812 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
813 | 813 | if ($this->emetteur->logo) |
814 | 814 | { |
815 | 815 | if (is_readable($logo)) |
816 | 816 | { |
817 | - $height=pdf_getHeightForLogo($logo); |
|
818 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
817 | + $height = pdf_getHeightForLogo($logo); |
|
818 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
819 | 819 | } |
820 | 820 | else |
821 | 821 | { |
822 | - $pdf->SetTextColor(200,0,0); |
|
823 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
824 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
822 | + $pdf->SetTextColor(200, 0, 0); |
|
823 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
824 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
825 | 825 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
826 | 826 | } |
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - $text=$this->emetteur->name; |
|
830 | + $text = $this->emetteur->name; |
|
831 | 831 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
832 | 832 | } |
833 | 833 | |
834 | 834 | // Show barcode |
835 | - if (! empty($conf->barcode->enabled)) |
|
835 | + if (!empty($conf->barcode->enabled)) |
|
836 | 836 | { |
837 | - $posx=105; |
|
837 | + $posx = 105; |
|
838 | 838 | } |
839 | 839 | else |
840 | 840 | { |
841 | - $posx=$this->marge_gauche+3; |
|
841 | + $posx = $this->marge_gauche + 3; |
|
842 | 842 | } |
843 | 843 | //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
844 | - if (! empty($conf->barcode->enabled)) |
|
844 | + if (!empty($conf->barcode->enabled)) |
|
845 | 845 | { |
846 | 846 | // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
847 | 847 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
848 | 848 | //$pdf->Image($logo,10, 5, 0, 24); |
849 | 849 | } |
850 | 850 | |
851 | - $pdf->SetDrawColor(128,128,128); |
|
852 | - if (! empty($conf->barcode->enabled)) |
|
851 | + $pdf->SetDrawColor(128, 128, 128); |
|
852 | + if (!empty($conf->barcode->enabled)) |
|
853 | 853 | { |
854 | 854 | // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref |
855 | 855 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
@@ -857,115 +857,115 @@ discard block |
||
857 | 857 | } |
858 | 858 | |
859 | 859 | |
860 | - $posx=$this->page_largeur - $w - $this->marge_droite; |
|
861 | - $posy=$this->marge_haute; |
|
860 | + $posx = $this->page_largeur - $w - $this->marge_droite; |
|
861 | + $posy = $this->marge_haute; |
|
862 | 862 | |
863 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
864 | - $pdf->SetXY($posx,$posy); |
|
865 | - $pdf->SetTextColor(0,0,60); |
|
866 | - $title=$outputlangs->transnoentities("ReceptionSheet"); |
|
863 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
864 | + $pdf->SetXY($posx, $posy); |
|
865 | + $pdf->SetTextColor(0, 0, 60); |
|
866 | + $title = $outputlangs->transnoentities("ReceptionSheet"); |
|
867 | 867 | $pdf->MultiCell($w, 4, $title, '', 'R'); |
868 | 868 | |
869 | - $pdf->SetFont('','', $default_font_size + 1); |
|
869 | + $pdf->SetFont('', '', $default_font_size + 1); |
|
870 | 870 | |
871 | - $posy+=5; |
|
871 | + $posy += 5; |
|
872 | 872 | |
873 | - $pdf->SetXY($posx,$posy); |
|
874 | - $pdf->SetTextColor(0,0,60); |
|
875 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); |
|
873 | + $pdf->SetXY($posx, $posy); |
|
874 | + $pdf->SetTextColor(0, 0, 60); |
|
875 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R'); |
|
876 | 876 | |
877 | 877 | // Date planned delivery |
878 | - if (! empty($object->date_delivery)) |
|
878 | + if (!empty($object->date_delivery)) |
|
879 | 879 | { |
880 | - $posy+=4; |
|
881 | - $pdf->SetXY($posx,$posy); |
|
882 | - $pdf->SetTextColor(0,0,60); |
|
883 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
880 | + $posy += 4; |
|
881 | + $pdf->SetXY($posx, $posy); |
|
882 | + $pdf->SetTextColor(0, 0, 60); |
|
883 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); |
|
884 | 884 | } |
885 | 885 | |
886 | - if (! empty($object->thirdparty->code_fournisseur)) |
|
886 | + if (!empty($object->thirdparty->code_fournisseur)) |
|
887 | 887 | { |
888 | - $posy+=4; |
|
889 | - $pdf->SetXY($posx,$posy); |
|
890 | - $pdf->SetTextColor(0,0,60); |
|
891 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
888 | + $posy += 4; |
|
889 | + $pdf->SetXY($posx, $posy); |
|
890 | + $pdf->SetTextColor(0, 0, 60); |
|
891 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | |
895 | - $pdf->SetFont('','', $default_font_size + 3); |
|
896 | - $Yoff=25; |
|
895 | + $pdf->SetFont('', '', $default_font_size + 3); |
|
896 | + $Yoff = 25; |
|
897 | 897 | |
898 | 898 | // Add list of linked orders |
899 | - $origin = $object->origin; |
|
900 | - $origin_id = $object->origin_id; |
|
899 | + $origin = $object->origin; |
|
900 | + $origin_id = $object->origin_id; |
|
901 | 901 | |
902 | 902 | // TODO move to external function |
903 | - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
903 | + if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
904 | 904 | { |
905 | 905 | $outputlangs->load('orders'); |
906 | 906 | |
907 | 907 | $classname = 'CommandeFournisseur'; |
908 | 908 | $linkedobject = new $classname($this->db); |
909 | - $result=$linkedobject->fetch($origin_id); |
|
909 | + $result = $linkedobject->fetch($origin_id); |
|
910 | 910 | if ($result >= 0) |
911 | 911 | { |
912 | 912 | //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
913 | 913 | |
914 | - $pdf->SetFont('','', $default_font_size - 2); |
|
915 | - $text=$linkedobject->ref; |
|
916 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
917 | - $Yoff = $Yoff+8; |
|
918 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
919 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | - $Yoff = $Yoff+3; |
|
921 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
922 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
914 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
915 | + $text = $linkedobject->ref; |
|
916 | + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; |
|
917 | + $Yoff = $Yoff + 8; |
|
918 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
|
919 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
920 | + $Yoff = $Yoff + 3; |
|
921 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
|
922 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); |
|
923 | 923 | } |
924 | 924 | } |
925 | 925 | |
926 | 926 | if ($showaddress) |
927 | 927 | { |
928 | 928 | // Sender properties |
929 | - $carac_emetteur=''; |
|
929 | + $carac_emetteur = ''; |
|
930 | 930 | // Add internal contact of origin element if defined |
931 | - $arrayidcontact=array(); |
|
932 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
931 | + $arrayidcontact = array(); |
|
932 | + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); |
|
933 | + if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING'); |
|
934 | 934 | if (count($arrayidcontact) > 0) |
935 | 935 | { |
936 | 936 | $object->fetch_user(reset($arrayidcontact)); |
937 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
937 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
941 | 941 | |
942 | 942 | // Show sender |
943 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | - $posx=$this->marge_gauche; |
|
945 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
943 | + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
944 | + $posx = $this->marge_gauche; |
|
945 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
946 | 946 | |
947 | - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
947 | + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
948 | + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
949 | 949 | |
950 | 950 | // Show sender frame |
951 | - $pdf->SetTextColor(0,0,0); |
|
952 | - $pdf->SetFont('','', $default_font_size - 2); |
|
953 | - $pdf->SetXY($posx,$posy-5); |
|
954 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | - $pdf->SetXY($posx,$posy); |
|
956 | - $pdf->SetFillColor(230,230,230); |
|
951 | + $pdf->SetTextColor(0, 0, 0); |
|
952 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
953 | + $pdf->SetXY($posx, $posy - 5); |
|
954 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
955 | + $pdf->SetXY($posx, $posy); |
|
956 | + $pdf->SetFillColor(230, 230, 230); |
|
957 | 957 | $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
958 | - $pdf->SetTextColor(0,0,60); |
|
959 | - $pdf->SetFillColor(255,255,255); |
|
958 | + $pdf->SetTextColor(0, 0, 60); |
|
959 | + $pdf->SetFillColor(255, 255, 255); |
|
960 | 960 | |
961 | 961 | // If RECEPTION contact defined, we use it |
962 | - $usecontact=false; |
|
963 | - $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
962 | + $usecontact = false; |
|
963 | + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); |
|
964 | 964 | |
965 | 965 | if (count($arrayidcontact) > 0) |
966 | 966 | { |
967 | - $usecontact=true; |
|
968 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
967 | + $usecontact = true; |
|
968 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | //Recipient name |
@@ -976,51 +976,51 @@ discard block |
||
976 | 976 | $thirdparty = $object->thirdparty; |
977 | 977 | } |
978 | 978 | |
979 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
979 | + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
980 | 980 | |
981 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
981 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); |
|
982 | 982 | |
983 | 983 | // Show recipient name |
984 | - $pdf->SetXY($posx+2,$posy+3); |
|
985 | - $pdf->SetFont('','B', $default_font_size); |
|
986 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); |
|
984 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
985 | + $pdf->SetFont('', 'B', $default_font_size); |
|
986 | + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L'); |
|
987 | 987 | |
988 | 988 | $posy = $pdf->getY(); |
989 | 989 | |
990 | 990 | // Show recipient information |
991 | - $pdf->SetFont('','', $default_font_size - 1); |
|
992 | - $pdf->SetXY($posx+2,$posy); |
|
993 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); |
|
991 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
992 | + $pdf->SetXY($posx + 2, $posy); |
|
993 | + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L'); |
|
994 | 994 | |
995 | 995 | // Show recipient |
996 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
998 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
996 | + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
997 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
998 | + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
999 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1000 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
1001 | 1001 | |
1002 | 1002 | // Show recipient frame |
1003 | - $pdf->SetTextColor(0,0,0); |
|
1004 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1005 | - $pdf->SetXY($posx+2,$posy-5); |
|
1003 | + $pdf->SetTextColor(0, 0, 0); |
|
1004 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1005 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
1006 | 1006 | $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
1007 | 1007 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
1008 | 1008 | |
1009 | 1009 | |
1010 | 1010 | |
1011 | 1011 | // Show sender name |
1012 | - $pdf->SetXY($posx+2,$posy+3); |
|
1013 | - $pdf->SetFont('','B',$default_font_size); |
|
1012 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1013 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1014 | 1014 | $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
1015 | - $posy=$pdf->getY(); |
|
1015 | + $posy = $pdf->getY(); |
|
1016 | 1016 | |
1017 | 1017 | // Show sender information |
1018 | - $pdf->SetXY($posx+2,$posy); |
|
1019 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1018 | + $pdf->SetXY($posx + 2, $posy); |
|
1019 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1020 | 1020 | $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); |
1021 | 1021 | } |
1022 | 1022 | |
1023 | - $pdf->SetTextColor(0,0,0); |
|
1023 | + $pdf->SetTextColor(0, 0, 0); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1032,10 +1032,10 @@ discard block |
||
1032 | 1032 | * @param int $hidefreetext 1=Hide free text |
1033 | 1033 | * @return int Return height of bottom margin including footer text |
1034 | 1034 | */ |
1035 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1035 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1036 | 1036 | { |
1037 | 1037 | global $conf; |
1038 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | - return pdf_pagefoot($pdf,$outputlangs,'RECEPTION_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1038 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1039 | + return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1040 | 1040 | } |
1041 | 1041 | } |
@@ -62,7 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | // Get source company |
64 | 64 | $this->emetteur=$mysoc; |
65 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
65 | + if (! $this->emetteur->country_code) { |
|
66 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
67 | + } |
|
68 | + // By default if not defined |
|
66 | 69 | |
67 | 70 | // Define position of columns |
68 | 71 | $this->posxdesc=$this->marge_gauche+1; |
@@ -82,9 +85,11 @@ discard block |
||
82 | 85 | |
83 | 86 | $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
84 | 87 | |
85 | - if ($this->page_largeur < 210) // To work with US executive format |
|
88 | + if ($this->page_largeur < 210) { |
|
89 | + // To work with US executive format |
|
86 | 90 | { |
87 | 91 | $this->posxweightvol-=20; |
92 | + } |
|
88 | 93 | $this->posxpicture-=20; |
89 | 94 | $this->posxqtyordered-=20; |
90 | 95 | $this->posxqtytoship-=20; |
@@ -117,9 +122,13 @@ discard block |
||
117 | 122 | |
118 | 123 | $object->fetch_thirdparty(); |
119 | 124 | |
120 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
125 | + if (! is_object($outputlangs)) { |
|
126 | + $outputlangs=$langs; |
|
127 | + } |
|
121 | 128 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
122 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
129 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
130 | + $outputlangs->charset_output='ISO-8859-1'; |
|
131 | + } |
|
123 | 132 | |
124 | 133 | $outputlangs->load("main"); |
125 | 134 | $outputlangs->load("dict"); |
@@ -141,7 +150,9 @@ discard block |
||
141 | 150 | |
142 | 151 | for ($i = 0 ; $i < $nblignes ; $i++) |
143 | 152 | { |
144 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
153 | + if (empty($object->lines[$i]->fk_product)) { |
|
154 | + continue; |
|
155 | + } |
|
145 | 156 | |
146 | 157 | $objphoto = new Product($this->db); |
147 | 158 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -153,18 +164,18 @@ discard block |
||
153 | 164 | |
154 | 165 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
155 | 166 | { |
156 | - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
167 | + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { |
|
168 | + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
157 | 169 | { |
158 | 170 | if ($obj['photo_vignette']) |
159 | 171 | { |
160 | 172 | $filename= $obj['photo_vignette']; |
161 | - } |
|
162 | - else |
|
173 | + } |
|
174 | + } else |
|
163 | 175 | { |
164 | 176 | $filename=$obj['photo']; |
165 | 177 | } |
166 | - } |
|
167 | - else |
|
178 | + } else |
|
168 | 179 | { |
169 | 180 | $filename=$obj['photo']; |
170 | 181 | } |
@@ -173,11 +184,15 @@ discard block |
||
173 | 184 | break; |
174 | 185 | } |
175 | 186 | |
176 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
187 | + if ($realpath) { |
|
188 | + $realpatharray[$i]=$realpath; |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | } |
179 | 192 | |
180 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
|
193 | + if (count($realpatharray) == 0) { |
|
194 | + $this->posxpicture=$this->posxweightvol; |
|
195 | + } |
|
181 | 196 | |
182 | 197 | if ($conf->reception->dir_output) |
183 | 198 | { |
@@ -186,8 +201,7 @@ discard block |
||
186 | 201 | { |
187 | 202 | $dir = $conf->reception->dir_output; |
188 | 203 | $file = $dir . "/SPECIMEN.pdf"; |
189 | - } |
|
190 | - else |
|
204 | + } else |
|
191 | 205 | { |
192 | 206 | $rcpref = dol_sanitizeFileName($object->ref); |
193 | 207 | $dir = $conf->reception->dir_output."/" . $rcpref; |
@@ -243,20 +257,26 @@ discard block |
||
243 | 257 | $pagenb=0; |
244 | 258 | $pdf->SetDrawColor(128,128,128); |
245 | 259 | |
246 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
260 | + if (method_exists($pdf,'AliasNbPages')) { |
|
261 | + $pdf->AliasNbPages(); |
|
262 | + } |
|
247 | 263 | |
248 | 264 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
249 | 265 | $pdf->SetSubject($outputlangs->transnoentities("Reception")); |
250 | 266 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
251 | 267 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
252 | 268 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); |
253 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
269 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
270 | + $pdf->SetCompression(false); |
|
271 | + } |
|
254 | 272 | |
255 | 273 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
256 | 274 | |
257 | 275 | // New page |
258 | 276 | $pdf->AddPage(); |
259 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
277 | + if (! empty($tplidx)) { |
|
278 | + $pdf->useTemplate($tplidx); |
|
279 | + } |
|
260 | 280 | $pagenb++; |
261 | 281 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
262 | 282 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -313,7 +333,9 @@ discard block |
||
313 | 333 | // Get code using getLabelFromKey |
314 | 334 | $code=$outputlangs->getLabelFromKey($this->db,$object->shipment_method_id,'c_shipment_mode','rowid','code'); |
315 | 335 | $label=''; |
316 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
336 | + if ($object->tracking_url != $object->tracking_number) { |
|
337 | + $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
338 | + } |
|
317 | 339 | $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); |
318 | 340 | //var_dump($object->tracking_url != $object->tracking_number);exit; |
319 | 341 | if ($object->tracking_url != $object->tracking_number) |
@@ -345,8 +367,7 @@ discard block |
||
345 | 367 | |
346 | 368 | $tab_height = $tab_height - $height_note; |
347 | 369 | $tab_top = $nexY+6; |
348 | - } |
|
349 | - else |
|
370 | + } else |
|
350 | 371 | { |
351 | 372 | $height_note=0; |
352 | 373 | } |
@@ -365,7 +386,9 @@ discard block |
||
365 | 386 | |
366 | 387 | // Define size of image if we need it |
367 | 388 | $imglinesize=array(); |
368 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
389 | + if (! empty($realpatharray[$i])) { |
|
390 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
391 | + } |
|
369 | 392 | |
370 | 393 | $pdf->setTopMargin($tab_top_newpage); |
371 | 394 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -376,11 +399,17 @@ discard block |
||
376 | 399 | $posYAfterDescription=0; |
377 | 400 | |
378 | 401 | // We start with Photo of product line |
379 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
402 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
403 | + // If photo too high, we moved completely on new page |
|
380 | 404 | { |
381 | 405 | $pdf->AddPage('','',true); |
382 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
383 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
406 | + } |
|
407 | + if (! empty($tplidx)) { |
|
408 | + $pdf->useTemplate($tplidx); |
|
409 | + } |
|
410 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
411 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
412 | + } |
|
384 | 413 | $pdf->setPage($pageposbefore+1); |
385 | 414 | |
386 | 415 | $curY = $tab_top_newpage; |
@@ -402,9 +431,11 @@ discard block |
||
402 | 431 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
403 | 432 | |
404 | 433 | $pageposafter=$pdf->getPage(); |
405 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
434 | + if ($pageposafter > $pageposbefore) { |
|
435 | + // There is a pagebreak |
|
406 | 436 | { |
407 | 437 | $pdf->rollbackTransaction(true); |
438 | + } |
|
408 | 439 | $pageposafter=$pageposbefore; |
409 | 440 | //print $pageposafter.'-'.$pageposbefore;exit; |
410 | 441 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -414,23 +445,27 @@ discard block |
||
414 | 445 | $pageposafter=$pdf->getPage(); |
415 | 446 | $posyafter=$pdf->GetY(); |
416 | 447 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
448 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
449 | + // There is no space left for total+free text |
|
418 | 450 | { |
419 | 451 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
420 | 452 | { |
421 | 453 | $pdf->AddPage('','',true); |
422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
423 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
454 | + } |
|
455 | + if (! empty($tplidx)) { |
|
456 | + $pdf->useTemplate($tplidx); |
|
457 | + } |
|
458 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
459 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
460 | + } |
|
424 | 461 | $pdf->setPage($pageposafter+1); |
425 | 462 | } |
426 | - } |
|
427 | - else |
|
463 | + } else |
|
428 | 464 | { |
429 | 465 | // We found a page break |
430 | 466 | $showpricebeforepagebreak=0; |
431 | 467 | } |
432 | - } |
|
433 | - else // No pagebreak |
|
468 | + } else // No pagebreak |
|
434 | 469 | { |
435 | 470 | $pdf->commitTransaction(); |
436 | 471 | } |
@@ -493,7 +528,9 @@ discard block |
||
493 | 528 | } |
494 | 529 | |
495 | 530 | $nexY+=3; |
496 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
531 | + if ($weighttxt && $voltxt) { |
|
532 | + $nexY+=2; |
|
533 | + } |
|
497 | 534 | |
498 | 535 | // Add line |
499 | 536 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -512,8 +549,7 @@ discard block |
||
512 | 549 | if ($pagenb == 1) |
513 | 550 | { |
514 | 551 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
515 | - } |
|
516 | - else |
|
552 | + } else |
|
517 | 553 | { |
518 | 554 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
519 | 555 | } |
@@ -527,15 +563,16 @@ discard block |
||
527 | 563 | if ($pagenb == 1) |
528 | 564 | { |
529 | 565 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
530 | - } |
|
531 | - else |
|
566 | + } else |
|
532 | 567 | { |
533 | 568 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
534 | 569 | } |
535 | 570 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
536 | 571 | // New page |
537 | 572 | $pdf->AddPage(); |
538 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
573 | + if (! empty($tplidx)) { |
|
574 | + $pdf->useTemplate($tplidx); |
|
575 | + } |
|
539 | 576 | $pagenb++; |
540 | 577 | } |
541 | 578 | } |
@@ -545,8 +582,7 @@ discard block |
||
545 | 582 | { |
546 | 583 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
547 | 584 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
548 | - } |
|
549 | - else |
|
585 | + } else |
|
550 | 586 | { |
551 | 587 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
552 | 588 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -557,7 +593,9 @@ discard block |
||
557 | 593 | |
558 | 594 | // Pied de page |
559 | 595 | $this->_pagefoot($pdf,$object,$outputlangs); |
560 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
596 | + if (method_exists($pdf,'AliasNbPages')) { |
|
597 | + $pdf->AliasNbPages(); |
|
598 | + } |
|
561 | 599 | |
562 | 600 | $pdf->Close(); |
563 | 601 | |
@@ -569,18 +607,17 @@ discard block |
||
569 | 607 | global $action; |
570 | 608 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
571 | 609 | |
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
610 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
611 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
612 | + } |
|
574 | 613 | |
575 | 614 | return 1; // No error |
576 | - } |
|
577 | - else |
|
615 | + } else |
|
578 | 616 | { |
579 | 617 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
580 | 618 | return 0; |
581 | 619 | } |
582 | - } |
|
583 | - else |
|
620 | + } else |
|
584 | 621 | { |
585 | 622 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
586 | 623 | return 0; |
@@ -618,8 +655,11 @@ discard block |
||
618 | 655 | { |
619 | 656 | $col2x-=20; |
620 | 657 | }*/ |
621 | - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
622 | - else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
658 | + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { |
|
659 | + $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
660 | + } else { |
|
661 | + $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
662 | + } |
|
623 | 663 | |
624 | 664 | $useborder=0; |
625 | 665 | $index = 0; |
@@ -641,10 +681,18 @@ discard block |
||
641 | 681 | $object->volume_units=$object->size_units * 3; |
642 | 682 | } |
643 | 683 | |
644 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
645 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
646 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
647 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
684 | + if ($totalWeight!='') { |
|
685 | + $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
686 | + } |
|
687 | + if ($totalVolume!='') { |
|
688 | + $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
689 | + } |
|
690 | + if ($object->trueWeight) { |
|
691 | + $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
692 | + } |
|
693 | + if ($object->trueVolume) { |
|
694 | + $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
695 | + } |
|
648 | 696 | |
649 | 697 | $pdf->SetFillColor(255,255,255); |
650 | 698 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -683,7 +731,9 @@ discard block |
||
683 | 731 | |
684 | 732 | $index++; |
685 | 733 | } |
686 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
734 | + if (! $totalWeighttoshow && ! $totalVolumetoshow) { |
|
735 | + $index++; |
|
736 | + } |
|
687 | 737 | |
688 | 738 | $pdf->SetTextColor(0,0,0); |
689 | 739 | |
@@ -708,7 +758,9 @@ discard block |
||
708 | 758 | |
709 | 759 | // Force to disable hidetop and hidebottom |
710 | 760 | $hidebottom=0; |
711 | - if ($hidetop) $hidetop=-1; |
|
761 | + if ($hidetop) { |
|
762 | + $hidetop=-1; |
|
763 | + } |
|
712 | 764 | |
713 | 765 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
714 | 766 | |
@@ -816,16 +868,14 @@ discard block |
||
816 | 868 | { |
817 | 869 | $height=pdf_getHeightForLogo($logo); |
818 | 870 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
819 | - } |
|
820 | - else |
|
871 | + } else |
|
821 | 872 | { |
822 | 873 | $pdf->SetTextColor(200,0,0); |
823 | 874 | $pdf->SetFont('','B', $default_font_size - 2); |
824 | 875 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
825 | 876 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
826 | 877 | } |
827 | - } |
|
828 | - else |
|
878 | + } else |
|
829 | 879 | { |
830 | 880 | $text=$this->emetteur->name; |
831 | 881 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -835,8 +885,7 @@ discard block |
||
835 | 885 | if (! empty($conf->barcode->enabled)) |
836 | 886 | { |
837 | 887 | $posx=105; |
838 | - } |
|
839 | - else |
|
888 | + } else |
|
840 | 889 | { |
841 | 890 | $posx=$this->marge_gauche+3; |
842 | 891 | } |
@@ -900,9 +949,11 @@ discard block |
||
900 | 949 | $origin_id = $object->origin_id; |
901 | 950 | |
902 | 951 | // TODO move to external function |
903 | - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' |
|
952 | + if (! empty($conf->fournisseur->enabled)) { |
|
953 | + // commonly $origin='commande' |
|
904 | 954 | { |
905 | 955 | $outputlangs->load('orders'); |
956 | + } |
|
906 | 957 | |
907 | 958 | $classname = 'CommandeFournisseur'; |
908 | 959 | $linkedobject = new $classname($this->db); |
@@ -913,7 +964,9 @@ discard block |
||
913 | 964 | |
914 | 965 | $pdf->SetFont('','', $default_font_size - 2); |
915 | 966 | $text=$linkedobject->ref; |
916 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
967 | + if ($linkedobject->ref_client) { |
|
968 | + $text.=' ('.$linkedobject->ref_client.')'; |
|
969 | + } |
|
917 | 970 | $Yoff = $Yoff+8; |
918 | 971 | $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
919 | 972 | $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
@@ -929,8 +982,12 @@ discard block |
||
929 | 982 | $carac_emetteur=''; |
930 | 983 | // Add internal contact of origin element if defined |
931 | 984 | $arrayidcontact=array(); |
932 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
933 | - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
985 | + if (! empty($origin) && is_object($object->$origin)) { |
|
986 | + $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
987 | + } |
|
988 | + if(empty($arrayidcontact)) { |
|
989 | + $arrayidcontact=$object->$origin->getIdContact('internal','SHIPPING'); |
|
990 | + } |
|
934 | 991 | if (count($arrayidcontact) > 0) |
935 | 992 | { |
936 | 993 | $object->fetch_user(reset($arrayidcontact)); |
@@ -942,7 +999,9 @@ discard block |
||
942 | 999 | // Show sender |
943 | 1000 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
944 | 1001 | $posx=$this->marge_gauche; |
945 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1002 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1003 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1004 | + } |
|
946 | 1005 | |
947 | 1006 | $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
948 | 1007 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
@@ -994,10 +1053,15 @@ discard block |
||
994 | 1053 | |
995 | 1054 | // Show recipient |
996 | 1055 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
997 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1056 | + if ($this->page_largeur < 210) { |
|
1057 | + $widthrecbox=84; |
|
1058 | + } |
|
1059 | + // To work with US executive format |
|
998 | 1060 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
999 | 1061 | $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
1000 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1062 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1063 | + $posx=$this->marge_gauche; |
|
1064 | + } |
|
1001 | 1065 | |
1002 | 1066 | // Show recipient frame |
1003 | 1067 | $pdf->SetTextColor(0,0,0); |
@@ -35,488 +35,488 @@ |
||
35 | 35 | */ |
36 | 36 | class doc_generic_reception_odt extends ModelePdfReception |
37 | 37 | { |
38 | - var $emetteur; // Objet societe qui emet |
|
39 | - |
|
40 | - var $phpmin = array(5,2,0); // Minimum version of PHP required by module |
|
41 | - var $version = 'dolibarr'; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Constructor |
|
46 | - * |
|
47 | - * @param DoliDB $db Database handler |
|
48 | - */ |
|
49 | - function __construct($db) |
|
50 | - { |
|
51 | - global $conf,$langs,$mysoc; |
|
52 | - |
|
53 | - $langs->load("main"); |
|
54 | - $langs->load("companies"); |
|
55 | - |
|
56 | - $this->db = $db; |
|
57 | - $this->name = "ODT templates"; |
|
58 | - $this->description = $langs->trans("DocumentModelOdt"); |
|
59 | - $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
60 | - |
|
61 | - // Dimension page pour format A4 |
|
62 | - $this->type = 'odt'; |
|
63 | - $this->page_largeur = 0; |
|
64 | - $this->page_hauteur = 0; |
|
65 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | - $this->marge_gauche=0; |
|
67 | - $this->marge_droite=0; |
|
68 | - $this->marge_haute=0; |
|
69 | - $this->marge_basse=0; |
|
70 | - |
|
71 | - $this->option_logo = 1; // Affiche logo |
|
72 | - $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | - $this->option_modereg = 0; // Affiche mode reglement |
|
74 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | - $this->option_credit_note = 0; // Support credit notes |
|
79 | - $this->option_freetext = 1; // Support add of a personalised text |
|
80 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | - |
|
82 | - // Recupere emetteur |
|
83 | - $this->emetteur=$mysoc; |
|
84 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Return description of a module |
|
90 | - * |
|
91 | - * @param Translate $langs Lang object to use for output |
|
92 | - * @return string Description |
|
93 | - */ |
|
94 | - function info($langs) |
|
95 | - { |
|
96 | - global $conf,$langs; |
|
97 | - |
|
98 | - $langs->load("companies"); |
|
99 | - $langs->load("errors"); |
|
100 | - |
|
101 | - $form = new Form($this->db); |
|
102 | - |
|
103 | - $texte = $this->description.".<br>\n"; |
|
104 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | - $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
109 | - |
|
110 | - // List of directories area |
|
111 | - $texte.= '<tr><td>'; |
|
112 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
113 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | - $listoffiles=array(); |
|
115 | - foreach($listofdir as $key=>$tmpdir) |
|
116 | - { |
|
117 | - $tmpdir=trim($tmpdir); |
|
118 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
119 | - if (! $tmpdir) { |
|
120 | - unset($listofdir[$key]); continue; |
|
121 | - } |
|
122 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | - else |
|
124 | - { |
|
125 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
126 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | - } |
|
128 | - } |
|
129 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
130 | - // Add list of substitution keys |
|
131 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | - |
|
134 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
135 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | - $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | - $texte.= '</textarea>'; |
|
139 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | - $texte.= '<br></div></div>'; |
|
142 | - |
|
143 | - // Scan directories |
|
144 | - $nbofiles=count($listoffiles); |
|
145 | - if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
146 | - { |
|
147 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | - //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | - $texte.=count($listoffiles); |
|
150 | - //$texte.=$nbofiles?'</a>':''; |
|
151 | - $texte.='</b>'; |
|
152 | - } |
|
153 | - if ($nbofiles) |
|
154 | - { |
|
155 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | - foreach($listoffiles as $file) |
|
157 | - { |
|
38 | + var $emetteur; // Objet societe qui emet |
|
39 | + |
|
40 | + var $phpmin = array(5,2,0); // Minimum version of PHP required by module |
|
41 | + var $version = 'dolibarr'; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Constructor |
|
46 | + * |
|
47 | + * @param DoliDB $db Database handler |
|
48 | + */ |
|
49 | + function __construct($db) |
|
50 | + { |
|
51 | + global $conf,$langs,$mysoc; |
|
52 | + |
|
53 | + $langs->load("main"); |
|
54 | + $langs->load("companies"); |
|
55 | + |
|
56 | + $this->db = $db; |
|
57 | + $this->name = "ODT templates"; |
|
58 | + $this->description = $langs->trans("DocumentModelOdt"); |
|
59 | + $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
60 | + |
|
61 | + // Dimension page pour format A4 |
|
62 | + $this->type = 'odt'; |
|
63 | + $this->page_largeur = 0; |
|
64 | + $this->page_hauteur = 0; |
|
65 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | + $this->marge_gauche=0; |
|
67 | + $this->marge_droite=0; |
|
68 | + $this->marge_haute=0; |
|
69 | + $this->marge_basse=0; |
|
70 | + |
|
71 | + $this->option_logo = 1; // Affiche logo |
|
72 | + $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | + $this->option_modereg = 0; // Affiche mode reglement |
|
74 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | + $this->option_credit_note = 0; // Support credit notes |
|
79 | + $this->option_freetext = 1; // Support add of a personalised text |
|
80 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | + |
|
82 | + // Recupere emetteur |
|
83 | + $this->emetteur=$mysoc; |
|
84 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Return description of a module |
|
90 | + * |
|
91 | + * @param Translate $langs Lang object to use for output |
|
92 | + * @return string Description |
|
93 | + */ |
|
94 | + function info($langs) |
|
95 | + { |
|
96 | + global $conf,$langs; |
|
97 | + |
|
98 | + $langs->load("companies"); |
|
99 | + $langs->load("errors"); |
|
100 | + |
|
101 | + $form = new Form($this->db); |
|
102 | + |
|
103 | + $texte = $this->description.".<br>\n"; |
|
104 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | + $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
109 | + |
|
110 | + // List of directories area |
|
111 | + $texte.= '<tr><td>'; |
|
112 | + $texttitle=$langs->trans("ListOfDirectories"); |
|
113 | + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | + $listoffiles=array(); |
|
115 | + foreach($listofdir as $key=>$tmpdir) |
|
116 | + { |
|
117 | + $tmpdir=trim($tmpdir); |
|
118 | + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
119 | + if (! $tmpdir) { |
|
120 | + unset($listofdir[$key]); continue; |
|
121 | + } |
|
122 | + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | + else |
|
124 | + { |
|
125 | + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
126 | + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | + } |
|
128 | + } |
|
129 | + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
130 | + // Add list of substitution keys |
|
131 | + $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | + |
|
134 | + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
135 | + $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | + $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | + $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | + $texte.= '</textarea>'; |
|
139 | + $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | + $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | + $texte.= '<br></div></div>'; |
|
142 | + |
|
143 | + // Scan directories |
|
144 | + $nbofiles=count($listoffiles); |
|
145 | + if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
146 | + { |
|
147 | + $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | + //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | + $texte.=count($listoffiles); |
|
150 | + //$texte.=$nbofiles?'</a>':''; |
|
151 | + $texte.='</b>'; |
|
152 | + } |
|
153 | + if ($nbofiles) |
|
154 | + { |
|
155 | + $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | + foreach($listoffiles as $file) |
|
157 | + { |
|
158 | 158 | $texte.=$file['name'].'<br>'; |
159 | - } |
|
160 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
161 | - } |
|
162 | - |
|
163 | - $texte.= '</td>'; |
|
164 | - |
|
165 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | - $texte.= '</td>'; |
|
168 | - $texte.= '</tr>'; |
|
169 | - |
|
170 | - $texte.= '</table>'; |
|
171 | - $texte.= '</form>'; |
|
172 | - |
|
173 | - return $texte; |
|
174 | - } |
|
175 | - |
|
176 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
177 | - /** |
|
178 | - * Function to build a document on disk using the generic odt module. |
|
179 | - * |
|
180 | - * @param Reception $object Object source to build document |
|
181 | - * @param Translate $outputlangs Lang output object |
|
182 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
183 | - * @param int $hidedetails Do not show line details |
|
184 | - * @param int $hidedesc Do not show desc |
|
185 | - * @param int $hideref Do not show ref |
|
186 | - * @return int 1 if OK, <=0 if KO |
|
187 | - */ |
|
188 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
189 | - { |
|
190 | - // phpcs:enable |
|
191 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | - |
|
193 | - if (empty($srctemplatepath)) |
|
194 | - { |
|
195 | - dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
196 | - return -1; |
|
197 | - } |
|
198 | - |
|
199 | - // Add odtgeneration hook |
|
200 | - if (! is_object($hookmanager)) |
|
201 | - { |
|
202 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
203 | - $hookmanager=new HookManager($this->db); |
|
204 | - } |
|
205 | - $hookmanager->initHooks(array('odtgeneration')); |
|
206 | - global $action; |
|
207 | - |
|
208 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | - $sav_charset_output=$outputlangs->charset_output; |
|
210 | - $outputlangs->charset_output='UTF-8'; |
|
211 | - |
|
212 | - $outputlangs->load("main"); |
|
213 | - $outputlangs->load("dict"); |
|
214 | - $outputlangs->load("companies"); |
|
215 | - $outputlangs->load("bills"); |
|
216 | - |
|
217 | - if ($conf->reception->dir_output."/reception") |
|
218 | - { |
|
219 | - // If $object is id instead of object |
|
220 | - if (! is_object($object)) |
|
221 | - { |
|
222 | - $id = $object; |
|
223 | - $object = new Reception($this->db); |
|
224 | - $result=$object->fetch($id); |
|
225 | - if ($result < 0) |
|
226 | - { |
|
227 | - dol_print_error($this->db,$object->error); |
|
228 | - return -1; |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - $dir = $conf->reception->dir_output."/reception"; |
|
233 | - $objectref = dol_sanitizeFileName($object->ref); |
|
234 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
235 | - $file = $dir . "/" . $objectref . ".odt"; |
|
236 | - |
|
237 | - if (! file_exists($dir)) |
|
238 | - { |
|
239 | - if (dol_mkdir($dir) < 0) |
|
240 | - { |
|
241 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
242 | - return -1; |
|
243 | - } |
|
244 | - } |
|
245 | - |
|
246 | - if (file_exists($dir)) |
|
247 | - { |
|
248 | - //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
249 | - $newfile=basename($srctemplatepath); |
|
250 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
251 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
252 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
253 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
254 | - //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
255 | - // Get extension (ods or odt) |
|
256 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
257 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
258 | - { |
|
259 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
260 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
261 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
262 | - } |
|
263 | - else |
|
264 | - { |
|
265 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
266 | - } |
|
267 | - $file=$dir.'/'.$filename; |
|
268 | - //print "newdir=".$dir; |
|
269 | - //print "newfile=".$newfile; |
|
270 | - //print "file=".$file; |
|
271 | - //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
272 | - |
|
273 | - dol_mkdir($conf->reception->dir_temp); |
|
274 | - |
|
275 | - |
|
276 | - // If BILLING contact defined on invoice, we use it |
|
277 | - $usecontact=false; |
|
278 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
279 | - if (count($arrayidcontact) > 0) |
|
280 | - { |
|
281 | - $usecontact=true; |
|
282 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
283 | - } |
|
284 | - |
|
285 | - // Recipient name |
|
286 | - if (! empty($usecontact)) |
|
287 | - { |
|
288 | - // On peut utiliser le nom de la societe du contact |
|
289 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | - else $socobject = $object->thirdparty; |
|
291 | - } |
|
292 | - else |
|
293 | - { |
|
294 | - $socobject=$object->thirdparty; |
|
295 | - } |
|
296 | - |
|
297 | - // Make substitution |
|
298 | - $substitutionarray=array( |
|
299 | - '__FROM_NAME__' => $this->emetteur->name, |
|
300 | - '__FROM_EMAIL__' => $this->emetteur->email, |
|
301 | - '__TOTAL_TTC__' => $object->total_ttc, |
|
302 | - '__TOTAL_HT__' => $object->total_ht, |
|
303 | - '__TOTAL_VAT__' => $object->total_vat |
|
304 | - ); |
|
305 | - complete_substitutions_array($substitutionarray, $langs, $object); |
|
306 | - // Call the ODTSubstitution hook |
|
307 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
308 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
309 | - |
|
310 | - // Line of free text |
|
311 | - $newfreetext=''; |
|
312 | - $paramfreetext='RECEPTION_FREE_TEXT'; |
|
313 | - if (! empty($conf->global->$paramfreetext)) |
|
314 | - { |
|
315 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
316 | - } |
|
317 | - |
|
318 | - // Open and load template |
|
319 | - require_once ODTPHP_PATH.'odf.php'; |
|
320 | - try { |
|
321 | - $odfHandler = new odf( |
|
322 | - $srctemplatepath, |
|
323 | - array( |
|
324 | - 'PATH_TO_TMP' => $conf->reception->dir_temp, |
|
325 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
326 | - 'DELIMITER_LEFT' => '{', |
|
327 | - 'DELIMITER_RIGHT' => '}' |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - catch(Exception $e) |
|
332 | - { |
|
333 | - $this->error=$e->getMessage(); |
|
334 | - return -1; |
|
335 | - } |
|
336 | - // After construction $odfHandler->contentXml contains content and |
|
337 | - // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
338 | - // [!-- BEGIN lines --]*[!-- END lines --] |
|
339 | - //print html_entity_decode($odfHandler->__toString()); |
|
340 | - //print exit; |
|
341 | - |
|
342 | - |
|
343 | - // Make substitutions into odt of freetext |
|
344 | - try { |
|
345 | - $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
346 | - } |
|
347 | - catch(OdfException $e) |
|
348 | - { |
|
349 | - } |
|
350 | - |
|
351 | - // Make substitutions into odt of user info |
|
352 | - $tmparray=$this->get_substitutionarray_user($user,$outputlangs); |
|
353 | - //var_dump($tmparray); exit; |
|
354 | - foreach($tmparray as $key=>$value) |
|
355 | - { |
|
356 | - try { |
|
357 | - if (preg_match('/logo$/',$key)) // Image |
|
358 | - { |
|
359 | - //var_dump($value);exit; |
|
360 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
361 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | - } |
|
363 | - else // Text |
|
364 | - { |
|
365 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
366 | - } |
|
367 | - } |
|
368 | - catch(OdfException $e) |
|
369 | - { |
|
370 | - } |
|
371 | - } |
|
372 | - // Make substitutions into odt of mysoc |
|
373 | - $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
374 | - //var_dump($tmparray); exit; |
|
375 | - foreach($tmparray as $key=>$value) |
|
376 | - { |
|
377 | - try { |
|
378 | - if (preg_match('/logo$/',$key)) // Image |
|
379 | - { |
|
380 | - //var_dump($value);exit; |
|
381 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | - } |
|
384 | - else // Text |
|
385 | - { |
|
386 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
387 | - } |
|
388 | - } |
|
389 | - catch(OdfException $e) |
|
390 | - { |
|
391 | - } |
|
392 | - } |
|
393 | - // Make substitutions into odt of thirdparty |
|
394 | - $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
395 | - foreach($tmparray as $key=>$value) |
|
396 | - { |
|
397 | - try { |
|
398 | - if (preg_match('/logo$/',$key)) // Image |
|
399 | - { |
|
400 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
401 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | - } |
|
403 | - else // Text |
|
404 | - { |
|
405 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
406 | - } |
|
407 | - } |
|
408 | - catch(OdfException $e) |
|
409 | - { |
|
410 | - } |
|
411 | - } |
|
412 | - // Replace tags of object + external modules |
|
413 | - $tmparray=$this->get_substitutionarray_reception($object,$outputlangs); |
|
414 | - complete_substitutions_array($tmparray, $outputlangs, $object); |
|
415 | - // Call the ODTSubstitution hook |
|
416 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
417 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | - foreach($tmparray as $key=>$value) |
|
419 | - { |
|
420 | - try { |
|
421 | - if (preg_match('/logo$/',$key)) // Image |
|
422 | - { |
|
423 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
424 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | - } |
|
426 | - else // Text |
|
427 | - { |
|
428 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
429 | - } |
|
430 | - } |
|
431 | - catch(OdfException $e) |
|
432 | - { |
|
433 | - } |
|
434 | - } |
|
435 | - // Replace tags of lines |
|
436 | - try |
|
437 | - { |
|
438 | - $listlines = $odfHandler->setSegment('lines'); |
|
439 | - foreach ($object->lines as $line) |
|
440 | - { |
|
441 | - $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs); |
|
442 | - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
443 | - // Call the ODTSubstitutionLine hook |
|
444 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
445 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
446 | - foreach($tmparray as $key => $val) |
|
447 | - { |
|
448 | - try |
|
449 | - { |
|
450 | - $listlines->setVars($key, $val, true, 'UTF-8'); |
|
451 | - } |
|
452 | - catch(OdfException $e) |
|
453 | - { |
|
454 | - } |
|
455 | - catch(SegmentException $e) |
|
456 | - { |
|
457 | - } |
|
458 | - } |
|
459 | - $listlines->merge(); |
|
460 | - } |
|
461 | - $odfHandler->mergeSegment($listlines); |
|
462 | - } |
|
463 | - catch(OdfException $e) |
|
464 | - { |
|
465 | - $this->error=$e->getMessage(); |
|
466 | - dol_syslog($this->error, LOG_WARNING); |
|
467 | - return -1; |
|
468 | - } |
|
469 | - |
|
470 | - // Replace labels translated |
|
471 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
472 | - foreach($tmparray as $key=>$value) |
|
473 | - { |
|
474 | - try { |
|
475 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
476 | - } |
|
477 | - catch(OdfException $e) |
|
478 | - { |
|
479 | - } |
|
480 | - } |
|
481 | - |
|
482 | - // Call the beforeODTSave hook |
|
483 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
484 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
485 | - |
|
486 | - // Write new file |
|
487 | - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
488 | - try { |
|
489 | - $odfHandler->exportAsAttachedPDF($file); |
|
490 | - }catch (Exception $e){ |
|
491 | - $this->error=$e->getMessage(); |
|
492 | - return -1; |
|
493 | - } |
|
494 | - } |
|
495 | - else { |
|
496 | - try { |
|
497 | - $odfHandler->saveToDisk($file); |
|
498 | - }catch (Exception $e){ |
|
499 | - $this->error=$e->getMessage(); |
|
500 | - return -1; |
|
501 | - } |
|
502 | - } |
|
503 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
504 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
505 | - |
|
506 | - if (! empty($conf->global->MAIN_UMASK)) |
|
507 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
508 | - |
|
509 | - $odfHandler=null; // Destroy object |
|
510 | - |
|
511 | - return 1; // Success |
|
512 | - } |
|
513 | - else |
|
514 | - { |
|
515 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
516 | - return -1; |
|
517 | - } |
|
518 | - } |
|
519 | - |
|
520 | - return -1; |
|
521 | - } |
|
159 | + } |
|
160 | + $texte.='<div id="div_'.get_class($this).'">'; |
|
161 | + } |
|
162 | + |
|
163 | + $texte.= '</td>'; |
|
164 | + |
|
165 | + $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | + $texte.= '</td>'; |
|
168 | + $texte.= '</tr>'; |
|
169 | + |
|
170 | + $texte.= '</table>'; |
|
171 | + $texte.= '</form>'; |
|
172 | + |
|
173 | + return $texte; |
|
174 | + } |
|
175 | + |
|
176 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
177 | + /** |
|
178 | + * Function to build a document on disk using the generic odt module. |
|
179 | + * |
|
180 | + * @param Reception $object Object source to build document |
|
181 | + * @param Translate $outputlangs Lang output object |
|
182 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
183 | + * @param int $hidedetails Do not show line details |
|
184 | + * @param int $hidedesc Do not show desc |
|
185 | + * @param int $hideref Do not show ref |
|
186 | + * @return int 1 if OK, <=0 if KO |
|
187 | + */ |
|
188 | + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
189 | + { |
|
190 | + // phpcs:enable |
|
191 | + global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | + |
|
193 | + if (empty($srctemplatepath)) |
|
194 | + { |
|
195 | + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
196 | + return -1; |
|
197 | + } |
|
198 | + |
|
199 | + // Add odtgeneration hook |
|
200 | + if (! is_object($hookmanager)) |
|
201 | + { |
|
202 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
203 | + $hookmanager=new HookManager($this->db); |
|
204 | + } |
|
205 | + $hookmanager->initHooks(array('odtgeneration')); |
|
206 | + global $action; |
|
207 | + |
|
208 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | + $sav_charset_output=$outputlangs->charset_output; |
|
210 | + $outputlangs->charset_output='UTF-8'; |
|
211 | + |
|
212 | + $outputlangs->load("main"); |
|
213 | + $outputlangs->load("dict"); |
|
214 | + $outputlangs->load("companies"); |
|
215 | + $outputlangs->load("bills"); |
|
216 | + |
|
217 | + if ($conf->reception->dir_output."/reception") |
|
218 | + { |
|
219 | + // If $object is id instead of object |
|
220 | + if (! is_object($object)) |
|
221 | + { |
|
222 | + $id = $object; |
|
223 | + $object = new Reception($this->db); |
|
224 | + $result=$object->fetch($id); |
|
225 | + if ($result < 0) |
|
226 | + { |
|
227 | + dol_print_error($this->db,$object->error); |
|
228 | + return -1; |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + $dir = $conf->reception->dir_output."/reception"; |
|
233 | + $objectref = dol_sanitizeFileName($object->ref); |
|
234 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
235 | + $file = $dir . "/" . $objectref . ".odt"; |
|
236 | + |
|
237 | + if (! file_exists($dir)) |
|
238 | + { |
|
239 | + if (dol_mkdir($dir) < 0) |
|
240 | + { |
|
241 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
242 | + return -1; |
|
243 | + } |
|
244 | + } |
|
245 | + |
|
246 | + if (file_exists($dir)) |
|
247 | + { |
|
248 | + //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
249 | + $newfile=basename($srctemplatepath); |
|
250 | + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
251 | + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
252 | + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
253 | + $newfiletmp=$objectref.'_'.$newfiletmp; |
|
254 | + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
255 | + // Get extension (ods or odt) |
|
256 | + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
257 | + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
258 | + { |
|
259 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
260 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
261 | + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
262 | + } |
|
263 | + else |
|
264 | + { |
|
265 | + $filename=$newfiletmp.'.'.$newfileformat; |
|
266 | + } |
|
267 | + $file=$dir.'/'.$filename; |
|
268 | + //print "newdir=".$dir; |
|
269 | + //print "newfile=".$newfile; |
|
270 | + //print "file=".$file; |
|
271 | + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
272 | + |
|
273 | + dol_mkdir($conf->reception->dir_temp); |
|
274 | + |
|
275 | + |
|
276 | + // If BILLING contact defined on invoice, we use it |
|
277 | + $usecontact=false; |
|
278 | + $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
279 | + if (count($arrayidcontact) > 0) |
|
280 | + { |
|
281 | + $usecontact=true; |
|
282 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
283 | + } |
|
284 | + |
|
285 | + // Recipient name |
|
286 | + if (! empty($usecontact)) |
|
287 | + { |
|
288 | + // On peut utiliser le nom de la societe du contact |
|
289 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | + else $socobject = $object->thirdparty; |
|
291 | + } |
|
292 | + else |
|
293 | + { |
|
294 | + $socobject=$object->thirdparty; |
|
295 | + } |
|
296 | + |
|
297 | + // Make substitution |
|
298 | + $substitutionarray=array( |
|
299 | + '__FROM_NAME__' => $this->emetteur->name, |
|
300 | + '__FROM_EMAIL__' => $this->emetteur->email, |
|
301 | + '__TOTAL_TTC__' => $object->total_ttc, |
|
302 | + '__TOTAL_HT__' => $object->total_ht, |
|
303 | + '__TOTAL_VAT__' => $object->total_vat |
|
304 | + ); |
|
305 | + complete_substitutions_array($substitutionarray, $langs, $object); |
|
306 | + // Call the ODTSubstitution hook |
|
307 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
308 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
309 | + |
|
310 | + // Line of free text |
|
311 | + $newfreetext=''; |
|
312 | + $paramfreetext='RECEPTION_FREE_TEXT'; |
|
313 | + if (! empty($conf->global->$paramfreetext)) |
|
314 | + { |
|
315 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
316 | + } |
|
317 | + |
|
318 | + // Open and load template |
|
319 | + require_once ODTPHP_PATH.'odf.php'; |
|
320 | + try { |
|
321 | + $odfHandler = new odf( |
|
322 | + $srctemplatepath, |
|
323 | + array( |
|
324 | + 'PATH_TO_TMP' => $conf->reception->dir_temp, |
|
325 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
326 | + 'DELIMITER_LEFT' => '{', |
|
327 | + 'DELIMITER_RIGHT' => '}' |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + catch(Exception $e) |
|
332 | + { |
|
333 | + $this->error=$e->getMessage(); |
|
334 | + return -1; |
|
335 | + } |
|
336 | + // After construction $odfHandler->contentXml contains content and |
|
337 | + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
338 | + // [!-- BEGIN lines --]*[!-- END lines --] |
|
339 | + //print html_entity_decode($odfHandler->__toString()); |
|
340 | + //print exit; |
|
341 | + |
|
342 | + |
|
343 | + // Make substitutions into odt of freetext |
|
344 | + try { |
|
345 | + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
346 | + } |
|
347 | + catch(OdfException $e) |
|
348 | + { |
|
349 | + } |
|
350 | + |
|
351 | + // Make substitutions into odt of user info |
|
352 | + $tmparray=$this->get_substitutionarray_user($user,$outputlangs); |
|
353 | + //var_dump($tmparray); exit; |
|
354 | + foreach($tmparray as $key=>$value) |
|
355 | + { |
|
356 | + try { |
|
357 | + if (preg_match('/logo$/',$key)) // Image |
|
358 | + { |
|
359 | + //var_dump($value);exit; |
|
360 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
361 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | + } |
|
363 | + else // Text |
|
364 | + { |
|
365 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
366 | + } |
|
367 | + } |
|
368 | + catch(OdfException $e) |
|
369 | + { |
|
370 | + } |
|
371 | + } |
|
372 | + // Make substitutions into odt of mysoc |
|
373 | + $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
374 | + //var_dump($tmparray); exit; |
|
375 | + foreach($tmparray as $key=>$value) |
|
376 | + { |
|
377 | + try { |
|
378 | + if (preg_match('/logo$/',$key)) // Image |
|
379 | + { |
|
380 | + //var_dump($value);exit; |
|
381 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
382 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | + } |
|
384 | + else // Text |
|
385 | + { |
|
386 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
387 | + } |
|
388 | + } |
|
389 | + catch(OdfException $e) |
|
390 | + { |
|
391 | + } |
|
392 | + } |
|
393 | + // Make substitutions into odt of thirdparty |
|
394 | + $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
395 | + foreach($tmparray as $key=>$value) |
|
396 | + { |
|
397 | + try { |
|
398 | + if (preg_match('/logo$/',$key)) // Image |
|
399 | + { |
|
400 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
401 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | + } |
|
403 | + else // Text |
|
404 | + { |
|
405 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
406 | + } |
|
407 | + } |
|
408 | + catch(OdfException $e) |
|
409 | + { |
|
410 | + } |
|
411 | + } |
|
412 | + // Replace tags of object + external modules |
|
413 | + $tmparray=$this->get_substitutionarray_reception($object,$outputlangs); |
|
414 | + complete_substitutions_array($tmparray, $outputlangs, $object); |
|
415 | + // Call the ODTSubstitution hook |
|
416 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
417 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | + foreach($tmparray as $key=>$value) |
|
419 | + { |
|
420 | + try { |
|
421 | + if (preg_match('/logo$/',$key)) // Image |
|
422 | + { |
|
423 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
424 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | + } |
|
426 | + else // Text |
|
427 | + { |
|
428 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
429 | + } |
|
430 | + } |
|
431 | + catch(OdfException $e) |
|
432 | + { |
|
433 | + } |
|
434 | + } |
|
435 | + // Replace tags of lines |
|
436 | + try |
|
437 | + { |
|
438 | + $listlines = $odfHandler->setSegment('lines'); |
|
439 | + foreach ($object->lines as $line) |
|
440 | + { |
|
441 | + $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs); |
|
442 | + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
443 | + // Call the ODTSubstitutionLine hook |
|
444 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
445 | + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
446 | + foreach($tmparray as $key => $val) |
|
447 | + { |
|
448 | + try |
|
449 | + { |
|
450 | + $listlines->setVars($key, $val, true, 'UTF-8'); |
|
451 | + } |
|
452 | + catch(OdfException $e) |
|
453 | + { |
|
454 | + } |
|
455 | + catch(SegmentException $e) |
|
456 | + { |
|
457 | + } |
|
458 | + } |
|
459 | + $listlines->merge(); |
|
460 | + } |
|
461 | + $odfHandler->mergeSegment($listlines); |
|
462 | + } |
|
463 | + catch(OdfException $e) |
|
464 | + { |
|
465 | + $this->error=$e->getMessage(); |
|
466 | + dol_syslog($this->error, LOG_WARNING); |
|
467 | + return -1; |
|
468 | + } |
|
469 | + |
|
470 | + // Replace labels translated |
|
471 | + $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
472 | + foreach($tmparray as $key=>$value) |
|
473 | + { |
|
474 | + try { |
|
475 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
476 | + } |
|
477 | + catch(OdfException $e) |
|
478 | + { |
|
479 | + } |
|
480 | + } |
|
481 | + |
|
482 | + // Call the beforeODTSave hook |
|
483 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
484 | + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
485 | + |
|
486 | + // Write new file |
|
487 | + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
488 | + try { |
|
489 | + $odfHandler->exportAsAttachedPDF($file); |
|
490 | + }catch (Exception $e){ |
|
491 | + $this->error=$e->getMessage(); |
|
492 | + return -1; |
|
493 | + } |
|
494 | + } |
|
495 | + else { |
|
496 | + try { |
|
497 | + $odfHandler->saveToDisk($file); |
|
498 | + }catch (Exception $e){ |
|
499 | + $this->error=$e->getMessage(); |
|
500 | + return -1; |
|
501 | + } |
|
502 | + } |
|
503 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
504 | + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
505 | + |
|
506 | + if (! empty($conf->global->MAIN_UMASK)) |
|
507 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
508 | + |
|
509 | + $odfHandler=null; // Destroy object |
|
510 | + |
|
511 | + return 1; // Success |
|
512 | + } |
|
513 | + else |
|
514 | + { |
|
515 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
516 | + return -1; |
|
517 | + } |
|
518 | + } |
|
519 | + |
|
520 | + return -1; |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | \ No newline at end of file |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class doc_generic_reception_odt extends ModelePdfReception |
37 | 37 | { |
38 | - var $emetteur; // Objet societe qui emet |
|
38 | + var $emetteur; // Objet societe qui emet |
|
39 | 39 | |
40 | - var $phpmin = array(5,2,0); // Minimum version of PHP required by module |
|
40 | + var $phpmin = array(5, 2, 0); // Minimum version of PHP required by module |
|
41 | 41 | var $version = 'dolibarr'; |
42 | 42 | |
43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function __construct($db) |
50 | 50 | { |
51 | - global $conf,$langs,$mysoc; |
|
51 | + global $conf, $langs, $mysoc; |
|
52 | 52 | |
53 | 53 | $langs->load("main"); |
54 | 54 | $langs->load("companies"); |
@@ -56,32 +56,32 @@ discard block |
||
56 | 56 | $this->db = $db; |
57 | 57 | $this->name = "ODT templates"; |
58 | 58 | $this->description = $langs->trans("DocumentModelOdt"); |
59 | - $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
59 | + $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
60 | 60 | |
61 | 61 | // Dimension page pour format A4 |
62 | 62 | $this->type = 'odt'; |
63 | 63 | $this->page_largeur = 0; |
64 | 64 | $this->page_hauteur = 0; |
65 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
66 | - $this->marge_gauche=0; |
|
67 | - $this->marge_droite=0; |
|
68 | - $this->marge_haute=0; |
|
69 | - $this->marge_basse=0; |
|
70 | - |
|
71 | - $this->option_logo = 1; // Affiche logo |
|
72 | - $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | - $this->option_modereg = 0; // Affiche mode reglement |
|
74 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | - $this->option_credit_note = 0; // Support credit notes |
|
79 | - $this->option_freetext = 1; // Support add of a personalised text |
|
80 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
65 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
66 | + $this->marge_gauche = 0; |
|
67 | + $this->marge_droite = 0; |
|
68 | + $this->marge_haute = 0; |
|
69 | + $this->marge_basse = 0; |
|
70 | + |
|
71 | + $this->option_logo = 1; // Affiche logo |
|
72 | + $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION |
|
73 | + $this->option_modereg = 0; // Affiche mode reglement |
|
74 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
75 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
76 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
77 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
78 | + $this->option_credit_note = 0; // Support credit notes |
|
79 | + $this->option_freetext = 1; // Support add of a personalised text |
|
80 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
81 | 81 | |
82 | 82 | // Recupere emetteur |
83 | - $this->emetteur=$mysoc; |
|
84 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
83 | + $this->emetteur = $mysoc; |
|
84 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function info($langs) |
95 | 95 | { |
96 | - global $conf,$langs; |
|
96 | + global $conf, $langs; |
|
97 | 97 | |
98 | 98 | $langs->load("companies"); |
99 | 99 | $langs->load("errors"); |
@@ -101,74 +101,74 @@ discard block |
||
101 | 101 | $form = new Form($this->db); |
102 | 102 | |
103 | 103 | $texte = $this->description.".<br>\n"; |
104 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | - $texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
104 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
105 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
106 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
107 | + $texte .= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">'; |
|
108 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
109 | 109 | |
110 | 110 | // List of directories area |
111 | - $texte.= '<tr><td>'; |
|
112 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
113 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | - $listoffiles=array(); |
|
115 | - foreach($listofdir as $key=>$tmpdir) |
|
111 | + $texte .= '<tr><td>'; |
|
112 | + $texttitle = $langs->trans("ListOfDirectories"); |
|
113 | + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); |
|
114 | + $listoffiles = array(); |
|
115 | + foreach ($listofdir as $key=>$tmpdir) |
|
116 | 116 | { |
117 | - $tmpdir=trim($tmpdir); |
|
118 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
119 | - if (! $tmpdir) { |
|
117 | + $tmpdir = trim($tmpdir); |
|
118 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
119 | + if (!$tmpdir) { |
|
120 | 120 | unset($listofdir[$key]); continue; |
121 | 121 | } |
122 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
122 | + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); |
|
123 | 123 | else |
124 | 124 | { |
125 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
126 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
125 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); |
|
126 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
127 | 127 | } |
128 | 128 | } |
129 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
129 | + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); |
|
130 | 130 | // Add list of substitution keys |
131 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | - |
|
134 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
135 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | - $texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | - $texte.= '</textarea>'; |
|
139 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | - $texte.= '<br></div></div>'; |
|
131 | + $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
132 | + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
133 | + |
|
134 | + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); |
|
135 | + $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
136 | + $texte .= '<textarea class="flat" cols="60" name="value1">'; |
|
137 | + $texte .= $conf->global->RECEPTION_ADDON_PDF_ODT_PATH; |
|
138 | + $texte .= '</textarea>'; |
|
139 | + $texte .= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
140 | + $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
141 | + $texte .= '<br></div></div>'; |
|
142 | 142 | |
143 | 143 | // Scan directories |
144 | - $nbofiles=count($listoffiles); |
|
145 | - if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
144 | + $nbofiles = count($listoffiles); |
|
145 | + if (!empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) |
|
146 | 146 | { |
147 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
147 | + $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | 148 | //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
149 | - $texte.=count($listoffiles); |
|
149 | + $texte .= count($listoffiles); |
|
150 | 150 | //$texte.=$nbofiles?'</a>':''; |
151 | - $texte.='</b>'; |
|
151 | + $texte .= '</b>'; |
|
152 | 152 | } |
153 | 153 | if ($nbofiles) |
154 | 154 | { |
155 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | - foreach($listoffiles as $file) |
|
155 | + $texte .= '<div id="div_'.get_class($this).'" class="hidden">'; |
|
156 | + foreach ($listoffiles as $file) |
|
157 | 157 | { |
158 | - $texte.=$file['name'].'<br>'; |
|
158 | + $texte .= $file['name'].'<br>'; |
|
159 | 159 | } |
160 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
160 | + $texte .= '<div id="div_'.get_class($this).'">'; |
|
161 | 161 | } |
162 | 162 | |
163 | - $texte.= '</td>'; |
|
163 | + $texte .= '</td>'; |
|
164 | 164 | |
165 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | - $texte.= '</td>'; |
|
168 | - $texte.= '</tr>'; |
|
165 | + $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
166 | + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
167 | + $texte .= '</td>'; |
|
168 | + $texte .= '</tr>'; |
|
169 | 169 | |
170 | - $texte.= '</table>'; |
|
171 | - $texte.= '</form>'; |
|
170 | + $texte .= '</table>'; |
|
171 | + $texte .= '</form>'; |
|
172 | 172 | |
173 | 173 | return $texte; |
174 | 174 | } |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | * @param int $hideref Do not show ref |
186 | 186 | * @return int 1 if OK, <=0 if KO |
187 | 187 | */ |
188 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
188 | + function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
189 | 189 | { |
190 | 190 | // phpcs:enable |
191 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
191 | + global $user, $langs, $conf, $mysoc, $hookmanager; |
|
192 | 192 | |
193 | 193 | if (empty($srctemplatepath)) |
194 | 194 | { |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | // Add odtgeneration hook |
200 | - if (! is_object($hookmanager)) |
|
200 | + if (!is_object($hookmanager)) |
|
201 | 201 | { |
202 | 202 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
203 | - $hookmanager=new HookManager($this->db); |
|
203 | + $hookmanager = new HookManager($this->db); |
|
204 | 204 | } |
205 | 205 | $hookmanager->initHooks(array('odtgeneration')); |
206 | 206 | global $action; |
207 | 207 | |
208 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | - $sav_charset_output=$outputlangs->charset_output; |
|
210 | - $outputlangs->charset_output='UTF-8'; |
|
208 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
209 | + $sav_charset_output = $outputlangs->charset_output; |
|
210 | + $outputlangs->charset_output = 'UTF-8'; |
|
211 | 211 | |
212 | 212 | $outputlangs->load("main"); |
213 | 213 | $outputlangs->load("dict"); |
@@ -217,28 +217,28 @@ discard block |
||
217 | 217 | if ($conf->reception->dir_output."/reception") |
218 | 218 | { |
219 | 219 | // If $object is id instead of object |
220 | - if (! is_object($object)) |
|
220 | + if (!is_object($object)) |
|
221 | 221 | { |
222 | 222 | $id = $object; |
223 | 223 | $object = new Reception($this->db); |
224 | - $result=$object->fetch($id); |
|
224 | + $result = $object->fetch($id); |
|
225 | 225 | if ($result < 0) |
226 | 226 | { |
227 | - dol_print_error($this->db,$object->error); |
|
227 | + dol_print_error($this->db, $object->error); |
|
228 | 228 | return -1; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | $dir = $conf->reception->dir_output."/reception"; |
233 | 233 | $objectref = dol_sanitizeFileName($object->ref); |
234 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
235 | - $file = $dir . "/" . $objectref . ".odt"; |
|
234 | + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; |
|
235 | + $file = $dir."/".$objectref.".odt"; |
|
236 | 236 | |
237 | - if (! file_exists($dir)) |
|
237 | + if (!file_exists($dir)) |
|
238 | 238 | { |
239 | 239 | if (dol_mkdir($dir) < 0) |
240 | 240 | { |
241 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
241 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
242 | 242 | return -1; |
243 | 243 | } |
244 | 244 | } |
@@ -246,25 +246,25 @@ discard block |
||
246 | 246 | if (file_exists($dir)) |
247 | 247 | { |
248 | 248 | //print "srctemplatepath=".$srctemplatepath; // Src filename |
249 | - $newfile=basename($srctemplatepath); |
|
250 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
251 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
252 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
253 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
249 | + $newfile = basename($srctemplatepath); |
|
250 | + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); |
|
251 | + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
|
252 | + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
|
253 | + $newfiletmp = $objectref.'_'.$newfiletmp; |
|
254 | 254 | //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
255 | 255 | // Get extension (ods or odt) |
256 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
257 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
256 | + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); |
|
257 | + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
258 | 258 | { |
259 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
260 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
261 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
259 | + $format = $conf->global->MAIN_DOC_USE_TIMING; |
|
260 | + if ($format == '1') $format = '%Y%m%d%H%M%S'; |
|
261 | + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; |
|
262 | 262 | } |
263 | 263 | else |
264 | 264 | { |
265 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
265 | + $filename = $newfiletmp.'.'.$newfileformat; |
|
266 | 266 | } |
267 | - $file=$dir.'/'.$filename; |
|
267 | + $file = $dir.'/'.$filename; |
|
268 | 268 | //print "newdir=".$dir; |
269 | 269 | //print "newfile=".$newfile; |
270 | 270 | //print "file=".$file; |
@@ -274,28 +274,28 @@ discard block |
||
274 | 274 | |
275 | 275 | |
276 | 276 | // If BILLING contact defined on invoice, we use it |
277 | - $usecontact=false; |
|
278 | - $arrayidcontact=$object->getIdContact('external','BILLING'); |
|
277 | + $usecontact = false; |
|
278 | + $arrayidcontact = $object->getIdContact('external', 'BILLING'); |
|
279 | 279 | if (count($arrayidcontact) > 0) |
280 | 280 | { |
281 | - $usecontact=true; |
|
282 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
281 | + $usecontact = true; |
|
282 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // Recipient name |
286 | - if (! empty($usecontact)) |
|
286 | + if (!empty($usecontact)) |
|
287 | 287 | { |
288 | 288 | // On peut utiliser le nom de la societe du contact |
289 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
289 | + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | 290 | else $socobject = $object->thirdparty; |
291 | 291 | } |
292 | 292 | else |
293 | 293 | { |
294 | - $socobject=$object->thirdparty; |
|
294 | + $socobject = $object->thirdparty; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | // Make substitution |
298 | - $substitutionarray=array( |
|
298 | + $substitutionarray = array( |
|
299 | 299 | '__FROM_NAME__' => $this->emetteur->name, |
300 | 300 | '__FROM_EMAIL__' => $this->emetteur->email, |
301 | 301 | '__TOTAL_TTC__' => $object->total_ttc, |
@@ -304,15 +304,15 @@ discard block |
||
304 | 304 | ); |
305 | 305 | complete_substitutions_array($substitutionarray, $langs, $object); |
306 | 306 | // Call the ODTSubstitution hook |
307 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
308 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
307 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); |
|
308 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
309 | 309 | |
310 | 310 | // Line of free text |
311 | - $newfreetext=''; |
|
312 | - $paramfreetext='RECEPTION_FREE_TEXT'; |
|
313 | - if (! empty($conf->global->$paramfreetext)) |
|
311 | + $newfreetext = ''; |
|
312 | + $paramfreetext = 'RECEPTION_FREE_TEXT'; |
|
313 | + if (!empty($conf->global->$paramfreetext)) |
|
314 | 314 | { |
315 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
315 | + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // Open and load template |
@@ -322,15 +322,15 @@ discard block |
||
322 | 322 | $srctemplatepath, |
323 | 323 | array( |
324 | 324 | 'PATH_TO_TMP' => $conf->reception->dir_temp, |
325 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
325 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
326 | 326 | 'DELIMITER_LEFT' => '{', |
327 | 327 | 'DELIMITER_RIGHT' => '}' |
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | } |
331 | - catch(Exception $e) |
|
331 | + catch (Exception $e) |
|
332 | 332 | { |
333 | - $this->error=$e->getMessage(); |
|
333 | + $this->error = $e->getMessage(); |
|
334 | 334 | return -1; |
335 | 335 | } |
336 | 336 | // After construction $odfHandler->contentXml contains content and |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | try { |
345 | 345 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
346 | 346 | } |
347 | - catch(OdfException $e) |
|
347 | + catch (OdfException $e) |
|
348 | 348 | { |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Make substitutions into odt of user info |
352 | - $tmparray=$this->get_substitutionarray_user($user,$outputlangs); |
|
352 | + $tmparray = $this->get_substitutionarray_user($user, $outputlangs); |
|
353 | 353 | //var_dump($tmparray); exit; |
354 | - foreach($tmparray as $key=>$value) |
|
354 | + foreach ($tmparray as $key=>$value) |
|
355 | 355 | { |
356 | 356 | try { |
357 | - if (preg_match('/logo$/',$key)) // Image |
|
357 | + if (preg_match('/logo$/', $key)) // Image |
|
358 | 358 | { |
359 | 359 | //var_dump($value);exit; |
360 | 360 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
@@ -365,17 +365,17 @@ discard block |
||
365 | 365 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
366 | 366 | } |
367 | 367 | } |
368 | - catch(OdfException $e) |
|
368 | + catch (OdfException $e) |
|
369 | 369 | { |
370 | 370 | } |
371 | 371 | } |
372 | 372 | // Make substitutions into odt of mysoc |
373 | - $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
373 | + $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); |
|
374 | 374 | //var_dump($tmparray); exit; |
375 | - foreach($tmparray as $key=>$value) |
|
375 | + foreach ($tmparray as $key=>$value) |
|
376 | 376 | { |
377 | 377 | try { |
378 | - if (preg_match('/logo$/',$key)) // Image |
|
378 | + if (preg_match('/logo$/', $key)) // Image |
|
379 | 379 | { |
380 | 380 | //var_dump($value);exit; |
381 | 381 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
@@ -386,16 +386,16 @@ discard block |
||
386 | 386 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
387 | 387 | } |
388 | 388 | } |
389 | - catch(OdfException $e) |
|
389 | + catch (OdfException $e) |
|
390 | 390 | { |
391 | 391 | } |
392 | 392 | } |
393 | 393 | // Make substitutions into odt of thirdparty |
394 | - $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
395 | - foreach($tmparray as $key=>$value) |
|
394 | + $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); |
|
395 | + foreach ($tmparray as $key=>$value) |
|
396 | 396 | { |
397 | 397 | try { |
398 | - if (preg_match('/logo$/',$key)) // Image |
|
398 | + if (preg_match('/logo$/', $key)) // Image |
|
399 | 399 | { |
400 | 400 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
401 | 401 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -405,20 +405,20 @@ discard block |
||
405 | 405 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
406 | 406 | } |
407 | 407 | } |
408 | - catch(OdfException $e) |
|
408 | + catch (OdfException $e) |
|
409 | 409 | { |
410 | 410 | } |
411 | 411 | } |
412 | 412 | // Replace tags of object + external modules |
413 | - $tmparray=$this->get_substitutionarray_reception($object,$outputlangs); |
|
413 | + $tmparray = $this->get_substitutionarray_reception($object, $outputlangs); |
|
414 | 414 | complete_substitutions_array($tmparray, $outputlangs, $object); |
415 | 415 | // Call the ODTSubstitution hook |
416 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
417 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
418 | - foreach($tmparray as $key=>$value) |
|
416 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
417 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
418 | + foreach ($tmparray as $key=>$value) |
|
419 | 419 | { |
420 | 420 | try { |
421 | - if (preg_match('/logo$/',$key)) // Image |
|
421 | + if (preg_match('/logo$/', $key)) // Image |
|
422 | 422 | { |
423 | 423 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
424 | 424 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
429 | 429 | } |
430 | 430 | } |
431 | - catch(OdfException $e) |
|
431 | + catch (OdfException $e) |
|
432 | 432 | { |
433 | 433 | } |
434 | 434 | } |
@@ -438,21 +438,21 @@ discard block |
||
438 | 438 | $listlines = $odfHandler->setSegment('lines'); |
439 | 439 | foreach ($object->lines as $line) |
440 | 440 | { |
441 | - $tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs); |
|
441 | + $tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs); |
|
442 | 442 | complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
443 | 443 | // Call the ODTSubstitutionLine hook |
444 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
445 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
446 | - foreach($tmparray as $key => $val) |
|
444 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); |
|
445 | + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
446 | + foreach ($tmparray as $key => $val) |
|
447 | 447 | { |
448 | 448 | try |
449 | 449 | { |
450 | 450 | $listlines->setVars($key, $val, true, 'UTF-8'); |
451 | 451 | } |
452 | - catch(OdfException $e) |
|
452 | + catch (OdfException $e) |
|
453 | 453 | { |
454 | 454 | } |
455 | - catch(SegmentException $e) |
|
455 | + catch (SegmentException $e) |
|
456 | 456 | { |
457 | 457 | } |
458 | 458 | } |
@@ -460,59 +460,59 @@ discard block |
||
460 | 460 | } |
461 | 461 | $odfHandler->mergeSegment($listlines); |
462 | 462 | } |
463 | - catch(OdfException $e) |
|
463 | + catch (OdfException $e) |
|
464 | 464 | { |
465 | - $this->error=$e->getMessage(); |
|
465 | + $this->error = $e->getMessage(); |
|
466 | 466 | dol_syslog($this->error, LOG_WARNING); |
467 | 467 | return -1; |
468 | 468 | } |
469 | 469 | |
470 | 470 | // Replace labels translated |
471 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
472 | - foreach($tmparray as $key=>$value) |
|
471 | + $tmparray = $outputlangs->get_translations_for_substitutions(); |
|
472 | + foreach ($tmparray as $key=>$value) |
|
473 | 473 | { |
474 | 474 | try { |
475 | 475 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
476 | 476 | } |
477 | - catch(OdfException $e) |
|
477 | + catch (OdfException $e) |
|
478 | 478 | { |
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | 482 | // Call the beforeODTSave hook |
483 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
484 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
483 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
484 | + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
485 | 485 | |
486 | 486 | // Write new file |
487 | 487 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
488 | 488 | try { |
489 | 489 | $odfHandler->exportAsAttachedPDF($file); |
490 | - }catch (Exception $e){ |
|
491 | - $this->error=$e->getMessage(); |
|
490 | + } catch (Exception $e) { |
|
491 | + $this->error = $e->getMessage(); |
|
492 | 492 | return -1; |
493 | 493 | } |
494 | 494 | } |
495 | 495 | else { |
496 | 496 | try { |
497 | 497 | $odfHandler->saveToDisk($file); |
498 | - }catch (Exception $e){ |
|
499 | - $this->error=$e->getMessage(); |
|
498 | + } catch (Exception $e) { |
|
499 | + $this->error = $e->getMessage(); |
|
500 | 500 | return -1; |
501 | 501 | } |
502 | 502 | } |
503 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
504 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
503 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
504 | + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
505 | 505 | |
506 | - if (! empty($conf->global->MAIN_UMASK)) |
|
506 | + if (!empty($conf->global->MAIN_UMASK)) |
|
507 | 507 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
508 | 508 | |
509 | - $odfHandler=null; // Destroy object |
|
509 | + $odfHandler = null; // Destroy object |
|
510 | 510 | |
511 | - return 1; // Success |
|
511 | + return 1; // Success |
|
512 | 512 | } |
513 | 513 | else |
514 | 514 | { |
515 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
515 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
516 | 516 | return -1; |
517 | 517 | } |
518 | 518 | } |
@@ -81,7 +81,10 @@ discard block |
||
81 | 81 | |
82 | 82 | // Recupere emetteur |
83 | 83 | $this->emetteur=$mysoc; |
84 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | + if (! $this->emetteur->country_code) { |
|
85 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
86 | + } |
|
87 | + // By default if not defined |
|
85 | 88 | } |
86 | 89 | |
87 | 90 | |
@@ -119,11 +122,14 @@ discard block |
||
119 | 122 | if (! $tmpdir) { |
120 | 123 | unset($listofdir[$key]); continue; |
121 | 124 | } |
122 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
123 | - else |
|
125 | + if (! is_dir($tmpdir)) { |
|
126 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
127 | + } else |
|
124 | 128 | { |
125 | 129 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
126 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
130 | + if (count($tmpfiles)) { |
|
131 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
132 | + } |
|
127 | 133 | } |
128 | 134 | } |
129 | 135 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -205,7 +211,9 @@ discard block |
||
205 | 211 | $hookmanager->initHooks(array('odtgeneration')); |
206 | 212 | global $action; |
207 | 213 | |
208 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
214 | + if (! is_object($outputlangs)) { |
|
215 | + $outputlangs=$langs; |
|
216 | + } |
|
209 | 217 | $sav_charset_output=$outputlangs->charset_output; |
210 | 218 | $outputlangs->charset_output='UTF-8'; |
211 | 219 | |
@@ -231,7 +239,9 @@ discard block |
||
231 | 239 | |
232 | 240 | $dir = $conf->reception->dir_output."/reception"; |
233 | 241 | $objectref = dol_sanitizeFileName($object->ref); |
234 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
242 | + if (! preg_match('/specimen/i',$objectref)) { |
|
243 | + $dir.= "/" . $objectref; |
|
244 | + } |
|
235 | 245 | $file = $dir . "/" . $objectref . ".odt"; |
236 | 246 | |
237 | 247 | if (! file_exists($dir)) |
@@ -257,10 +267,11 @@ discard block |
||
257 | 267 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
258 | 268 | { |
259 | 269 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
260 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
270 | + if ($format == '1') { |
|
271 | + $format='%Y%m%d%H%M%S'; |
|
272 | + } |
|
261 | 273 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
262 | - } |
|
263 | - else |
|
274 | + } else |
|
264 | 275 | { |
265 | 276 | $filename=$newfiletmp.'.'.$newfileformat; |
266 | 277 | } |
@@ -286,10 +297,12 @@ discard block |
||
286 | 297 | if (! empty($usecontact)) |
287 | 298 | { |
288 | 299 | // On peut utiliser le nom de la societe du contact |
289 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
290 | - else $socobject = $object->thirdparty; |
|
291 | - } |
|
292 | - else |
|
300 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
301 | + $socobject = $object->contact; |
|
302 | + } else { |
|
303 | + $socobject = $object->thirdparty; |
|
304 | + } |
|
305 | + } else |
|
293 | 306 | { |
294 | 307 | $socobject=$object->thirdparty; |
295 | 308 | } |
@@ -327,8 +340,7 @@ discard block |
||
327 | 340 | 'DELIMITER_RIGHT' => '}' |
328 | 341 | ) |
329 | 342 | ); |
330 | - } |
|
331 | - catch(Exception $e) |
|
343 | + } catch(Exception $e) |
|
332 | 344 | { |
333 | 345 | $this->error=$e->getMessage(); |
334 | 346 | return -1; |
@@ -343,8 +355,7 @@ discard block |
||
343 | 355 | // Make substitutions into odt of freetext |
344 | 356 | try { |
345 | 357 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
346 | - } |
|
347 | - catch(OdfException $e) |
|
358 | + } catch(OdfException $e) |
|
348 | 359 | { |
349 | 360 | } |
350 | 361 | |
@@ -354,18 +365,19 @@ discard block |
||
354 | 365 | foreach($tmparray as $key=>$value) |
355 | 366 | { |
356 | 367 | try { |
357 | - if (preg_match('/logo$/',$key)) // Image |
|
368 | + if (preg_match('/logo$/',$key)) { |
|
369 | + // Image |
|
358 | 370 | { |
359 | 371 | //var_dump($value);exit; |
360 | 372 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
361 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
362 | - } |
|
363 | - else // Text |
|
373 | + } else { |
|
374 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
375 | + } |
|
376 | + } else // Text |
|
364 | 377 | { |
365 | 378 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
366 | 379 | } |
367 | - } |
|
368 | - catch(OdfException $e) |
|
380 | + } catch(OdfException $e) |
|
369 | 381 | { |
370 | 382 | } |
371 | 383 | } |
@@ -375,18 +387,19 @@ discard block |
||
375 | 387 | foreach($tmparray as $key=>$value) |
376 | 388 | { |
377 | 389 | try { |
378 | - if (preg_match('/logo$/',$key)) // Image |
|
390 | + if (preg_match('/logo$/',$key)) { |
|
391 | + // Image |
|
379 | 392 | { |
380 | 393 | //var_dump($value);exit; |
381 | 394 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | - } |
|
384 | - else // Text |
|
395 | + } else { |
|
396 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
397 | + } |
|
398 | + } else // Text |
|
385 | 399 | { |
386 | 400 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
387 | 401 | } |
388 | - } |
|
389 | - catch(OdfException $e) |
|
402 | + } catch(OdfException $e) |
|
390 | 403 | { |
391 | 404 | } |
392 | 405 | } |
@@ -395,17 +408,18 @@ discard block |
||
395 | 408 | foreach($tmparray as $key=>$value) |
396 | 409 | { |
397 | 410 | try { |
398 | - if (preg_match('/logo$/',$key)) // Image |
|
411 | + if (preg_match('/logo$/',$key)) { |
|
412 | + // Image |
|
399 | 413 | { |
400 | 414 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
401 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
402 | - } |
|
403 | - else // Text |
|
415 | + } else { |
|
416 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
417 | + } |
|
418 | + } else // Text |
|
404 | 419 | { |
405 | 420 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
406 | 421 | } |
407 | - } |
|
408 | - catch(OdfException $e) |
|
422 | + } catch(OdfException $e) |
|
409 | 423 | { |
410 | 424 | } |
411 | 425 | } |
@@ -418,17 +432,18 @@ discard block |
||
418 | 432 | foreach($tmparray as $key=>$value) |
419 | 433 | { |
420 | 434 | try { |
421 | - if (preg_match('/logo$/',$key)) // Image |
|
435 | + if (preg_match('/logo$/',$key)) { |
|
436 | + // Image |
|
422 | 437 | { |
423 | 438 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
424 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | - } |
|
426 | - else // Text |
|
439 | + } else { |
|
440 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
441 | + } |
|
442 | + } else // Text |
|
427 | 443 | { |
428 | 444 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
429 | 445 | } |
430 | - } |
|
431 | - catch(OdfException $e) |
|
446 | + } catch(OdfException $e) |
|
432 | 447 | { |
433 | 448 | } |
434 | 449 | } |
@@ -448,19 +463,16 @@ discard block |
||
448 | 463 | try |
449 | 464 | { |
450 | 465 | $listlines->setVars($key, $val, true, 'UTF-8'); |
451 | - } |
|
452 | - catch(OdfException $e) |
|
466 | + } catch(OdfException $e) |
|
453 | 467 | { |
454 | - } |
|
455 | - catch(SegmentException $e) |
|
468 | + } catch(SegmentException $e) |
|
456 | 469 | { |
457 | 470 | } |
458 | 471 | } |
459 | 472 | $listlines->merge(); |
460 | 473 | } |
461 | 474 | $odfHandler->mergeSegment($listlines); |
462 | - } |
|
463 | - catch(OdfException $e) |
|
475 | + } catch(OdfException $e) |
|
464 | 476 | { |
465 | 477 | $this->error=$e->getMessage(); |
466 | 478 | dol_syslog($this->error, LOG_WARNING); |
@@ -473,8 +485,7 @@ discard block |
||
473 | 485 | { |
474 | 486 | try { |
475 | 487 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
476 | - } |
|
477 | - catch(OdfException $e) |
|
488 | + } catch(OdfException $e) |
|
478 | 489 | { |
479 | 490 | } |
480 | 491 | } |
@@ -487,15 +498,14 @@ discard block |
||
487 | 498 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
488 | 499 | try { |
489 | 500 | $odfHandler->exportAsAttachedPDF($file); |
490 | - }catch (Exception $e){ |
|
501 | + } catch (Exception $e){ |
|
491 | 502 | $this->error=$e->getMessage(); |
492 | 503 | return -1; |
493 | 504 | } |
494 | - } |
|
495 | - else { |
|
505 | + } else { |
|
496 | 506 | try { |
497 | 507 | $odfHandler->saveToDisk($file); |
498 | - }catch (Exception $e){ |
|
508 | + } catch (Exception $e){ |
|
499 | 509 | $this->error=$e->getMessage(); |
500 | 510 | return -1; |
501 | 511 | } |
@@ -503,14 +513,14 @@ discard block |
||
503 | 513 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
504 | 514 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
505 | 515 | |
506 | - if (! empty($conf->global->MAIN_UMASK)) |
|
507 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
516 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
517 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
518 | + } |
|
508 | 519 | |
509 | 520 | $odfHandler=null; // Destroy object |
510 | 521 | |
511 | 522 | return 1; // Success |
512 | - } |
|
513 | - else |
|
523 | + } else |
|
514 | 524 | { |
515 | 525 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
516 | 526 | return -1; |
@@ -28,119 +28,119 @@ |
||
28 | 28 | */ |
29 | 29 | class mod_reception_beryl extends ModelNumRefReception |
30 | 30 | { |
31 | - var $version='dolibarr'; |
|
32 | - var $prefix='RCP'; |
|
33 | - var $error=''; |
|
34 | - var $nom='Beryl'; |
|
31 | + var $version='dolibarr'; |
|
32 | + var $prefix='RCP'; |
|
33 | + var $error=''; |
|
34 | + var $nom='Beryl'; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Return default description of numbering model |
|
39 | - * |
|
40 | - * @return string text description |
|
41 | - */ |
|
37 | + /** |
|
38 | + * Return default description of numbering model |
|
39 | + * |
|
40 | + * @return string text description |
|
41 | + */ |
|
42 | 42 | function info() |
43 | 43 | { |
44 | - global $langs; |
|
45 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
44 | + global $langs; |
|
45 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Return numbering example |
|
51 | - * |
|
52 | - * @return string Example |
|
53 | - */ |
|
54 | - function getExample() |
|
55 | - { |
|
56 | - return $this->prefix."0501-0001"; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Test if existing numbers make problems with numbering |
|
62 | - * |
|
63 | - * @return boolean false if conflit, true if ok |
|
64 | - */ |
|
65 | - function canBeActivated() |
|
66 | - { |
|
67 | - global $conf,$langs,$db; |
|
68 | - |
|
69 | - $coyymm=''; $max=''; |
|
70 | - |
|
71 | - $posindice=8; |
|
72 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
73 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | - $sql.= " AND entity = ".$conf->entity; |
|
76 | - |
|
77 | - $resql=$db->query($sql); |
|
78 | - if ($resql) |
|
79 | - { |
|
80 | - $row = $db->fetch_row($resql); |
|
81 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
82 | - } |
|
83 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
84 | - { |
|
85 | - $langs->load("errors"); |
|
86 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
87 | - return false; |
|
88 | - } |
|
89 | - |
|
90 | - return true; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Return next value |
|
95 | - * |
|
96 | - * @param Societe $objsoc Third party object |
|
97 | - * @param Object $shipment Shipment object |
|
98 | - * @return string Value if OK, 0 if KO |
|
99 | - */ |
|
100 | - function getNextValue($objsoc,$shipment) |
|
101 | - { |
|
102 | - global $db,$conf; |
|
103 | - |
|
104 | - $posindice=9; |
|
105 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | - $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | - |
|
110 | - $resql=$db->query($sql); |
|
111 | - if ($resql) |
|
112 | - { |
|
113 | - $obj = $db->fetch_object($resql); |
|
114 | - if ($obj) $max = intval($obj->max); |
|
115 | - else $max=0; |
|
116 | - } |
|
117 | - else |
|
118 | - { |
|
119 | - dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
|
120 | - return -1; |
|
121 | - } |
|
122 | - |
|
123 | - $date=time(); |
|
124 | - $yymm = strftime("%y%m",$date); |
|
125 | - |
|
126 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | - else $num = sprintf("%04s",$max+1); |
|
128 | - |
|
129 | - dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
130 | - return $this->prefix.$yymm."-".$num; |
|
131 | - } |
|
132 | - |
|
133 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
134 | - /** |
|
135 | - * Return next free value |
|
136 | - * |
|
137 | - * @param Societe $objsoc Third party object |
|
138 | - * @param Object $objforref Shipment object |
|
139 | - * @return string Next free value |
|
140 | - */ |
|
141 | - function reception_get_num($objsoc,$objforref) |
|
142 | - { |
|
143 | - // phpcs:enable |
|
144 | - return $this->getNextValue($objsoc,$objforref); |
|
145 | - } |
|
49 | + /** |
|
50 | + * Return numbering example |
|
51 | + * |
|
52 | + * @return string Example |
|
53 | + */ |
|
54 | + function getExample() |
|
55 | + { |
|
56 | + return $this->prefix."0501-0001"; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Test if existing numbers make problems with numbering |
|
62 | + * |
|
63 | + * @return boolean false if conflit, true if ok |
|
64 | + */ |
|
65 | + function canBeActivated() |
|
66 | + { |
|
67 | + global $conf,$langs,$db; |
|
68 | + |
|
69 | + $coyymm=''; $max=''; |
|
70 | + |
|
71 | + $posindice=8; |
|
72 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
73 | + $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | + $sql.= " AND entity = ".$conf->entity; |
|
76 | + |
|
77 | + $resql=$db->query($sql); |
|
78 | + if ($resql) |
|
79 | + { |
|
80 | + $row = $db->fetch_row($resql); |
|
81 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
82 | + } |
|
83 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
84 | + { |
|
85 | + $langs->load("errors"); |
|
86 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
87 | + return false; |
|
88 | + } |
|
89 | + |
|
90 | + return true; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Return next value |
|
95 | + * |
|
96 | + * @param Societe $objsoc Third party object |
|
97 | + * @param Object $shipment Shipment object |
|
98 | + * @return string Value if OK, 0 if KO |
|
99 | + */ |
|
100 | + function getNextValue($objsoc,$shipment) |
|
101 | + { |
|
102 | + global $db,$conf; |
|
103 | + |
|
104 | + $posindice=9; |
|
105 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | + $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | + $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | + $sql.= " AND entity = ".$conf->entity; |
|
109 | + |
|
110 | + $resql=$db->query($sql); |
|
111 | + if ($resql) |
|
112 | + { |
|
113 | + $obj = $db->fetch_object($resql); |
|
114 | + if ($obj) $max = intval($obj->max); |
|
115 | + else $max=0; |
|
116 | + } |
|
117 | + else |
|
118 | + { |
|
119 | + dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
|
120 | + return -1; |
|
121 | + } |
|
122 | + |
|
123 | + $date=time(); |
|
124 | + $yymm = strftime("%y%m",$date); |
|
125 | + |
|
126 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | + else $num = sprintf("%04s",$max+1); |
|
128 | + |
|
129 | + dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
130 | + return $this->prefix.$yymm."-".$num; |
|
131 | + } |
|
132 | + |
|
133 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
134 | + /** |
|
135 | + * Return next free value |
|
136 | + * |
|
137 | + * @param Societe $objsoc Third party object |
|
138 | + * @param Object $objforref Shipment object |
|
139 | + * @return string Next free value |
|
140 | + */ |
|
141 | + function reception_get_num($objsoc,$objforref) |
|
142 | + { |
|
143 | + // phpcs:enable |
|
144 | + return $this->getNextValue($objsoc,$objforref); |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | * \ingroup reception |
22 | 22 | * \brief File of class to manage shipments numbering rules Beryl |
23 | 23 | */ |
24 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; |
|
24 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Class to manage reception numbering rules Beryl |
28 | 28 | */ |
29 | 29 | class mod_reception_beryl extends ModelNumRefReception |
30 | 30 | { |
31 | - var $version='dolibarr'; |
|
32 | - var $prefix='RCP'; |
|
33 | - var $error=''; |
|
34 | - var $nom='Beryl'; |
|
31 | + var $version = 'dolibarr'; |
|
32 | + var $prefix = 'RCP'; |
|
33 | + var $error = ''; |
|
34 | + var $nom = 'Beryl'; |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function info() |
43 | 43 | { |
44 | 44 | global $langs; |
45 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
45 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,26 +64,26 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function canBeActivated() |
66 | 66 | { |
67 | - global $conf,$langs,$db; |
|
67 | + global $conf, $langs, $db; |
|
68 | 68 | |
69 | - $coyymm=''; $max=''; |
|
69 | + $coyymm = ''; $max = ''; |
|
70 | 70 | |
71 | - $posindice=8; |
|
71 | + $posindice = 8; |
|
72 | 72 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
73 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | - $sql.= " AND entity = ".$conf->entity; |
|
73 | + $sql .= " FROM ".MAIN_DB_PREFIX."reception"; |
|
74 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
75 | + $sql .= " AND entity = ".$conf->entity; |
|
76 | 76 | |
77 | - $resql=$db->query($sql); |
|
77 | + $resql = $db->query($sql); |
|
78 | 78 | if ($resql) |
79 | 79 | { |
80 | 80 | $row = $db->fetch_row($resql); |
81 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
81 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
82 | 82 | } |
83 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
83 | + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
84 | 84 | { |
85 | 85 | $langs->load("errors"); |
86 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
86 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -97,22 +97,22 @@ discard block |
||
97 | 97 | * @param Object $shipment Shipment object |
98 | 98 | * @return string Value if OK, 0 if KO |
99 | 99 | */ |
100 | - function getNextValue($objsoc,$shipment) |
|
100 | + function getNextValue($objsoc, $shipment) |
|
101 | 101 | { |
102 | - global $db,$conf; |
|
102 | + global $db, $conf; |
|
103 | 103 | |
104 | - $posindice=9; |
|
104 | + $posindice = 9; |
|
105 | 105 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | - $sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | - $sql.= " AND entity = ".$conf->entity; |
|
106 | + $sql .= " FROM ".MAIN_DB_PREFIX."reception"; |
|
107 | + $sql .= " WHERE ref like '".$db->escape($this->prefix)."____-%'"; |
|
108 | + $sql .= " AND entity = ".$conf->entity; |
|
109 | 109 | |
110 | - $resql=$db->query($sql); |
|
110 | + $resql = $db->query($sql); |
|
111 | 111 | if ($resql) |
112 | 112 | { |
113 | 113 | $obj = $db->fetch_object($resql); |
114 | 114 | if ($obj) $max = intval($obj->max); |
115 | - else $max=0; |
|
115 | + else $max = 0; |
|
116 | 116 | } |
117 | 117 | else |
118 | 118 | { |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | return -1; |
121 | 121 | } |
122 | 122 | |
123 | - $date=time(); |
|
124 | - $yymm = strftime("%y%m",$date); |
|
123 | + $date = time(); |
|
124 | + $yymm = strftime("%y%m", $date); |
|
125 | 125 | |
126 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | - else $num = sprintf("%04s",$max+1); |
|
126 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | + else $num = sprintf("%04s", $max + 1); |
|
128 | 128 | |
129 | 129 | dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
130 | 130 | return $this->prefix.$yymm."-".$num; |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * @param Object $objforref Shipment object |
139 | 139 | * @return string Next free value |
140 | 140 | */ |
141 | - function reception_get_num($objsoc,$objforref) |
|
141 | + function reception_get_num($objsoc, $objforref) |
|
142 | 142 | { |
143 | 143 | // phpcs:enable |
144 | - return $this->getNextValue($objsoc,$objforref); |
|
144 | + return $this->getNextValue($objsoc, $objforref); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -111,10 +111,12 @@ discard block |
||
111 | 111 | if ($resql) |
112 | 112 | { |
113 | 113 | $obj = $db->fetch_object($resql); |
114 | - if ($obj) $max = intval($obj->max); |
|
115 | - else $max=0; |
|
116 | - } |
|
117 | - else |
|
114 | + if ($obj) { |
|
115 | + $max = intval($obj->max); |
|
116 | + } else { |
|
117 | + $max=0; |
|
118 | + } |
|
119 | + } else |
|
118 | 120 | { |
119 | 121 | dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG); |
120 | 122 | return -1; |
@@ -123,8 +125,13 @@ discard block |
||
123 | 125 | $date=time(); |
124 | 126 | $yymm = strftime("%y%m",$date); |
125 | 127 | |
126 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
127 | - else $num = sprintf("%04s",$max+1); |
|
128 | + if ($max >= (pow(10, 4) - 1)) { |
|
129 | + $num=$max+1; |
|
130 | + } |
|
131 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
132 | + else { |
|
133 | + $num = sprintf("%04s",$max+1); |
|
134 | + } |
|
128 | 135 | |
129 | 136 | dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); |
130 | 137 | return $this->prefix.$yymm."-".$num; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File that contains parent class for sending receipts models |
23 | 23 | * and parent class for sending receipts numbering models |
24 | 24 | */ |
25 | - require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
25 | + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Parent class of sending receipts models |
@@ -34,25 +34,25 @@ discard block |
||
34 | 34 | |
35 | 35 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
36 | 36 | /** |
37 | - * Return list of active generation modules |
|
38 | - * |
|
37 | + * Return list of active generation modules |
|
38 | + * |
|
39 | 39 | * @param DoliDB $db Database handler |
40 | 40 | * @param integer $maxfilenamelength Max length of value to show |
41 | 41 | * @return array List of templates |
42 | - */ |
|
43 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
44 | - { |
|
45 | - // phpcs:enable |
|
46 | - global $conf; |
|
42 | + */ |
|
43 | + static function liste_modeles($db,$maxfilenamelength=0) |
|
44 | + { |
|
45 | + // phpcs:enable |
|
46 | + global $conf; |
|
47 | 47 | |
48 | - $type='reception'; |
|
49 | - $liste=array(); |
|
48 | + $type='reception'; |
|
49 | + $liste=array(); |
|
50 | 50 | |
51 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
51 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | + $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
53 | 53 | |
54 | - return $liste; |
|
55 | - } |
|
54 | + return $liste; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -61,78 +61,78 @@ discard block |
||
61 | 61 | */ |
62 | 62 | abstract class ModelNumRefReception |
63 | 63 | { |
64 | - var $error=''; |
|
65 | - |
|
66 | - /** Return if a model can be used or not |
|
67 | - * |
|
68 | - * @return boolean true if model can be used |
|
69 | - */ |
|
70 | - function isEnabled() |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Return default description of numbering model |
|
77 | - * |
|
78 | - * @return string text description |
|
79 | - */ |
|
80 | - function info() |
|
81 | - { |
|
82 | - global $langs; |
|
83 | - $langs->load("reception"); |
|
84 | - return $langs->trans("NoDescription"); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns numbering example |
|
89 | - * |
|
90 | - * @return string Example |
|
91 | - */ |
|
92 | - function getExample() |
|
93 | - { |
|
94 | - global $langs; |
|
95 | - $langs->load("reception"); |
|
96 | - return $langs->trans("NoExample"); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Test if existing numbers make problems with numbering |
|
101 | - * |
|
102 | - * @return boolean false if conflit, true if ok |
|
103 | - */ |
|
104 | - function canBeActivated() |
|
105 | - { |
|
106 | - return true; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Returns next value assigned |
|
111 | - * |
|
112 | - * @param Societe $objsoc Third party object |
|
113 | - * @param Object $shipment Shipment object |
|
114 | - * @return string Value |
|
115 | - */ |
|
116 | - function getNextValue($objsoc, $shipment) |
|
117 | - { |
|
118 | - global $langs; |
|
119 | - return $langs->trans("NotAvailable"); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Returns version of the numbering model |
|
124 | - * |
|
125 | - * @return string Value |
|
126 | - */ |
|
127 | - function getVersion() |
|
128 | - { |
|
129 | - global $langs; |
|
130 | - $langs->load("admin"); |
|
131 | - |
|
132 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
133 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
134 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
135 | - if ($this->version) return $this->version; |
|
136 | - return $langs->trans("NotAvailable"); |
|
137 | - } |
|
64 | + var $error=''; |
|
65 | + |
|
66 | + /** Return if a model can be used or not |
|
67 | + * |
|
68 | + * @return boolean true if model can be used |
|
69 | + */ |
|
70 | + function isEnabled() |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Return default description of numbering model |
|
77 | + * |
|
78 | + * @return string text description |
|
79 | + */ |
|
80 | + function info() |
|
81 | + { |
|
82 | + global $langs; |
|
83 | + $langs->load("reception"); |
|
84 | + return $langs->trans("NoDescription"); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns numbering example |
|
89 | + * |
|
90 | + * @return string Example |
|
91 | + */ |
|
92 | + function getExample() |
|
93 | + { |
|
94 | + global $langs; |
|
95 | + $langs->load("reception"); |
|
96 | + return $langs->trans("NoExample"); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Test if existing numbers make problems with numbering |
|
101 | + * |
|
102 | + * @return boolean false if conflit, true if ok |
|
103 | + */ |
|
104 | + function canBeActivated() |
|
105 | + { |
|
106 | + return true; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Returns next value assigned |
|
111 | + * |
|
112 | + * @param Societe $objsoc Third party object |
|
113 | + * @param Object $shipment Shipment object |
|
114 | + * @return string Value |
|
115 | + */ |
|
116 | + function getNextValue($objsoc, $shipment) |
|
117 | + { |
|
118 | + global $langs; |
|
119 | + return $langs->trans("NotAvailable"); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Returns version of the numbering model |
|
124 | + * |
|
125 | + * @return string Value |
|
126 | + */ |
|
127 | + function getVersion() |
|
128 | + { |
|
129 | + global $langs; |
|
130 | + $langs->load("admin"); |
|
131 | + |
|
132 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
133 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
134 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
135 | + if ($this->version) return $this->version; |
|
136 | + return $langs->trans("NotAvailable"); |
|
137 | + } |
|
138 | 138 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | abstract class ModelePdfReception extends CommonDocGenerator |
31 | 31 | { |
32 | - var $error=''; |
|
32 | + var $error = ''; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * @param integer $maxfilenamelength Max length of value to show |
41 | 41 | * @return array List of templates |
42 | 42 | */ |
43 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
43 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
44 | 44 | { |
45 | 45 | // phpcs:enable |
46 | 46 | global $conf; |
47 | 47 | |
48 | - $type='reception'; |
|
49 | - $liste=array(); |
|
48 | + $type = 'reception'; |
|
49 | + $liste = array(); |
|
50 | 50 | |
51 | 51 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
52 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
52 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
53 | 53 | |
54 | 54 | return $liste; |
55 | 55 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | abstract class ModelNumRefReception |
63 | 63 | { |
64 | - var $error=''; |
|
64 | + var $error = ''; |
|
65 | 65 | |
66 | 66 | /** Return if a model can be used or not |
67 | 67 | * |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |
@@ -29,109 +29,109 @@ |
||
29 | 29 | */ |
30 | 30 | class mod_reception_moonstone extends ModelNumRefReception |
31 | 31 | { |
32 | - var $version='dolibarr'; |
|
33 | - var $error = ''; |
|
34 | - var $nom = 'Moonstone'; |
|
35 | - |
|
36 | - /** |
|
37 | - * Return default description of numbering model |
|
38 | - * |
|
39 | - * @return string text description |
|
40 | - */ |
|
41 | - function info() |
|
32 | + var $version='dolibarr'; |
|
33 | + var $error = ''; |
|
34 | + var $nom = 'Moonstone'; |
|
35 | + |
|
36 | + /** |
|
37 | + * Return default description of numbering model |
|
38 | + * |
|
39 | + * @return string text description |
|
40 | + */ |
|
41 | + function info() |
|
42 | 42 | { |
43 | - global $conf,$langs; |
|
43 | + global $conf,$langs; |
|
44 | 44 | |
45 | - $langs->load("bills"); |
|
45 | + $langs->load("bills"); |
|
46 | 46 | |
47 | - $form = new Form($this->db); |
|
47 | + $form = new Form($this->db); |
|
48 | 48 | |
49 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
50 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | - $texte.= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
49 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
50 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | + $texte.= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
55 | 55 | |
56 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
57 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
58 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
59 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
56 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
57 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
58 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
59 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
60 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
61 | 61 | |
62 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>'; |
|
64 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | - $texte.= '</tr>'; |
|
66 | - $texte.= '</table>'; |
|
67 | - $texte.= '</form>'; |
|
62 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>'; |
|
64 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | + $texte.= '</tr>'; |
|
66 | + $texte.= '</table>'; |
|
67 | + $texte.= '</form>'; |
|
68 | 68 | |
69 | - return $texte; |
|
69 | + return $texte; |
|
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Return numbering example |
|
74 | - * |
|
75 | - * @return string Example |
|
76 | - */ |
|
72 | + /** |
|
73 | + * Return numbering example |
|
74 | + * |
|
75 | + * @return string Example |
|
76 | + */ |
|
77 | 77 | function getExample() |
78 | 78 | { |
79 | - global $conf,$langs,$mysoc; |
|
80 | - |
|
81 | - $old_code_client=$mysoc->code_client; |
|
82 | - $old_code_type=$mysoc->typent_code; |
|
83 | - $mysoc->code_client='CCCCCCCCCC'; |
|
84 | - $mysoc->typent_code='TTTTTTTTTT'; |
|
85 | - $numExample = $this->getNextValue($mysoc,''); |
|
86 | - $mysoc->code_client=$old_code_client; |
|
87 | - $mysoc->typent_code=$old_code_type; |
|
88 | - |
|
89 | - if (! $numExample) |
|
90 | - { |
|
91 | - $numExample = $langs->trans('NotConfigured'); |
|
92 | - } |
|
93 | - return $numExample; |
|
79 | + global $conf,$langs,$mysoc; |
|
80 | + |
|
81 | + $old_code_client=$mysoc->code_client; |
|
82 | + $old_code_type=$mysoc->typent_code; |
|
83 | + $mysoc->code_client='CCCCCCCCCC'; |
|
84 | + $mysoc->typent_code='TTTTTTTTTT'; |
|
85 | + $numExample = $this->getNextValue($mysoc,''); |
|
86 | + $mysoc->code_client=$old_code_client; |
|
87 | + $mysoc->typent_code=$old_code_type; |
|
88 | + |
|
89 | + if (! $numExample) |
|
90 | + { |
|
91 | + $numExample = $langs->trans('NotConfigured'); |
|
92 | + } |
|
93 | + return $numExample; |
|
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Return next value |
|
98 | - * |
|
99 | - * @param Societe $objsoc Third party object |
|
100 | - * @param Object $reception Reception object |
|
101 | - * @return string Value if OK, 0 if KO |
|
102 | - */ |
|
96 | + /** |
|
97 | + * Return next value |
|
98 | + * |
|
99 | + * @param Societe $objsoc Third party object |
|
100 | + * @param Object $reception Reception object |
|
101 | + * @return string Value if OK, 0 if KO |
|
102 | + */ |
|
103 | 103 | function getNextValue($objsoc,$reception) |
104 | 104 | { |
105 | - global $db,$conf; |
|
106 | - |
|
107 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
108 | - |
|
109 | - $mask=$conf->global->RECEPTION_MOONSTONE_MASK; |
|
110 | - |
|
111 | - if (! $mask) |
|
112 | - { |
|
113 | - $this->error='NotConfigured'; |
|
114 | - return 0; |
|
115 | - } |
|
116 | - |
|
117 | - $date = $reception->date_reception; |
|
118 | - |
|
119 | - $numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date); |
|
120 | - |
|
121 | - return $numFinal; |
|
122 | - } |
|
123 | - |
|
124 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
125 | - /** |
|
126 | - * Return next free value |
|
127 | - * |
|
128 | - * @param Societe $objsoc Third party object |
|
129 | - * @param Object $objforref Reception object |
|
130 | - * @return string Next free value |
|
131 | - */ |
|
132 | - function reception_get_num($objsoc,$objforref) |
|
133 | - { |
|
134 | - // phpcs:enable |
|
135 | - return $this->getNextValue($objsoc,$objforref); |
|
136 | - } |
|
105 | + global $db,$conf; |
|
106 | + |
|
107 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
108 | + |
|
109 | + $mask=$conf->global->RECEPTION_MOONSTONE_MASK; |
|
110 | + |
|
111 | + if (! $mask) |
|
112 | + { |
|
113 | + $this->error='NotConfigured'; |
|
114 | + return 0; |
|
115 | + } |
|
116 | + |
|
117 | + $date = $reception->date_reception; |
|
118 | + |
|
119 | + $numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date); |
|
120 | + |
|
121 | + return $numFinal; |
|
122 | + } |
|
123 | + |
|
124 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
|
125 | + /** |
|
126 | + * Return next free value |
|
127 | + * |
|
128 | + * @param Societe $objsoc Third party object |
|
129 | + * @param Object $objforref Reception object |
|
130 | + * @return string Next free value |
|
131 | + */ |
|
132 | + function reception_get_num($objsoc,$objforref) |
|
133 | + { |
|
134 | + // phpcs:enable |
|
135 | + return $this->getNextValue($objsoc,$objforref); |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * \brief File of class to manage reception numbering rules Moonstone |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage reception numbering rules Moonstone |
29 | 29 | */ |
30 | 30 | class mod_reception_moonstone extends ModelNumRefReception |
31 | 31 | { |
32 | - var $version='dolibarr'; |
|
32 | + var $version = 'dolibarr'; |
|
33 | 33 | var $error = ''; |
34 | 34 | var $nom = 'Moonstone'; |
35 | 35 | |
@@ -40,31 +40,31 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function info() |
42 | 42 | { |
43 | - global $conf,$langs; |
|
43 | + global $conf, $langs; |
|
44 | 44 | |
45 | 45 | $langs->load("bills"); |
46 | 46 | |
47 | 47 | $form = new Form($this->db); |
48 | 48 | |
49 | 49 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
50 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | - $texte.= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
55 | - |
|
56 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
57 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
58 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
59 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception")); |
|
60 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
61 | - |
|
62 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>'; |
|
64 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | - $texte.= '</tr>'; |
|
66 | - $texte.= '</table>'; |
|
67 | - $texte.= '</form>'; |
|
50 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
51 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
52 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
53 | + $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">'; |
|
54 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
55 | + |
|
56 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception")); |
|
57 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
58 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
59 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception")); |
|
60 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
61 | + |
|
62 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
63 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
64 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
65 | + $texte .= '</tr>'; |
|
66 | + $texte .= '</table>'; |
|
67 | + $texte .= '</form>'; |
|
68 | 68 | |
69 | 69 | return $texte; |
70 | 70 | } |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function getExample() |
78 | 78 | { |
79 | - global $conf,$langs,$mysoc; |
|
79 | + global $conf, $langs, $mysoc; |
|
80 | 80 | |
81 | - $old_code_client=$mysoc->code_client; |
|
82 | - $old_code_type=$mysoc->typent_code; |
|
83 | - $mysoc->code_client='CCCCCCCCCC'; |
|
84 | - $mysoc->typent_code='TTTTTTTTTT'; |
|
85 | - $numExample = $this->getNextValue($mysoc,''); |
|
86 | - $mysoc->code_client=$old_code_client; |
|
87 | - $mysoc->typent_code=$old_code_type; |
|
81 | + $old_code_client = $mysoc->code_client; |
|
82 | + $old_code_type = $mysoc->typent_code; |
|
83 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
84 | + $mysoc->typent_code = 'TTTTTTTTTT'; |
|
85 | + $numExample = $this->getNextValue($mysoc, ''); |
|
86 | + $mysoc->code_client = $old_code_client; |
|
87 | + $mysoc->typent_code = $old_code_type; |
|
88 | 88 | |
89 | - if (! $numExample) |
|
89 | + if (!$numExample) |
|
90 | 90 | { |
91 | 91 | $numExample = $langs->trans('NotConfigured'); |
92 | 92 | } |
@@ -100,23 +100,23 @@ discard block |
||
100 | 100 | * @param Object $reception Reception object |
101 | 101 | * @return string Value if OK, 0 if KO |
102 | 102 | */ |
103 | - function getNextValue($objsoc,$reception) |
|
103 | + function getNextValue($objsoc, $reception) |
|
104 | 104 | { |
105 | - global $db,$conf; |
|
105 | + global $db, $conf; |
|
106 | 106 | |
107 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
107 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
108 | 108 | |
109 | - $mask=$conf->global->RECEPTION_MOONSTONE_MASK; |
|
109 | + $mask = $conf->global->RECEPTION_MOONSTONE_MASK; |
|
110 | 110 | |
111 | - if (! $mask) |
|
111 | + if (!$mask) |
|
112 | 112 | { |
113 | - $this->error='NotConfigured'; |
|
113 | + $this->error = 'NotConfigured'; |
|
114 | 114 | return 0; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $date = $reception->date_reception; |
118 | 118 | |
119 | - $numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date); |
|
119 | + $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date); |
|
120 | 120 | |
121 | 121 | return $numFinal; |
122 | 122 | } |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * @param Object $objforref Reception object |
130 | 130 | * @return string Next free value |
131 | 131 | */ |
132 | - function reception_get_num($objsoc,$objforref) |
|
132 | + function reception_get_num($objsoc, $objforref) |
|
133 | 133 | { |
134 | 134 | // phpcs:enable |
135 | - return $this->getNextValue($objsoc,$objforref); |
|
135 | + return $this->getNextValue($objsoc, $objforref); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_payment_ant extends ModeleNumRefPayments |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string Error message |
|
41 | - */ |
|
42 | - public $error = ''; |
|
39 | + /** |
|
40 | + * @var string Error message |
|
41 | + */ |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Ant'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Ant'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Ant'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Ant'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -59,39 +59,39 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return string Texte descripif |
61 | 61 | */ |
62 | - function info() |
|
62 | + function info() |
|
63 | 63 | { |
64 | - global $conf, $langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | - $langs->load("bills"); |
|
66 | + $langs->load("bills"); |
|
67 | 67 | |
68 | - $form = new Form($this->db); |
|
68 | + $form = new Form($this->db); |
|
69 | 69 | |
70 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
70 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | - // Parametrage du prefix |
|
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
83 | + // Parametrage du prefix |
|
84 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte.= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte.= '</table>'; |
|
92 | + $texte.= '</form>'; |
|
93 | 93 | |
94 | - return $texte; |
|
94 | + return $texte; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,55 +101,55 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$mysoc; |
|
105 | - |
|
106 | - $old_code_client=$mysoc->code_client; |
|
107 | - $mysoc->code_client='CCCCCCCCCC'; |
|
108 | - $numExample = $this->getNextValue($mysoc,''); |
|
109 | - $mysoc->code_client=$old_code_client; |
|
110 | - |
|
111 | - if (! $numExample) |
|
112 | - { |
|
113 | - $numExample = $langs->trans('NotConfigured'); |
|
114 | - } |
|
115 | - return $numExample; |
|
104 | + global $conf,$langs,$mysoc; |
|
105 | + |
|
106 | + $old_code_client=$mysoc->code_client; |
|
107 | + $mysoc->code_client='CCCCCCCCCC'; |
|
108 | + $numExample = $this->getNextValue($mysoc,''); |
|
109 | + $mysoc->code_client=$old_code_client; |
|
110 | + |
|
111 | + if (! $numExample) |
|
112 | + { |
|
113 | + $numExample = $langs->trans('NotConfigured'); |
|
114 | + } |
|
115 | + return $numExample; |
|
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Return next free value |
|
120 | - * |
|
121 | - * @param Societe $objsoc Object thirdparty |
|
122 | - * @param Object $object Object we need next value for |
|
123 | - * @return string Value if KO, <0 if KO |
|
124 | - */ |
|
118 | + /** |
|
119 | + * Return next free value |
|
120 | + * |
|
121 | + * @param Societe $objsoc Object thirdparty |
|
122 | + * @param Object $object Object we need next value for |
|
123 | + * @return string Value if KO, <0 if KO |
|
124 | + */ |
|
125 | 125 | function getNextValue($objsoc,$object) |
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db,$conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | - // We get cursor rule |
|
132 | - $mask=$conf->global->PAYMENT_ANT_MASK; |
|
131 | + // We get cursor rule |
|
132 | + $mask=$conf->global->PAYMENT_ANT_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
135 | - { |
|
136 | - $this->error='NotConfigured'; |
|
137 | - return 0; |
|
138 | - } |
|
134 | + if (! $mask) |
|
135 | + { |
|
136 | + $this->error='NotConfigured'; |
|
137 | + return 0; |
|
138 | + } |
|
139 | 139 | |
140 | - $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
140 | + $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
141 | 141 | |
142 | - return $numFinal; |
|
143 | - } |
|
142 | + return $numFinal; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | 146 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
147 | - /** |
|
148 | - * Return next free value |
|
149 | - * |
|
150 | - * @param Societe $objsoc Object third party |
|
151 | - * @param string $objforref Object for number to search |
|
152 | - * @return string Next free value |
|
147 | + /** |
|
148 | + * Return next free value |
|
149 | + * |
|
150 | + * @param Societe $objsoc Object third party |
|
151 | + * @param string $objforref Object for number to search |
|
152 | + * @return string Next free value |
|
153 | 153 | */ |
154 | 154 | function commande_get_num($objsoc,$objforref) |
155 | 155 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Ant |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/payment/modules_payment.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error message |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Ant'; |
|
49 | + public $nom = 'Ant'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Ant'; |
|
54 | + public $name = 'Ant'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $form = new Form($this->db); |
69 | 69 | |
70 | 70 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | - |
|
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
71 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte .= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">'; |
|
75 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
76 | + |
|
77 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
78 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | 83 | // Parametrage du prefix |
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>'; |
|
84 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte .= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte .= '</table>'; |
|
92 | + $texte .= '</form>'; |
|
93 | 93 | |
94 | 94 | return $texte; |
95 | 95 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$mysoc; |
|
104 | + global $conf, $langs, $mysoc; |
|
105 | 105 | |
106 | - $old_code_client=$mysoc->code_client; |
|
107 | - $mysoc->code_client='CCCCCCCCCC'; |
|
108 | - $numExample = $this->getNextValue($mysoc,''); |
|
109 | - $mysoc->code_client=$old_code_client; |
|
106 | + $old_code_client = $mysoc->code_client; |
|
107 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
108 | + $numExample = $this->getNextValue($mysoc, ''); |
|
109 | + $mysoc->code_client = $old_code_client; |
|
110 | 110 | |
111 | - if (! $numExample) |
|
111 | + if (!$numExample) |
|
112 | 112 | { |
113 | 113 | $numExample = $langs->trans('NotConfigured'); |
114 | 114 | } |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | * @param Object $object Object we need next value for |
123 | 123 | * @return string Value if KO, <0 if KO |
124 | 124 | */ |
125 | - function getNextValue($objsoc,$object) |
|
125 | + function getNextValue($objsoc, $object) |
|
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db, $conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | 131 | // We get cursor rule |
132 | - $mask=$conf->global->PAYMENT_ANT_MASK; |
|
132 | + $mask = $conf->global->PAYMENT_ANT_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
134 | + if (!$mask) |
|
135 | 135 | { |
136 | - $this->error='NotConfigured'; |
|
136 | + $this->error = 'NotConfigured'; |
|
137 | 137 | return 0; |
138 | 138 | } |
139 | 139 | |
140 | - $numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->datepaye); |
|
140 | + $numFinal = get_next_value($db, $mask, 'paiement', 'ref', '', $objsoc, $object->datepaye); |
|
141 | 141 | |
142 | 142 | return $numFinal; |
143 | 143 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param string $objforref Object for number to search |
152 | 152 | * @return string Next free value |
153 | 153 | */ |
154 | - function commande_get_num($objsoc,$objforref) |
|
154 | + function commande_get_num($objsoc, $objforref) |
|
155 | 155 | { |
156 | 156 | // phpcs:enable |
157 | - return $this->getNextValue($objsoc,$objforref); |
|
157 | + return $this->getNextValue($objsoc, $objforref); |
|
158 | 158 | } |
159 | 159 | } |
@@ -29,30 +29,30 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class mod_payment_cicada extends ModeleNumRefPayments |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | - public $prefix='PAY'; |
|
38 | + public $prefix='PAY'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string Nom du modele |
|
47 | - * @deprecated |
|
48 | - * @see name |
|
49 | - */ |
|
50 | - public $nom='Cicada'; |
|
45 | + /** |
|
46 | + * @var string Nom du modele |
|
47 | + * @deprecated |
|
48 | + * @see name |
|
49 | + */ |
|
50 | + public $nom='Cicada'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string model name |
|
54 | - */ |
|
55 | - public $name='Cicada'; |
|
52 | + /** |
|
53 | + * @var string model name |
|
54 | + */ |
|
55 | + public $name='Cicada'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -62,110 +62,110 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function info() |
64 | 64 | { |
65 | - global $langs; |
|
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + global $langs; |
|
66 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Renvoi un exemple de numerotation |
|
72 | - * |
|
73 | - * @return string Example |
|
74 | - */ |
|
75 | - function getExample() |
|
76 | - { |
|
77 | - return $this->prefix."0501-0001"; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | - * |
|
85 | - * @return boolean false si conflit, true si ok |
|
86 | - */ |
|
87 | - function canBeActivated() |
|
88 | - { |
|
89 | - global $conf,$langs,$db; |
|
90 | - |
|
91 | - $payyymm=''; $max=''; |
|
92 | - |
|
93 | - $posindice=9; |
|
94 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
98 | - |
|
99 | - $resql=$db->query($sql); |
|
100 | - if ($resql) |
|
101 | - { |
|
102 | - $row = $db->fetch_row($resql); |
|
103 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | - } |
|
105 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | - { |
|
107 | - $langs->load("errors"); |
|
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Return next free value |
|
117 | - * |
|
118 | - * @param Societe $objsoc Object thirdparty |
|
119 | - * @param Object $object Object we need next value for |
|
120 | - * @return string Value if KO, <0 if KO |
|
121 | - */ |
|
122 | - function getNextValue($objsoc,$object) |
|
123 | - { |
|
124 | - global $db,$conf; |
|
125 | - |
|
126 | - // D'abord on recupere la valeur max |
|
127 | - $posindice=9; |
|
128 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | - |
|
133 | - $resql=$db->query($sql); |
|
134 | - if ($resql) |
|
135 | - { |
|
136 | - $obj = $db->fetch_object($resql); |
|
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
141 | - { |
|
142 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | - return -1; |
|
144 | - } |
|
145 | - |
|
146 | - //$date=time(); |
|
147 | - $date=$object->datepaye; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
149 | - |
|
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | - |
|
153 | - dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | - return $this->prefix.$yymm."-".$num; |
|
155 | - } |
|
70 | + /** |
|
71 | + * Renvoi un exemple de numerotation |
|
72 | + * |
|
73 | + * @return string Example |
|
74 | + */ |
|
75 | + function getExample() |
|
76 | + { |
|
77 | + return $this->prefix."0501-0001"; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | + * |
|
85 | + * @return boolean false si conflit, true si ok |
|
86 | + */ |
|
87 | + function canBeActivated() |
|
88 | + { |
|
89 | + global $conf,$langs,$db; |
|
90 | + |
|
91 | + $payyymm=''; $max=''; |
|
92 | + |
|
93 | + $posindice=9; |
|
94 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql.= " AND entity = ".$conf->entity; |
|
98 | + |
|
99 | + $resql=$db->query($sql); |
|
100 | + if ($resql) |
|
101 | + { |
|
102 | + $row = $db->fetch_row($resql); |
|
103 | + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + } |
|
105 | + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
106 | + { |
|
107 | + $langs->load("errors"); |
|
108 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Return next free value |
|
117 | + * |
|
118 | + * @param Societe $objsoc Object thirdparty |
|
119 | + * @param Object $object Object we need next value for |
|
120 | + * @return string Value if KO, <0 if KO |
|
121 | + */ |
|
122 | + function getNextValue($objsoc,$object) |
|
123 | + { |
|
124 | + global $db,$conf; |
|
125 | + |
|
126 | + // D'abord on recupere la valeur max |
|
127 | + $posindice=9; |
|
128 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql.= " AND entity = ".$conf->entity; |
|
132 | + |
|
133 | + $resql=$db->query($sql); |
|
134 | + if ($resql) |
|
135 | + { |
|
136 | + $obj = $db->fetch_object($resql); |
|
137 | + if ($obj) $max = intval($obj->max); |
|
138 | + else $max=0; |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
142 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
143 | + return -1; |
|
144 | + } |
|
145 | + |
|
146 | + //$date=time(); |
|
147 | + $date=$object->datepaye; |
|
148 | + $yymm = strftime("%y%m",$date); |
|
149 | + |
|
150 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | + else $num = sprintf("%04s",$max+1); |
|
152 | + |
|
153 | + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
|
154 | + return $this->prefix.$yymm."-".$num; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
159 | - /** |
|
160 | - * Return next free value |
|
161 | - * |
|
162 | - * @param Societe $objsoc Object third party |
|
163 | - * @param string $objforref Object for number to search |
|
164 | - * @return string Next free value |
|
165 | - */ |
|
166 | - function payment_get_num($objsoc,$objforref) |
|
167 | - { |
|
159 | + /** |
|
160 | + * Return next free value |
|
161 | + * |
|
162 | + * @param Societe $objsoc Object third party |
|
163 | + * @param string $objforref Object for number to search |
|
164 | + * @return string Next free value |
|
165 | + */ |
|
166 | + function payment_get_num($objsoc,$objforref) |
|
167 | + { |
|
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
170 | - } |
|
169 | + return $this->getNextValue($objsoc,$objforref); |
|
170 | + } |
|
171 | 171 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Cicada |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/payment/modules_payment.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage customer payment numbering rules Cicada |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | - public $prefix='PAY'; |
|
38 | + public $prefix = 'PAY'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string Nom du modele |
47 | 47 | * @deprecated |
48 | 48 | * @see name |
49 | 49 | */ |
50 | - public $nom='Cicada'; |
|
50 | + public $nom = 'Cicada'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var string model name |
54 | 54 | */ |
55 | - public $name='Cicada'; |
|
55 | + public $name = 'Cicada'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | function info() |
64 | 64 | { |
65 | 65 | global $langs; |
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
66 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function canBeActivated() |
88 | 88 | { |
89 | - global $conf,$langs,$db; |
|
89 | + global $conf, $langs, $db; |
|
90 | 90 | |
91 | - $payyymm=''; $max=''; |
|
91 | + $payyymm = ''; $max = ''; |
|
92 | 92 | |
93 | - $posindice=9; |
|
93 | + $posindice = 9; |
|
94 | 94 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
95 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
96 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql .= " AND entity = ".$conf->entity; |
|
98 | 98 | |
99 | - $resql=$db->query($sql); |
|
99 | + $resql = $db->query($sql); |
|
100 | 100 | if ($resql) |
101 | 101 | { |
102 | 102 | $row = $db->fetch_row($resql); |
103 | - if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } |
|
103 | + if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
104 | 104 | } |
105 | - if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) |
|
105 | + if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) |
|
106 | 106 | { |
107 | 107 | $langs->load("errors"); |
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
108 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | * @param Object $object Object we need next value for |
120 | 120 | * @return string Value if KO, <0 if KO |
121 | 121 | */ |
122 | - function getNextValue($objsoc,$object) |
|
122 | + function getNextValue($objsoc, $object) |
|
123 | 123 | { |
124 | - global $db,$conf; |
|
124 | + global $db, $conf; |
|
125 | 125 | |
126 | 126 | // D'abord on recupere la valeur max |
127 | - $posindice=9; |
|
127 | + $posindice = 9; |
|
128 | 128 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
129 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiement"; |
|
130 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql .= " AND entity = ".$conf->entity; |
|
132 | 132 | |
133 | - $resql=$db->query($sql); |
|
133 | + $resql = $db->query($sql); |
|
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | 137 | if ($obj) $max = intval($obj->max); |
138 | - else $max=0; |
|
138 | + else $max = 0; |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | //$date=time(); |
147 | - $date=$object->datepaye; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
147 | + $date = $object->datepaye; |
|
148 | + $yymm = strftime("%y%m", $date); |
|
149 | 149 | |
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
150 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | + else $num = sprintf("%04s", $max + 1); |
|
152 | 152 | |
153 | 153 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
154 | 154 | return $this->prefix.$yymm."-".$num; |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param string $objforref Object for number to search |
164 | 164 | * @return string Next free value |
165 | 165 | */ |
166 | - function payment_get_num($objsoc,$objforref) |
|
166 | + function payment_get_num($objsoc, $objforref) |
|
167 | 167 | { |
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
169 | + return $this->getNextValue($objsoc, $objforref); |
|
170 | 170 | } |
171 | 171 | } |
@@ -134,10 +134,12 @@ discard block |
||
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max=0; |
|
141 | + } |
|
142 | + } else |
|
141 | 143 | { |
142 | 144 | dol_syslog(__METHOD__, LOG_DEBUG); |
143 | 145 | return -1; |
@@ -147,8 +149,13 @@ discard block |
||
147 | 149 | $date=$object->datepaye; |
148 | 150 | $yymm = strftime("%y%m",$date); |
149 | 151 | |
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s",$max+1); |
|
152 | + if ($max >= (pow(10, 4) - 1)) { |
|
153 | + $num=$max+1; |
|
154 | + } |
|
155 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
156 | + else { |
|
157 | + $num = sprintf("%04s",$max+1); |
|
158 | + } |
|
152 | 159 | |
153 | 160 | dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); |
154 | 161 | return $this->prefix.$yymm."-".$num; |
@@ -23,82 +23,82 @@ |
||
23 | 23 | |
24 | 24 | abstract class ModeleNumRefPayments |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string Error code (or message) |
|
28 | - */ |
|
29 | - public $error=''; |
|
26 | + /** |
|
27 | + * @var string Error code (or message) |
|
28 | + */ |
|
29 | + public $error=''; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return if a module can be used or not |
|
33 | - * |
|
34 | - * @return boolean true if module can be used |
|
35 | - */ |
|
36 | - function isEnabled() |
|
37 | - { |
|
38 | - return true; |
|
39 | - } |
|
31 | + /** |
|
32 | + * Return if a module can be used or not |
|
33 | + * |
|
34 | + * @return boolean true if module can be used |
|
35 | + */ |
|
36 | + function isEnabled() |
|
37 | + { |
|
38 | + return true; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Return the default description of numbering module |
|
43 | - * |
|
44 | - * @return string Texte descripif |
|
45 | - */ |
|
46 | - function info() |
|
47 | - { |
|
48 | - global $langs; |
|
49 | - $langs->load("bills"); |
|
50 | - return $langs->trans("NoDescription"); |
|
51 | - } |
|
41 | + /** |
|
42 | + * Return the default description of numbering module |
|
43 | + * |
|
44 | + * @return string Texte descripif |
|
45 | + */ |
|
46 | + function info() |
|
47 | + { |
|
48 | + global $langs; |
|
49 | + $langs->load("bills"); |
|
50 | + return $langs->trans("NoDescription"); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Return numbering example |
|
55 | - * |
|
56 | - * @return string Example |
|
57 | - */ |
|
58 | - function getExample() |
|
59 | - { |
|
60 | - global $langs; |
|
61 | - $langs->load("bills"); |
|
62 | - return $langs->trans("NoExample"); |
|
63 | - } |
|
53 | + /** |
|
54 | + * Return numbering example |
|
55 | + * |
|
56 | + * @return string Example |
|
57 | + */ |
|
58 | + function getExample() |
|
59 | + { |
|
60 | + global $langs; |
|
61 | + $langs->load("bills"); |
|
62 | + return $langs->trans("NoExample"); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
67 | - * |
|
68 | - * @return boolean false si conflit, true si ok |
|
69 | - */ |
|
70 | - function canBeActivated() |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
65 | + /** |
|
66 | + * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. |
|
67 | + * |
|
68 | + * @return boolean false si conflit, true si ok |
|
69 | + */ |
|
70 | + function canBeActivated() |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Returns the next value |
|
77 | - * |
|
78 | - * @param Societe $objsoc Object thirdparty |
|
79 | - * @param Object $object Object we need next value for |
|
80 | - * @return string Valeur |
|
81 | - */ |
|
82 | - function getNextValue($objsoc,$object) |
|
83 | - { |
|
84 | - global $langs; |
|
85 | - return $langs->trans("NotAvailable"); |
|
86 | - } |
|
75 | + /** |
|
76 | + * Returns the next value |
|
77 | + * |
|
78 | + * @param Societe $objsoc Object thirdparty |
|
79 | + * @param Object $object Object we need next value for |
|
80 | + * @return string Valeur |
|
81 | + */ |
|
82 | + function getNextValue($objsoc,$object) |
|
83 | + { |
|
84 | + global $langs; |
|
85 | + return $langs->trans("NotAvailable"); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Returns the module numbering version |
|
90 | - * |
|
91 | - * @return string Value |
|
92 | - */ |
|
93 | - function getVersion() |
|
94 | - { |
|
95 | - global $langs; |
|
96 | - $langs->load("admin"); |
|
88 | + /** |
|
89 | + * Returns the module numbering version |
|
90 | + * |
|
91 | + * @return string Value |
|
92 | + */ |
|
93 | + function getVersion() |
|
94 | + { |
|
95 | + global $langs; |
|
96 | + $langs->load("admin"); |
|
97 | 97 | |
98 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
99 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
100 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
101 | - if ($this->version) return $this->version; |
|
102 | - return $langs->trans("NotAvailable"); |
|
103 | - } |
|
98 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
99 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
100 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
101 | + if ($this->version) return $this->version; |
|
102 | + return $langs->trans("NotAvailable"); |
|
103 | + } |
|
104 | 104 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var string Error code (or message) |
28 | 28 | */ |
29 | - public $error=''; |
|
29 | + public $error = ''; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Return if a module can be used or not |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param Object $object Object we need next value for |
80 | 80 | * @return string Valeur |
81 | 81 | */ |
82 | - function getNextValue($objsoc,$object) |
|
82 | + function getNextValue($objsoc, $object) |
|
83 | 83 | { |
84 | 84 | global $langs; |
85 | 85 | return $langs->trans("NotAvailable"); |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |