@@ -33,49 +33,49 @@ discard block |
||
33 | 33 | class Documents extends DolibarrApi |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
38 | - */ |
|
39 | - static $DOCUMENT_FIELDS = array( |
|
40 | - 'modulepart' |
|
41 | - ); |
|
42 | - |
|
43 | - /** |
|
44 | - * Constructor |
|
45 | - */ |
|
46 | - function __construct() |
|
47 | - { |
|
48 | - global $db; |
|
49 | - $this->db = $db; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
55 | - * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
56 | - * |
|
57 | - * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
58 | - * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
59 | - * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
60 | - * Also, note that setting this to 1 nead write access on object. |
|
61 | - * @return array List of documents |
|
62 | - * |
|
63 | - * @throws 500 |
|
64 | - * @throws 501 |
|
65 | - * @throws 400 |
|
66 | - * @throws 401 |
|
67 | - * @throws 200 |
|
68 | - */ |
|
69 | - public function index($module_part, $original_file='', $regeneratedoc=0) |
|
70 | - { |
|
36 | + /** |
|
37 | + * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
38 | + */ |
|
39 | + static $DOCUMENT_FIELDS = array( |
|
40 | + 'modulepart' |
|
41 | + ); |
|
42 | + |
|
43 | + /** |
|
44 | + * Constructor |
|
45 | + */ |
|
46 | + function __construct() |
|
47 | + { |
|
48 | + global $db; |
|
49 | + $this->db = $db; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
55 | + * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
56 | + * |
|
57 | + * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
58 | + * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
59 | + * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
60 | + * Also, note that setting this to 1 nead write access on object. |
|
61 | + * @return array List of documents |
|
62 | + * |
|
63 | + * @throws 500 |
|
64 | + * @throws 501 |
|
65 | + * @throws 400 |
|
66 | + * @throws 401 |
|
67 | + * @throws 200 |
|
68 | + */ |
|
69 | + public function index($module_part, $original_file='', $regeneratedoc=0) |
|
70 | + { |
|
71 | 71 | global $conf; |
72 | 72 | |
73 | 73 | if (empty($module_part)) { |
74 | - throw new RestException(400, 'bad value for parameter modulepart'); |
|
74 | + throw new RestException(400, 'bad value for parameter modulepart'); |
|
75 | + } |
|
76 | + if (empty($original_file)) { |
|
77 | + throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
75 | 78 | } |
76 | - if (empty($original_file)) { |
|
77 | - throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
78 | - } |
|
79 | 79 | |
80 | 80 | //--- Finds and returns the document |
81 | 81 | $entity=$conf->entity; |
@@ -87,94 +87,94 @@ discard block |
||
87 | 87 | |
88 | 88 | if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) |
89 | 89 | { |
90 | - throw new RestException(401); |
|
90 | + throw new RestException(401); |
|
91 | + } |
|
92 | + if (!$accessallowed) { |
|
93 | + throw new RestException(401); |
|
94 | + } |
|
95 | + |
|
96 | + // --- Generates the document |
|
97 | + if ($regeneratedoc) |
|
98 | + { |
|
99 | + $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
100 | + $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
101 | + $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
102 | + |
|
103 | + if ($module_part == 'facture' || $module_part == 'invoice') |
|
104 | + { |
|
105 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
106 | + $this->invoice = new Facture($this->db); |
|
107 | + $result = $this->invoice->fetch(0, $ref); |
|
108 | + if( ! $result ) { |
|
109 | + throw new RestException(404, 'Invoice not found'); |
|
110 | + } |
|
111 | + $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
112 | + if( $result <= 0 ) { |
|
113 | + throw new RestException(500, 'Error generating document'); |
|
114 | + } |
|
115 | + } |
|
91 | 116 | } |
92 | - if (!$accessallowed) { |
|
93 | - throw new RestException(401); |
|
94 | - } |
|
95 | - |
|
96 | - // --- Generates the document |
|
97 | - if ($regeneratedoc) |
|
98 | - { |
|
99 | - $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
100 | - $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
101 | - $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
102 | - |
|
103 | - if ($module_part == 'facture' || $module_part == 'invoice') |
|
104 | - { |
|
105 | - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
106 | - $this->invoice = new Facture($this->db); |
|
107 | - $result = $this->invoice->fetch(0, $ref); |
|
108 | - if( ! $result ) { |
|
109 | - throw new RestException(404, 'Invoice not found'); |
|
110 | - } |
|
111 | - $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
112 | - if( $result <= 0 ) { |
|
113 | - throw new RestException(500, 'Error generating document'); |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
117 | 117 | |
118 | 118 | $filename = basename($original_file); |
119 | 119 | $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset |
120 | 120 | |
121 | 121 | if (! file_exists($original_file_osencoded)) |
122 | 122 | { |
123 | - throw new RestException(404, 'File not found'); |
|
123 | + throw new RestException(404, 'File not found'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $file_content=file_get_contents($original_file_osencoded); |
127 | - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Return a document. |
|
133 | - * |
|
134 | - * @param int $id ID of document |
|
135 | - * @return array Array with data of file |
|
136 | - * |
|
137 | - * @throws RestException |
|
138 | - */ |
|
139 | - /* |
|
127 | + return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Return a document. |
|
133 | + * |
|
134 | + * @param int $id ID of document |
|
135 | + * @return array Array with data of file |
|
136 | + * |
|
137 | + * @throws RestException |
|
138 | + */ |
|
139 | + /* |
|
140 | 140 | public function get($id) { |
141 | 141 | return array('note'=>'xxx'); |
142 | 142 | }*/ |
143 | 143 | |
144 | 144 | |
145 | - /** |
|
146 | - * Push a file. |
|
147 | - * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
148 | - * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
149 | - * |
|
150 | - * @param string $filename Name of file to create ('FA1705-0123') |
|
151 | - * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
152 | - * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
153 | - * @param string $subdir Subdirectory (Only if ref not provided) |
|
154 | - * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
155 | - * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
156 | - * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
157 | - * @return bool State of copy |
|
158 | - * @throws RestException |
|
159 | - */ |
|
160 | - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
161 | - { |
|
162 | - global $db, $conf; |
|
163 | - |
|
164 | - /*var_dump($modulepart); |
|
145 | + /** |
|
146 | + * Push a file. |
|
147 | + * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
148 | + * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
149 | + * |
|
150 | + * @param string $filename Name of file to create ('FA1705-0123') |
|
151 | + * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
152 | + * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
153 | + * @param string $subdir Subdirectory (Only if ref not provided) |
|
154 | + * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
155 | + * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
156 | + * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
157 | + * @return bool State of copy |
|
158 | + * @throws RestException |
|
159 | + */ |
|
160 | + public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
161 | + { |
|
162 | + global $db, $conf; |
|
163 | + |
|
164 | + /*var_dump($modulepart); |
|
165 | 165 | var_dump($filename); |
166 | 166 | var_dump($filecontent); |
167 | 167 | exit;*/ |
168 | 168 | |
169 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
169 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
170 | 170 | |
171 | - if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
172 | - throw new RestException(401); |
|
173 | - } |
|
171 | + if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
172 | + throw new RestException(401); |
|
173 | + } |
|
174 | 174 | |
175 | - $newfilecontent = ''; |
|
176 | - if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
177 | - if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
175 | + $newfilecontent = ''; |
|
176 | + if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
177 | + if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
178 | 178 | |
179 | 179 | $original_file = dol_sanitizeFileName($filename); |
180 | 180 | |
@@ -183,37 +183,37 @@ discard block |
||
183 | 183 | $entity = $user->entity; |
184 | 184 | if ($ref) |
185 | 185 | { |
186 | - if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
187 | - { |
|
188 | - $modulepart='facture'; |
|
189 | - $object=new Facture($db); |
|
190 | - $result = $object->fetch('', $ref); |
|
191 | - } |
|
192 | - |
|
193 | - if (! ($object->id > 0)) |
|
194 | - { |
|
195 | - throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
196 | - } |
|
197 | - |
|
198 | - $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
199 | - $upload_dir = $tmp['original_file']; |
|
200 | - |
|
201 | - if (empty($upload_dir) || $upload_dir == '/') |
|
202 | - { |
|
203 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
204 | - } |
|
186 | + if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
187 | + { |
|
188 | + $modulepart='facture'; |
|
189 | + $object=new Facture($db); |
|
190 | + $result = $object->fetch('', $ref); |
|
191 | + } |
|
192 | + |
|
193 | + if (! ($object->id > 0)) |
|
194 | + { |
|
195 | + throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
196 | + } |
|
197 | + |
|
198 | + $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
199 | + $upload_dir = $tmp['original_file']; |
|
200 | + |
|
201 | + if (empty($upload_dir) || $upload_dir == '/') |
|
202 | + { |
|
203 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
204 | + } |
|
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
208 | - if ($modulepart == 'invoice') $modulepart ='facture'; |
|
208 | + if ($modulepart == 'invoice') $modulepart ='facture'; |
|
209 | 209 | |
210 | - $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
211 | - $upload_dir = $tmp['original_file']; |
|
210 | + $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
211 | + $upload_dir = $tmp['original_file']; |
|
212 | 212 | |
213 | - if (empty($upload_dir) || $upload_dir == '/') |
|
214 | - { |
|
215 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
216 | - } |
|
213 | + if (empty($upload_dir) || $upload_dir == '/') |
|
214 | + { |
|
215 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,46 +223,46 @@ discard block |
||
223 | 223 | $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; |
224 | 224 | dol_delete_file($destfiletmp); |
225 | 225 | |
226 | - if (!dol_is_dir($upload_dir)) { |
|
227 | - throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
228 | - } |
|
229 | - |
|
230 | - if (! $overwriteifexists && dol_is_file($destfile)) |
|
231 | - { |
|
232 | - throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
233 | - } |
|
234 | - |
|
235 | - $fhandle = @fopen($destfiletmp, 'w'); |
|
236 | - if ($fhandle) |
|
237 | - { |
|
238 | - $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
239 | - fclose($fhandle); |
|
240 | - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
241 | - } |
|
242 | - else |
|
243 | - { |
|
244 | - throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
245 | - } |
|
246 | - |
|
247 | - $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
248 | - |
|
249 | - return $result; |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Validate fields before create or update object |
|
254 | - * |
|
255 | - * @param array $data Array with data to verify |
|
256 | - * @return array |
|
257 | - * @throws RestException |
|
258 | - */ |
|
259 | - function _validate_file($data) { |
|
260 | - $result = array(); |
|
261 | - foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
262 | - if (!isset($data[$field])) |
|
263 | - throw new RestException(400, "$field field missing"); |
|
264 | - $result[$field] = $data[$field]; |
|
265 | - } |
|
266 | - return $result; |
|
267 | - } |
|
226 | + if (!dol_is_dir($upload_dir)) { |
|
227 | + throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
228 | + } |
|
229 | + |
|
230 | + if (! $overwriteifexists && dol_is_file($destfile)) |
|
231 | + { |
|
232 | + throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
233 | + } |
|
234 | + |
|
235 | + $fhandle = @fopen($destfiletmp, 'w'); |
|
236 | + if ($fhandle) |
|
237 | + { |
|
238 | + $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
239 | + fclose($fhandle); |
|
240 | + @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
245 | + } |
|
246 | + |
|
247 | + $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
248 | + |
|
249 | + return $result; |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Validate fields before create or update object |
|
254 | + * |
|
255 | + * @param array $data Array with data to verify |
|
256 | + * @return array |
|
257 | + * @throws RestException |
|
258 | + */ |
|
259 | + function _validate_file($data) { |
|
260 | + $result = array(); |
|
261 | + foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
262 | + if (!isset($data[$field])) |
|
263 | + throw new RestException(400, "$field field missing"); |
|
264 | + $result[$field] = $data[$field]; |
|
265 | + } |
|
266 | + return $result; |
|
267 | + } |
|
268 | 268 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @throws 401 |
67 | 67 | * @throws 200 |
68 | 68 | */ |
69 | - public function index($module_part, $original_file='', $regeneratedoc=0) |
|
69 | + public function index($module_part, $original_file = '', $regeneratedoc = 0) |
|
70 | 70 | { |
71 | 71 | global $conf; |
72 | 72 | |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | //--- Finds and returns the document |
81 | - $entity=$conf->entity; |
|
81 | + $entity = $conf->entity; |
|
82 | 82 | |
83 | 83 | $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', ($regeneratedoc ? 'write' : 'read')); |
84 | 84 | $accessallowed = $check_access['accessallowed']; |
85 | 85 | $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; |
86 | 86 | $original_file = $check_access['original_file']; |
87 | 87 | |
88 | - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) |
|
88 | + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) |
|
89 | 89 | { |
90 | 90 | throw new RestException(401); |
91 | 91 | } |
@@ -105,26 +105,26 @@ discard block |
||
105 | 105 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
106 | 106 | $this->invoice = new Facture($this->db); |
107 | 107 | $result = $this->invoice->fetch(0, $ref); |
108 | - if( ! $result ) { |
|
108 | + if (!$result) { |
|
109 | 109 | throw new RestException(404, 'Invoice not found'); |
110 | 110 | } |
111 | 111 | $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
112 | - if( $result <= 0 ) { |
|
112 | + if ($result <= 0) { |
|
113 | 113 | throw new RestException(500, 'Error generating document'); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | $filename = basename($original_file); |
119 | - $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset |
|
119 | + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset |
|
120 | 120 | |
121 | - if (! file_exists($original_file_osencoded)) |
|
121 | + if (!file_exists($original_file_osencoded)) |
|
122 | 122 | { |
123 | 123 | throw new RestException(404, 'File not found'); |
124 | 124 | } |
125 | 125 | |
126 | - $file_content=file_get_contents($original_file_osencoded); |
|
127 | - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
126 | + $file_content = file_get_contents($original_file_osencoded); |
|
127 | + return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return bool State of copy |
158 | 158 | * @throws RestException |
159 | 159 | */ |
160 | - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
160 | + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) |
|
161 | 161 | { |
162 | 162 | global $db, $conf; |
163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | var_dump($filecontent); |
167 | 167 | exit;*/ |
168 | 168 | |
169 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
169 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
170 | 170 | |
171 | 171 | if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
172 | 172 | throw new RestException(401); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | { |
186 | 186 | if ($modulepart == 'facture' || $modulepart == 'invoice') |
187 | 187 | { |
188 | - $modulepart='facture'; |
|
189 | - $object=new Facture($db); |
|
188 | + $modulepart = 'facture'; |
|
189 | + $object = new Facture($db); |
|
190 | 190 | $result = $object->fetch('', $ref); |
191 | 191 | } |
192 | 192 | |
193 | - if (! ($object->id > 0)) |
|
193 | + if (!($object->id > 0)) |
|
194 | 194 | { |
195 | 195 | throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
196 | 196 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
208 | - if ($modulepart == 'invoice') $modulepart ='facture'; |
|
208 | + if ($modulepart == 'invoice') $modulepart = 'facture'; |
|
209 | 209 | |
210 | 210 | $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
211 | 211 | $upload_dir = $tmp['original_file']; |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | |
220 | 220 | $upload_dir = dol_sanitizePathName($upload_dir); |
221 | 221 | |
222 | - $destfile = $upload_dir . '/' . $original_file; |
|
223 | - $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; |
|
222 | + $destfile = $upload_dir.'/'.$original_file; |
|
223 | + $destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file; |
|
224 | 224 | dol_delete_file($destfiletmp); |
225 | 225 | |
226 | 226 | if (!dol_is_dir($upload_dir)) { |
227 | - throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
227 | + throw new RestException(401, 'Directory not exists : '.$upload_dir); |
|
228 | 228 | } |
229 | 229 | |
230 | - if (! $overwriteifexists && dol_is_file($destfile)) |
|
230 | + if (!$overwriteifexists && dol_is_file($destfile)) |
|
231 | 231 | { |
232 | 232 | throw new RestException(500, "File with name '".$original_file."' already exists."); |
233 | 233 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | require '../../main.inc.php'; |
30 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
31 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
33 | 33 | |
34 | 34 | // Langs |
35 | 35 | $langs->load("compta"); |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | if ($user->societe_id > 0) |
46 | 46 | accessforbidden(); |
47 | -if (! $user->rights->accounting->bind->write) |
|
47 | +if (!$user->rights->accounting->bind->write) |
|
48 | 48 | accessforbidden(); |
49 | 49 | |
50 | 50 | // Filter |
51 | -$year = GETPOST("year",'int'); |
|
51 | +$year = GETPOST("year", 'int'); |
|
52 | 52 | if ($year == 0) { |
53 | 53 | $year_current = strftime("%Y", time()); |
54 | 54 | $year_start = $year_current; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // Validate History |
61 | -$action = GETPOST('action','aZ09'); |
|
61 | +$action = GETPOST('action', 'aZ09'); |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | $db->begin(); |
73 | 73 | |
74 | 74 | // First clean corrupted data |
75 | - $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
75 | + $sqlclean = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; |
|
76 | 76 | $sqlclean .= " SET fk_code_ventilation = 0"; |
77 | 77 | $sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN '; |
78 | 78 | $sqlclean .= ' (SELECT accnt.rowid '; |
79 | - $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; |
|
80 | - $sqlclean .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; |
|
81 | - $sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; |
|
79 | + $sqlclean .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; |
|
80 | + $sqlclean .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; |
|
81 | + $sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.')'; |
|
82 | 82 | $resql = $db->query($sqlclean); |
83 | 83 | |
84 | 84 | // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind |
85 | 85 | if ($db->type == 'pgsql') { |
86 | - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; |
|
86 | + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet"; |
|
87 | 87 | $sql1 .= " SET fk_code_ventilation = accnt.rowid"; |
88 | - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; |
|
89 | - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; |
|
88 | + $sql1 .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; |
|
89 | + $sql1 .= " WHERE ".MAIN_DB_PREFIX."facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS; |
|
90 | 90 | $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; |
91 | - $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; |
|
91 | + $sql1 .= " AND ".MAIN_DB_PREFIX."facturedet.fk_code_ventilation = 0"; |
|
92 | 92 | } else { |
93 | - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; |
|
93 | + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; |
|
94 | 94 | $sql1 .= " SET fk_code_ventilation = accnt.rowid"; |
95 | - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; |
|
95 | + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS; |
|
96 | 96 | $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; |
97 | 97 | $sql1 .= " AND fd.fk_code_ventilation = 0"; |
98 | 98 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | dol_syslog('htdocs/accountancy/customer/index.php'); |
101 | 101 | |
102 | 102 | $resql1 = $db->query($sql1); |
103 | - if (! $resql1) { |
|
104 | - $error ++; |
|
103 | + if (!$resql1) { |
|
104 | + $error++; |
|
105 | 105 | $db->rollback(); |
106 | 106 | setEventMessages($db->lasterror(), null, 'errors'); |
107 | 107 | } else { |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | $db->begin(); |
114 | 114 | |
115 | 115 | // Now clean |
116 | - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
117 | - $sql1.= " SET fk_code_ventilation = 0"; |
|
118 | - $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; |
|
119 | - $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; |
|
120 | - $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; |
|
121 | - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; |
|
122 | - $sql1.=")"; |
|
116 | + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; |
|
117 | + $sql1 .= " SET fk_code_ventilation = 0"; |
|
118 | + $sql1 .= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM ".MAIN_DB_PREFIX."facture as f"; |
|
119 | + $sql1 .= " WHERE f.datef >= '".$db->idate(dol_get_first_day($year_current, 1, false))."'"; |
|
120 | + $sql1 .= " AND f.datef <= '".$db->idate(dol_get_last_day($year_current, 12, false))."'"; |
|
121 | + $sql1 .= " AND f.entity IN (".getEntity('accountancy').")"; |
|
122 | + $sql1 .= ")"; |
|
123 | 123 | |
124 | 124 | dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); |
125 | 125 | |
126 | 126 | $resql1 = $db->query($sql1); |
127 | - if (! $resql1) { |
|
128 | - $error ++; |
|
127 | + if (!$resql1) { |
|
128 | + $error++; |
|
129 | 129 | $db->rollback(); |
130 | 130 | setEventMessage($db->lasterror(), 'errors'); |
131 | 131 | } else { |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | |
142 | 142 | llxHeader('', $langs->trans("CustomersVentilation")); |
143 | 143 | |
144 | -$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; |
|
145 | -$textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; |
|
144 | +$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>'; |
|
145 | +$textnextyear = ' <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>'; |
|
146 | 146 | |
147 | -print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); |
|
147 | +print load_fiche_titre($langs->trans("CustomersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); |
|
148 | 148 | |
149 | 149 | // Clean database |
150 | 150 | $db->begin(); |
151 | -$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
151 | +$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; |
|
152 | 152 | $sql1 .= " SET fk_code_ventilation = 0"; |
153 | 153 | $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; |
154 | 154 | $sql1 .= ' (SELECT accnt.rowid '; |
155 | -$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; |
|
156 | -$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; |
|
157 | -$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; |
|
155 | +$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; |
|
156 | +$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; |
|
157 | +$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.')'; |
|
158 | 158 | dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); |
159 | 159 | $resql1 = $db->query($sql1); |
160 | -if (! $resql1) { |
|
161 | - $error ++; |
|
160 | +if (!$resql1) { |
|
161 | + $error++; |
|
162 | 162 | $db->rollback(); |
163 | 163 | setEventMessage($db->lasterror(), 'errors'); |
164 | 164 | } else { |
@@ -166,21 +166,21 @@ discard block |
||
166 | 166 | } |
167 | 167 | // End clean database |
168 | 168 | |
169 | -print $langs->trans("DescVentilCustomer") . '<br>'; |
|
170 | -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>'; |
|
169 | +print $langs->trans("DescVentilCustomer").'<br>'; |
|
170 | +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>'; |
|
171 | 171 | print '<br>'; |
172 | 172 | |
173 | -$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
174 | -$sql .= " , " . MAIN_DB_PREFIX . "facture as f"; |
|
173 | +$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
174 | +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; |
|
175 | 175 | $sql .= " WHERE fd.fk_code_ventilation = 0"; |
176 | 176 | $sql .= " AND f.rowid = fd.fk_facture"; |
177 | 177 | $sql .= " AND f.fk_statut > 0"; |
178 | -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
179 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
178 | +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
179 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
180 | 180 | } else { |
181 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
181 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
182 | 182 | } |
183 | -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy |
|
183 | +$sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // We don't share object for accountancy |
|
184 | 184 | |
185 | 185 | dol_syslog('htdocs/accountancy/customer/index.php'); |
186 | 186 | $result = $db->query($sql); |
@@ -192,47 +192,47 @@ discard block |
||
192 | 192 | |
193 | 193 | $y = $year_current; |
194 | 194 | |
195 | -$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; |
|
196 | -$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; |
|
195 | +$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>'; |
|
196 | +$buttonreset = '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=cleanaccountancycode">'.$langs->trans("CleanHistory", $year_current).'</a>'; |
|
197 | 197 | |
198 | 198 | |
199 | 199 | print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); |
200 | 200 | |
201 | 201 | print '<div class="div-table-responsive-no-min">'; |
202 | 202 | print '<table class="noborder" width="100%">'; |
203 | -print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; |
|
204 | -print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; |
|
205 | -for($i = 1; $i <= 12; $i ++) { |
|
206 | - print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; |
|
203 | +print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>'; |
|
204 | +print '<td width="200" align="left">'.$langs->trans("Label").'</td>'; |
|
205 | +for ($i = 1; $i <= 12; $i++) { |
|
206 | + print '<td width="60" align="right">'.$langs->trans('MonthShort'.str_pad($i, 2, '0', STR_PAD_LEFT)).'</td>'; |
|
207 | 207 | } |
208 | -print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; |
|
208 | +print '<td width="60" align="right"><b>'.$langs->trans("Total").'</b></td></tr>'; |
|
209 | 209 | |
210 | -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; |
|
211 | -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; |
|
212 | -for($i = 1; $i <= 12; $i ++) { |
|
213 | - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; |
|
210 | +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; |
|
211 | +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; |
|
212 | +for ($i = 1; $i <= 12; $i++) { |
|
213 | + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; |
|
214 | 214 | } |
215 | 215 | $sql .= " SUM(fd.total_ht) as total"; |
216 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
217 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; |
|
218 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
219 | -$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; |
|
220 | -$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; |
|
221 | -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy |
|
216 | +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
217 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; |
|
218 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
219 | +$sql .= " WHERE f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
220 | +$sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
221 | +$sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // We don't share object for accountancy |
|
222 | 222 | $sql .= " AND aa.account_number IS NULL"; |
223 | -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
224 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
223 | +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
224 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
225 | 225 | } else { |
226 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
226 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
227 | 227 | } |
228 | 228 | $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; |
229 | 229 | |
230 | -dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); |
|
230 | +dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG); |
|
231 | 231 | $resql = $db->query($sql); |
232 | 232 | if ($resql) { |
233 | 233 | $num = $db->num_rows($resql); |
234 | 234 | |
235 | - while ( $row = $db->fetch_row($resql)) { |
|
235 | + while ($row = $db->fetch_row($resql)) { |
|
236 | 236 | |
237 | 237 | print '<tr class="oddeven"><td>'; |
238 | 238 | if ($row[0] == 'tobind') |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | } |
249 | 249 | else print $row[1]; |
250 | 250 | print '</td>'; |
251 | - for($i = 2; $i <= 12; $i ++) { |
|
252 | - print '<td align="right">' . price($row[$i]) . '</td>'; |
|
251 | + for ($i = 2; $i <= 12; $i++) { |
|
252 | + print '<td align="right">'.price($row[$i]).'</td>'; |
|
253 | 253 | } |
254 | - print '<td align="right">' . price($row[13]) . '</td>'; |
|
255 | - print '<td align="right"><b>' . price($row[14]) . '</b></td>'; |
|
254 | + print '<td align="right">'.price($row[13]).'</td>'; |
|
255 | + print '<td align="right"><b>'.price($row[14]).'</b></td>'; |
|
256 | 256 | print '</tr>'; |
257 | 257 | } |
258 | 258 | $db->free($resql); |
@@ -269,29 +269,29 @@ discard block |
||
269 | 269 | |
270 | 270 | print '<div class="div-table-responsive-no-min">'; |
271 | 271 | print '<table class="noborder" width="100%">'; |
272 | -print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; |
|
273 | -print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; |
|
274 | -for($i = 1; $i <= 12; $i ++) { |
|
275 | - print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; |
|
272 | +print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>'; |
|
273 | +print '<td width="200" align="left">'.$langs->trans("Label").'</td>'; |
|
274 | +for ($i = 1; $i <= 12; $i++) { |
|
275 | + print '<td width="60" align="right">'.$langs->trans('MonthShort'.str_pad($i, 2, '0', STR_PAD_LEFT)).'</td>'; |
|
276 | 276 | } |
277 | -print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; |
|
277 | +print '<td width="60" align="right"><b>'.$langs->trans("Total").'</b></td></tr>'; |
|
278 | 278 | |
279 | -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; |
|
280 | -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; |
|
281 | -for($i = 1; $i <= 12; $i ++) { |
|
282 | - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; |
|
279 | +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; |
|
280 | +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; |
|
281 | +for ($i = 1; $i <= 12; $i++) { |
|
282 | + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; |
|
283 | 283 | } |
284 | 284 | $sql .= " SUM(fd.total_ht) as total"; |
285 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
286 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; |
|
287 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
288 | -$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; |
|
289 | -$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; |
|
290 | -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy |
|
291 | -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
292 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
285 | +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
286 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; |
|
287 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
288 | +$sql .= " WHERE f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
289 | +$sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
290 | +$sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // We don't share object for accountancy |
|
291 | +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
292 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
293 | 293 | } else { |
294 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
294 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
295 | 295 | } |
296 | 296 | $sql .= " AND aa.account_number IS NOT NULL"; |
297 | 297 | $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | if ($resql) { |
302 | 302 | $num = $db->num_rows($resql); |
303 | 303 | |
304 | - while ( $row = $db->fetch_row($resql)) { |
|
304 | + while ($row = $db->fetch_row($resql)) { |
|
305 | 305 | |
306 | 306 | print '<tr class="oddeven"><td>'; |
307 | 307 | if ($row[0] == 'tobind') |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | else print $row[1]; |
320 | 320 | print '</td>'; |
321 | 321 | |
322 | - for($i = 2; $i <= 12; $i ++) { |
|
323 | - print '<td align="right">' . price($row[$i]) . '</td>'; |
|
322 | + for ($i = 2; $i <= 12; $i++) { |
|
323 | + print '<td align="right">'.price($row[$i]).'</td>'; |
|
324 | 324 | } |
325 | - print '<td align="right">' . price($row[13]) . '</td>'; |
|
326 | - print '<td align="right"><b>' . price($row[14]) . '</b></td>'; |
|
325 | + print '<td align="right">'.price($row[13]).'</td>'; |
|
326 | + print '<td align="right"><b>'.price($row[14]).'</b></td>'; |
|
327 | 327 | print '</tr>'; |
328 | 328 | } |
329 | 329 | $db->free($resql); |
@@ -344,26 +344,26 @@ discard block |
||
344 | 344 | print "<br>\n"; |
345 | 345 | print '<div class="div-table-responsive-no-min">'; |
346 | 346 | print '<table class="noborder" width="100%">'; |
347 | - print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>'; |
|
348 | - for($i = 1; $i <= 12; $i ++) { |
|
349 | - print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; |
|
347 | + print '<tr class="liste_titre"><td width="400" align="left">'.$langs->trans("TotalVente").'</td>'; |
|
348 | + for ($i = 1; $i <= 12; $i++) { |
|
349 | + print '<td width="60" align="right">'.$langs->trans('MonthShort'.str_pad($i, 2, '0', STR_PAD_LEFT)).'</td>'; |
|
350 | 350 | } |
351 | - print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; |
|
351 | + print '<td width="60" align="right"><b>'.$langs->trans("Total").'</b></td></tr>'; |
|
352 | 352 | |
353 | - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; |
|
354 | - for($i = 1; $i <= 12; $i ++) { |
|
355 | - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; |
|
353 | + $sql = "SELECT '".$langs->trans("TotalVente")."' AS total,"; |
|
354 | + for ($i = 1; $i <= 12; $i++) { |
|
355 | + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; |
|
356 | 356 | } |
357 | 357 | $sql .= " SUM(fd.total_ht) as total"; |
358 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
359 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; |
|
360 | - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; |
|
361 | - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; |
|
362 | - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy |
|
363 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
364 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
358 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
359 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; |
|
360 | + $sql .= " WHERE f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
361 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
362 | + $sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // We don't share object for accountancy |
|
363 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
364 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
365 | 365 | } else { |
366 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
366 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | dol_syslog('htdocs/accountancy/customer/index.php'); |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | $num = $db->num_rows($resql); |
373 | 373 | |
374 | 374 | while ($row = $db->fetch_row($resql)) { |
375 | - print '<tr><td>' . $row[0] . '</td>'; |
|
376 | - for($i = 1; $i <= 12; $i ++) { |
|
377 | - print '<td align="right">' . price($row[$i]) . '</td>'; |
|
375 | + print '<tr><td>'.$row[0].'</td>'; |
|
376 | + for ($i = 1; $i <= 12; $i++) { |
|
377 | + print '<td align="right">'.price($row[$i]).'</td>'; |
|
378 | 378 | } |
379 | - print '<td align="right"><b>' . price($row[13]) . '</b></td>'; |
|
379 | + print '<td align="right"><b>'.price($row[13]).'</b></td>'; |
|
380 | 380 | print '</tr>'; |
381 | 381 | } |
382 | 382 | $db->free($resql); |
@@ -387,30 +387,30 @@ discard block |
||
387 | 387 | print '</div>'; |
388 | 388 | |
389 | 389 | |
390 | - if (! empty($conf->margin->enabled)) { |
|
390 | + if (!empty($conf->margin->enabled)) { |
|
391 | 391 | print "<br>\n"; |
392 | 392 | print '<div class="div-table-responsive-no-min">'; |
393 | 393 | print '<table class="noborder" width="100%">'; |
394 | - print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>'; |
|
395 | - for($i = 1; $i <= 12; $i ++) { |
|
396 | - print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; |
|
394 | + print '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</td>'; |
|
395 | + for ($i = 1; $i <= 12; $i++) { |
|
396 | + print '<td width="60" align="right">'.$langs->trans('MonthShort'.str_pad($i, 2, '0', STR_PAD_LEFT)).'</td>'; |
|
397 | 397 | } |
398 | - print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; |
|
398 | + print '<td width="60" align="right"><b>'.$langs->trans("Total").'</b></td></tr>'; |
|
399 | 399 | |
400 | - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; |
|
401 | - for($i = 1; $i <= 12; $i ++) { |
|
402 | - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; |
|
400 | + $sql = "SELECT '".$langs->trans("Vide")."' AS marge,"; |
|
401 | + for ($i = 1; $i <= 12; $i++) { |
|
402 | + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; |
|
403 | 403 | } |
404 | 404 | $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; |
405 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
406 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; |
|
407 | - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; |
|
408 | - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; |
|
409 | - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy |
|
410 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
411 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
405 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
406 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; |
|
407 | + $sql .= " WHERE f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
408 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
409 | + $sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // We don't share object for accountancy |
|
410 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
411 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
412 | 412 | } else { |
413 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
413 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | dol_syslog('htdocs/accountancy/customer/index.php'); |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | |
421 | 421 | while ($row = $db->fetch_row($resql)) { |
422 | 422 | |
423 | - print '<tr><td>' . $row[0] . '</td>'; |
|
424 | - for($i = 1; $i <= 12; $i ++) { |
|
425 | - print '<td align="right">' . price(price2num($row[$i])) . '</td>'; |
|
423 | + print '<tr><td>'.$row[0].'</td>'; |
|
424 | + for ($i = 1; $i <= 12; $i++) { |
|
425 | + print '<td align="right">'.price(price2num($row[$i])).'</td>'; |
|
426 | 426 | } |
427 | - print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>'; |
|
427 | + print '<td align="right"><b>'.price(price2num($row[13])).'</b></td>'; |
|
428 | 428 | print '</tr>'; |
429 | 429 | } |
430 | 430 | $db->free($resql); |
@@ -42,10 +42,12 @@ discard block |
||
42 | 42 | if (empty($conf->accounting->enabled)) { |
43 | 43 | accessforbidden(); |
44 | 44 | } |
45 | -if ($user->societe_id > 0) |
|
45 | +if ($user->societe_id > 0) { |
|
46 | 46 | accessforbidden(); |
47 | -if (! $user->rights->accounting->bind->write) |
|
47 | +} |
|
48 | +if (! $user->rights->accounting->bind->write) { |
|
48 | 49 | accessforbidden(); |
50 | +} |
|
49 | 51 | |
50 | 52 | // Filter |
51 | 53 | $year = GETPOST("year",'int'); |
@@ -238,15 +240,17 @@ discard block |
||
238 | 240 | if ($row[0] == 'tobind') |
239 | 241 | { |
240 | 242 | print $langs->trans("Unknown"); |
243 | + } else { |
|
244 | + print length_accountg($row[0]); |
|
241 | 245 | } |
242 | - else print length_accountg($row[0]); |
|
243 | 246 | print '</td>'; |
244 | 247 | print '<td align="left">'; |
245 | 248 | if ($row[0] == 'tobind') |
246 | 249 | { |
247 | 250 | print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); |
251 | + } else { |
|
252 | + print $row[1]; |
|
248 | 253 | } |
249 | - else print $row[1]; |
|
250 | 254 | print '</td>'; |
251 | 255 | for($i = 2; $i <= 12; $i ++) { |
252 | 256 | print '<td align="right">' . price($row[$i]) . '</td>'; |
@@ -307,16 +311,18 @@ discard block |
||
307 | 311 | if ($row[0] == 'tobind') |
308 | 312 | { |
309 | 313 | print $langs->trans("Unknown"); |
314 | + } else { |
|
315 | + print length_accountg($row[0]); |
|
310 | 316 | } |
311 | - else print length_accountg($row[0]); |
|
312 | 317 | print '</td>'; |
313 | 318 | |
314 | 319 | print '<td align="left">'; |
315 | 320 | if ($row[0] == 'tobind') |
316 | 321 | { |
317 | 322 | print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); |
323 | + } else { |
|
324 | + print $row[1]; |
|
318 | 325 | } |
319 | - else print $row[1]; |
|
320 | 326 | print '</td>'; |
321 | 327 | |
322 | 328 | for($i = 2; $i <= 12; $i ++) { |
@@ -334,9 +340,11 @@ discard block |
||
334 | 340 | print '</div>'; |
335 | 341 | |
336 | 342 | |
337 | -if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? |
|
343 | +if ($conf->global->MAIN_FEATURES_LEVEL > 0) { |
|
344 | + // This part of code looks strange. Why showing a report that should rely on result of this step ? |
|
338 | 345 | { |
339 | 346 | print '<br>'; |
347 | +} |
|
340 | 348 | print '<br>'; |
341 | 349 | |
342 | 350 | print_fiche_titre($langs->trans("OtherInfo"), '', ''); |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | $sql .= " AND fd.fk_code_ventilation > 0"; |
101 | 101 | $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy |
102 | 102 | if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
103 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
103 | + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
104 | 104 | } else { |
105 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
105 | + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
106 | 106 | } |
107 | 107 | if ($date_start && $date_end) |
108 | 108 | $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $bookkeeping->doc_type = 'supplier_invoice'; |
278 | 278 | $bookkeeping->fk_doc = $key; |
279 | 279 | $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
280 | - $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
|
280 | + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
|
281 | 281 | $bookkeeping->subledger_account = ''; |
282 | 282 | $bookkeeping->subledger_label = ''; |
283 | 283 | $bookkeeping->numero_compte = $k; |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | * \brief Page with purchases journal |
28 | 28 | */ |
29 | 29 | require '../../main.inc.php'; |
30 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; |
|
31 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; |
|
37 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
37 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
38 | 38 | |
39 | -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors")); |
|
39 | +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors")); |
|
40 | 40 | |
41 | 41 | $id_journal = GETPOST('id_journal', 'int'); |
42 | -$action = GETPOST('action','aZ09'); |
|
42 | +$action = GETPOST('action', 'aZ09'); |
|
43 | 43 | |
44 | 44 | $date_startmonth = GETPOST('date_startmonth'); |
45 | 45 | $date_startday = GETPOST('date_startday'); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $pastmonthyear = $year_current; |
72 | 72 | if ($pastmonth == 0) { |
73 | 73 | $pastmonth = 12; |
74 | - $pastmonthyear --; |
|
74 | + $pastmonthyear--; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); |
@@ -90,73 +90,73 @@ discard block |
||
90 | 90 | $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; |
91 | 91 | $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; |
92 | 92 | //$sql .= " ct.accountancy_code_buy as account_tva"; |
93 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; |
|
93 | +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; |
|
94 | 94 | //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; |
95 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; |
|
96 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
97 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; |
|
98 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; |
|
95 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; |
|
96 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
97 | +$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; |
|
98 | +$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; |
|
99 | 99 | $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? |
100 | 100 | $sql .= " AND fd.fk_code_ventilation > 0"; |
101 | -$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy |
|
102 | -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
103 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
101 | +$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy |
|
102 | +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
103 | + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")"; |
|
104 | 104 | } else { |
105 | - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
|
105 | + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; |
|
106 | 106 | } |
107 | 107 | if ($date_start && $date_end) |
108 | - $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; |
|
108 | + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
109 | 109 | if ($in_bookkeeping == 'already') |
110 | - $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
|
110 | + $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
|
111 | 111 | if ($in_bookkeeping == 'notyet') |
112 | - $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
|
112 | + $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
|
113 | 113 | $sql .= " ORDER BY f.datef"; |
114 | 114 | |
115 | 115 | dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG); |
116 | 116 | $result = $db->query($sql); |
117 | 117 | if ($result) { |
118 | - $tabfac = array (); |
|
119 | - $tabht = array (); |
|
120 | - $tabtva = array (); |
|
121 | - $def_tva = array (); |
|
122 | - $tabttc = array (); |
|
123 | - $tablocaltax1 = array (); |
|
124 | - $tablocaltax2 = array (); |
|
125 | - $tabcompany = array (); |
|
118 | + $tabfac = array(); |
|
119 | + $tabht = array(); |
|
120 | + $tabtva = array(); |
|
121 | + $def_tva = array(); |
|
122 | + $tabttc = array(); |
|
123 | + $tablocaltax1 = array(); |
|
124 | + $tablocaltax2 = array(); |
|
125 | + $tabcompany = array(); |
|
126 | 126 | |
127 | 127 | $num = $db->num_rows($result); |
128 | 128 | |
129 | 129 | // Variables |
130 | - $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; |
|
131 | - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; |
|
130 | + $cptfour = (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; |
|
131 | + $cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; |
|
132 | 132 | |
133 | 133 | $i = 0; |
134 | - while ( $i < $num ) { |
|
134 | + while ($i < $num) { |
|
135 | 135 | $obj = $db->fetch_object($result); |
136 | 136 | |
137 | 137 | // Controls |
138 | - $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; |
|
138 | + $compta_soc = (!empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; |
|
139 | 139 | |
140 | 140 | $compta_prod = $obj->compte; |
141 | 141 | if (empty($compta_prod)) { |
142 | 142 | if ($obj->product_type == 0) |
143 | - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
143 | + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
144 | 144 | else |
145 | - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; |
|
145 | + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; |
|
146 | 146 | } |
147 | 147 | |
148 | - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); |
|
149 | - $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); |
|
148 | + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); |
|
149 | + $compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); |
|
150 | 150 | |
151 | 151 | // Define array to display all VAT rates that use this accounting account $compta_tva |
152 | - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) |
|
152 | + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) |
|
153 | 153 | { |
154 | - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); |
|
154 | + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); |
158 | 158 | $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr); |
159 | - $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; |
|
159 | + $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')'; |
|
160 | 160 | $tabfac[$obj->rowid]["refsologest"] = $obj->ref; |
161 | 161 | $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; |
162 | 162 | |
@@ -165,25 +165,25 @@ discard block |
||
165 | 165 | //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; |
166 | 166 | |
167 | 167 | // Avoid warnings |
168 | - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
169 | - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
170 | - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
171 | - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
172 | - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
168 | + if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
169 | + if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
170 | + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
171 | + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
172 | + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
173 | 173 | |
174 | 174 | $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; |
175 | 175 | $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; |
176 | 176 | $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; |
177 | 177 | $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; |
178 | 178 | $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; |
179 | - $tabcompany[$obj->rowid] = array ( |
|
179 | + $tabcompany[$obj->rowid] = array( |
|
180 | 180 | 'id' => $obj->socid, |
181 | 181 | 'name' => $obj->name, |
182 | 182 | 'code_fournisseur' => $obj->code_fournisseur, |
183 | 183 | 'code_compta_fournisseur' => $compta_soc |
184 | 184 | ); |
185 | 185 | |
186 | - $i ++; |
|
186 | + $i++; |
|
187 | 187 | } |
188 | 188 | } else { |
189 | 189 | dol_print_error($db); |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); |
218 | 218 | |
219 | 219 | // Thirdparty |
220 | - if (! $errorforline) |
|
220 | + if (!$errorforline) |
|
221 | 221 | { |
222 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
222 | + foreach ($tabttc[$key] as $k => $mt) { |
|
223 | 223 | if ($mt) { |
224 | 224 | $bookkeeping = new BookKeeping($db); |
225 | 225 | $bookkeeping->doc_date = $val["date"]; |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | $bookkeeping->date_create = $now; |
229 | 229 | $bookkeeping->doc_type = 'supplier_invoice'; |
230 | 230 | $bookkeeping->fk_doc = $key; |
231 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
231 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
232 | 232 | $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
233 | 233 | $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; |
234 | - $bookkeeping->subledger_label = ''; // TODO To complete |
|
234 | + $bookkeeping->subledger_label = ''; // TODO To complete |
|
235 | 235 | $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; |
236 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount"); |
|
236 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->refsupplier.' - '.$langs->trans("SubledgerAccount"); |
|
237 | 237 | $bookkeeping->montant = $mt; |
238 | 238 | $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; |
239 | 239 | $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | // Product / Service |
265 | - if (! $errorforline) |
|
265 | + if (!$errorforline) |
|
266 | 266 | { |
267 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
267 | + foreach ($tabht[$key] as $k => $mt) { |
|
268 | 268 | if ($mt) { |
269 | 269 | // get compte id and label |
270 | 270 | $accountingaccount = new AccountingAccount($db); |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | $bookkeeping->date_create = $now; |
277 | 277 | $bookkeeping->doc_type = 'supplier_invoice'; |
278 | 278 | $bookkeeping->fk_doc = $key; |
279 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
279 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
280 | 280 | $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
281 | 281 | $bookkeeping->subledger_account = ''; |
282 | 282 | $bookkeeping->subledger_label = ''; |
283 | 283 | $bookkeeping->numero_compte = $k; |
284 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; |
|
284 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->refsupplier.' - '.$accountingaccount->label; |
|
285 | 285 | $bookkeeping->montant = $mt; |
286 | 286 | $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; |
287 | 287 | $bookkeeping->debit = ($mt > 0) ? $mt : 0; |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | |
313 | 313 | // VAT |
314 | 314 | // var_dump($tabtva); |
315 | - if (! $errorforline) |
|
315 | + if (!$errorforline) |
|
316 | 316 | { |
317 | - $listoftax=array(0, 1, 2); |
|
318 | - foreach($listoftax as $numtax) |
|
317 | + $listoftax = array(0, 1, 2); |
|
318 | + foreach ($listoftax as $numtax) |
|
319 | 319 | { |
320 | 320 | $arrayofvat = $tabtva; |
321 | 321 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
322 | 322 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
323 | 323 | |
324 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
324 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
325 | 325 | if ($mt) { |
326 | 326 | $bookkeeping = new BookKeeping($db); |
327 | 327 | $bookkeeping->doc_date = $val["date"]; |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | $bookkeeping->date_create = $now; |
331 | 331 | $bookkeeping->doc_type = 'supplier_invoice'; |
332 | 332 | $bookkeeping->fk_doc = $key; |
333 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
333 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
334 | 334 | $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; |
335 | 335 | $bookkeeping->subledger_account = ''; |
336 | 336 | $bookkeeping->subledger_label = ''; |
337 | 337 | $bookkeeping->numero_compte = $k; |
338 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:''); |
|
338 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->refsupplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); |
|
339 | 339 | $bookkeeping->montant = $mt; |
340 | 340 | $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; |
341 | 341 | $bookkeeping->debit = ($mt > 0) ? $mt : 0; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | - if (! $errorforline) |
|
367 | + if (!$errorforline) |
|
368 | 368 | { |
369 | 369 | $db->commit(); |
370 | 370 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | if ($error >= 10) |
376 | 376 | { |
377 | 377 | setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); |
378 | - break; // Break in the foreach |
|
378 | + break; // Break in the foreach |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |
@@ -392,20 +392,20 @@ discard block |
||
392 | 392 | setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
393 | 393 | } |
394 | 394 | |
395 | - $action=''; |
|
395 | + $action = ''; |
|
396 | 396 | |
397 | 397 | // Must reload data, so we make a redirect |
398 | 398 | if (count($tabpay) != $error) |
399 | 399 | { |
400 | - $param='id_journal='.$id_journal; |
|
401 | - $param.='&date_startday='.$date_startday; |
|
402 | - $param.='&date_startmonth='.$date_startmonth; |
|
403 | - $param.='&date_startyear='.$date_startyear; |
|
404 | - $param.='&date_endday='.$date_endday; |
|
405 | - $param.='&date_endmonth='.$date_endmonth; |
|
406 | - $param.='&date_endyear='.$date_endyear; |
|
407 | - $param.='&in_bookeeping='.$in_bookeeping; |
|
408 | - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); |
|
400 | + $param = 'id_journal='.$id_journal; |
|
401 | + $param .= '&date_startday='.$date_startday; |
|
402 | + $param .= '&date_startmonth='.$date_startmonth; |
|
403 | + $param .= '&date_startyear='.$date_startyear; |
|
404 | + $param .= '&date_endday='.$date_endday; |
|
405 | + $param .= '&date_endmonth='.$date_endmonth; |
|
406 | + $param .= '&date_endyear='.$date_endyear; |
|
407 | + $param .= '&in_bookeeping='.$in_bookeeping; |
|
408 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
409 | 409 | exit; |
410 | 410 | } |
411 | 411 | } |
@@ -420,12 +420,12 @@ discard block |
||
420 | 420 | if ($action == 'exportcsv') { |
421 | 421 | $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; |
422 | 422 | |
423 | - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
|
423 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
424 | 424 | |
425 | 425 | $companystatic = new Fournisseur($db); |
426 | 426 | $invoicestatic = new FactureFournisseur($db); |
427 | 427 | |
428 | - foreach ( $tabfac as $key => $val ) |
|
428 | + foreach ($tabfac as $key => $val) |
|
429 | 429 | { |
430 | 430 | $companystatic->id = $tabcompany[$key]['id']; |
431 | 431 | $companystatic->name = $tabcompany[$key]['name']; |
@@ -441,39 +441,39 @@ discard block |
||
441 | 441 | $date = dol_print_date($val["date"], 'day'); |
442 | 442 | |
443 | 443 | // Third party |
444 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
445 | - print '"' . $key . '"' . $sep; |
|
446 | - print '"' . $date . '"' . $sep; |
|
447 | - print '"' . $val["refsologest"] . '"' . $sep; |
|
448 | - print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep; |
|
449 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
450 | - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; |
|
451 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
452 | - print '"' . $langs->trans("Code_tiers") . '"' . $sep; |
|
453 | - print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; |
|
454 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
455 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; |
|
456 | - print '"' . $journal . '"' ; |
|
444 | + foreach ($tabttc[$key] as $k => $mt) { |
|
445 | + print '"'.$key.'"'.$sep; |
|
446 | + print '"'.$date.'"'.$sep; |
|
447 | + print '"'.$val["refsologest"].'"'.$sep; |
|
448 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
449 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
450 | + print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep; |
|
451 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
452 | + print '"'.$langs->trans("Code_tiers").'"'.$sep; |
|
453 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Code_tiers").'"'.$sep; |
|
454 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
455 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
456 | + print '"'.$journal.'"'; |
|
457 | 457 | print "\n"; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // Product / Service |
461 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
461 | + foreach ($tabht[$key] as $k => $mt) { |
|
462 | 462 | $accountingaccount = new AccountingAccount($db); |
463 | 463 | $accountingaccount->fetch(null, $k, true); |
464 | 464 | if ($mt) { |
465 | - print '"' . $key . '"' . $sep; |
|
466 | - print '"' . $date . '"' . $sep; |
|
467 | - print '"' . $val["refsologest"] . '"' . $sep; |
|
468 | - print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep; |
|
469 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
470 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
471 | - print '""' . $sep; |
|
472 | - print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep; |
|
473 | - print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; |
|
474 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
475 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; |
|
476 | - print '"' . $journal . '"' ; |
|
465 | + print '"'.$key.'"'.$sep; |
|
466 | + print '"'.$date.'"'.$sep; |
|
467 | + print '"'.$val["refsologest"].'"'.$sep; |
|
468 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
469 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
470 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
471 | + print '""'.$sep; |
|
472 | + print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; |
|
473 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; |
|
474 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
475 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
476 | + print '"'.$journal.'"'; |
|
477 | 477 | print "\n"; |
478 | 478 | } |
479 | 479 | } |
@@ -487,18 +487,18 @@ discard block |
||
487 | 487 | |
488 | 488 | foreach ($arrayofvat[$key] as $k => $mt) { |
489 | 489 | if ($mt) { |
490 | - print '"' . $key . '"' . $sep; |
|
491 | - print '"' . $date . '"' . $sep; |
|
492 | - print '"' . $val["refsologest"] . '"' . $sep; |
|
493 | - print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep; |
|
494 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
495 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
496 | - print '""' . $sep; |
|
497 | - print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep; |
|
498 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep; |
|
499 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
500 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; |
|
501 | - print '"' . $journal . '"' ; |
|
490 | + print '"'.$key.'"'.$sep; |
|
491 | + print '"'.$date.'"'.$sep; |
|
492 | + print '"'.$val["refsologest"].'"'.$sep; |
|
493 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
494 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
495 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
496 | + print '""'.$sep; |
|
497 | + print '"'.$langs->trans("VAT").' - '.$def_tva[$key].'"'.$sep; |
|
498 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; |
|
499 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
500 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
501 | + print '"'.$journal.'"'; |
|
502 | 502 | print "\n"; |
503 | 503 | } |
504 | 504 | } |
@@ -510,22 +510,22 @@ discard block |
||
510 | 510 | |
511 | 511 | llxHeader('', $langs->trans("PurchasesJournal")); |
512 | 512 | |
513 | - $nom = $langs->trans("PurchasesJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); |
|
513 | + $nom = $langs->trans("PurchasesJournal").' - '.$accountingjournalstatic->getNomUrl(1); |
|
514 | 514 | $nomlink = ''; |
515 | 515 | $periodlink = ''; |
516 | 516 | $exportlink = ''; |
517 | - $builddate=dol_now(); |
|
518 | - $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
519 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
517 | + $builddate = dol_now(); |
|
518 | + $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
519 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
520 | 520 | $description .= $langs->trans("DepositsAreNotIncluded"); |
521 | 521 | } else { |
522 | 522 | $description .= $langs->trans("DepositsAreIncluded"); |
523 | 523 | } |
524 | 524 | |
525 | - $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
526 | - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
525 | + $listofchoices = array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
526 | + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1).' - '.$form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1).' - '.$langs->trans("AlreadyInGeneralLedger").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
527 | 527 | |
528 | - $varlink = 'id_journal=' . $id_journal; |
|
528 | + $varlink = 'id_journal='.$id_journal; |
|
529 | 529 | |
530 | 530 | journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
531 | 531 | |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | } |
537 | 537 | print '<div class="tabsAction tabsActionNoBottom">'; |
538 | 538 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
539 | - print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
539 | + print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
540 | 540 | } |
541 | 541 | else { |
542 | - print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
542 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
543 | 543 | } |
544 | - print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
|
544 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
545 | 545 | print '</div>'; |
546 | 546 | |
547 | 547 | // TODO Avoid using js. We can use a direct link with $param |
@@ -569,13 +569,13 @@ discard block |
||
569 | 569 | print "<table class=\"noborder\" width=\"100%\">"; |
570 | 570 | print "<tr class=\"liste_titre\">"; |
571 | 571 | print "<td></td>"; |
572 | - print "<td>" . $langs->trans("Date") . "</td>"; |
|
573 | - print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; |
|
574 | - print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
575 | - print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
576 | - print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
577 | - print "<td align='right'>" . $langs->trans("Debit") . "</td>"; |
|
578 | - print "<td align='right'>" . $langs->trans("Credit") . "</td>"; |
|
572 | + print "<td>".$langs->trans("Date")."</td>"; |
|
573 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>"; |
|
574 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
575 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
576 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
577 | + print "<td align='right'>".$langs->trans("Debit")."</td>"; |
|
578 | + print "<td align='right'>".$langs->trans("Credit")."</td>"; |
|
579 | 579 | print "</tr>\n"; |
580 | 580 | |
581 | 581 | $r = ''; |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $invoicestatic = new FactureFournisseur($db); |
584 | 584 | $companystatic = new Fournisseur($db); |
585 | 585 | |
586 | - foreach ( $tabfac as $key => $val ) { |
|
586 | + foreach ($tabfac as $key => $val) { |
|
587 | 587 | $invoicestatic->id = $key; |
588 | 588 | $invoicestatic->ref = $val["ref"]; |
589 | 589 | $invoicestatic->type = $val["type"]; |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | $date = dol_print_date($val["date"], 'day'); |
597 | 597 | |
598 | 598 | // Third party |
599 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
599 | + foreach ($tabttc[$key] as $k => $mt) { |
|
600 | 600 | print '<tr class="oddeven">'; |
601 | 601 | print "<td><!-- Thirdparty --></td>"; |
602 | - print "<td>" . $date . "</td>"; |
|
603 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
602 | + print "<td>".$date."</td>"; |
|
603 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
604 | 604 | $companystatic->id = $tabcompany[$key]['id']; |
605 | 605 | $companystatic->name = $tabcompany[$key]['name']; |
606 | 606 | $companystatic->supplier_code = $tabcompany[$key]['code_supplier']; |
@@ -622,22 +622,22 @@ discard block |
||
622 | 622 | } |
623 | 623 | else print $accountoshow; |
624 | 624 | print '</td>'; |
625 | - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; |
|
626 | - print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; |
|
627 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
625 | + print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->refsupplier.' - '.$langs->trans("SubledgerAccount")."</td>"; |
|
626 | + print '<td align="right">'.($mt < 0 ? -price(-$mt) : '')."</td>"; |
|
627 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
628 | 628 | print "</tr>"; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Product / Service |
632 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
632 | + foreach ($tabht[$key] as $k => $mt) { |
|
633 | 633 | $accountingaccount = new AccountingAccount($db); |
634 | 634 | $accountingaccount->fetch(null, $k, true); |
635 | 635 | |
636 | 636 | if ($mt) { |
637 | 637 | print '<tr class="oddeven">'; |
638 | 638 | print "<td><!-- Product --></td>"; |
639 | - print "<td>" . $date . "</td>"; |
|
640 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
639 | + print "<td>".$date."</td>"; |
|
640 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
641 | 641 | // Account |
642 | 642 | print "<td>"; |
643 | 643 | $accountoshow = length_accountg($k); |
@@ -652,9 +652,9 @@ discard block |
||
652 | 652 | print '</td>'; |
653 | 653 | $companystatic->id = $tabcompany[$key]['id']; |
654 | 654 | $companystatic->name = $tabcompany[$key]['name']; |
655 | - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>"; |
|
656 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
657 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
655 | + print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->refsupplier.' - '.$accountingaccount->label."</td>"; |
|
656 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
657 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
658 | 658 | print "</tr>"; |
659 | 659 | } |
660 | 660 | } |
@@ -666,12 +666,12 @@ discard block |
||
666 | 666 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
667 | 667 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
668 | 668 | |
669 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
669 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
670 | 670 | if ($mt) { |
671 | 671 | print '<tr class="oddeven">'; |
672 | 672 | print "<td><!-- VAT --></td>"; |
673 | - print "<td>" . $date . "</td>"; |
|
674 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
673 | + print "<td>".$date."</td>"; |
|
674 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
675 | 675 | // Account |
676 | 676 | print "<td>"; |
677 | 677 | $accountoshow = length_accountg($k); |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | // Subledger account |
685 | 685 | print "<td>"; |
686 | 686 | print '</td>'; |
687 | - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); |
|
687 | + print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->refsupplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); |
|
688 | 688 | print "</td>"; |
689 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
690 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
689 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
690 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
691 | 691 | print "</tr>"; |
692 | 692 | } |
693 | 693 | } |
@@ -48,13 +48,16 @@ discard block |
||
48 | 48 | $date_endday = GETPOST('date_endday'); |
49 | 49 | $date_endyear = GETPOST('date_endyear'); |
50 | 50 | $in_bookkeeping = GETPOST('in_bookkeeping'); |
51 | -if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; |
|
51 | +if ($in_bookkeeping == '') { |
|
52 | + $in_bookkeeping = 'notyet'; |
|
53 | +} |
|
52 | 54 | |
53 | 55 | $now = dol_now(); |
54 | 56 | |
55 | 57 | // Security check |
56 | -if ($user->societe_id > 0) |
|
58 | +if ($user->societe_id > 0) { |
|
57 | 59 | accessforbidden(); |
60 | +} |
|
58 | 61 | |
59 | 62 | /* |
60 | 63 | * Actions |
@@ -77,9 +80,11 @@ discard block |
||
77 | 80 | $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); |
78 | 81 | $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); |
79 | 82 | |
80 | -if (empty($date_start) || empty($date_end)) // We define date_start and date_end |
|
83 | +if (empty($date_start) || empty($date_end)) { |
|
84 | + // We define date_start and date_end |
|
81 | 85 | { |
82 | 86 | $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); |
87 | +} |
|
83 | 88 | $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); |
84 | 89 | } |
85 | 90 | |
@@ -104,12 +109,15 @@ discard block |
||
104 | 109 | } else { |
105 | 110 | $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; |
106 | 111 | } |
107 | -if ($date_start && $date_end) |
|
112 | +if ($date_start && $date_end) { |
|
108 | 113 | $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; |
109 | -if ($in_bookkeeping == 'already') |
|
114 | +} |
|
115 | +if ($in_bookkeeping == 'already') { |
|
110 | 116 | $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
111 | -if ($in_bookkeeping == 'notyet') |
|
117 | +} |
|
118 | +if ($in_bookkeeping == 'notyet') { |
|
112 | 119 | $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; |
120 | +} |
|
113 | 121 | $sql .= " ORDER BY f.datef"; |
114 | 122 | |
115 | 123 | dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG); |
@@ -139,10 +147,11 @@ discard block |
||
139 | 147 | |
140 | 148 | $compta_prod = $obj->compte; |
141 | 149 | if (empty($compta_prod)) { |
142 | - if ($obj->product_type == 0) |
|
143 | - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
144 | - else |
|
145 | - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; |
|
150 | + if ($obj->product_type == 0) { |
|
151 | + $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
152 | + } else { |
|
153 | + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; |
|
154 | + } |
|
146 | 155 | } |
147 | 156 | |
148 | 157 | $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); |
@@ -165,11 +174,21 @@ discard block |
||
165 | 174 | //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; |
166 | 175 | |
167 | 176 | // Avoid warnings |
168 | - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
169 | - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
170 | - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
171 | - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
172 | - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
177 | + if (! isset($tabttc[$obj->rowid][$compta_soc])) { |
|
178 | + $tabttc[$obj->rowid][$compta_soc] = 0; |
|
179 | + } |
|
180 | + if (! isset($tabht[$obj->rowid][$compta_prod])) { |
|
181 | + $tabht[$obj->rowid][$compta_prod] = 0; |
|
182 | + } |
|
183 | + if (! isset($tabtva[$obj->rowid][$compta_tva])) { |
|
184 | + $tabtva[$obj->rowid][$compta_tva] = 0; |
|
185 | + } |
|
186 | + if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) { |
|
187 | + $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
188 | + } |
|
189 | + if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) { |
|
190 | + $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
191 | + } |
|
173 | 192 | |
174 | 193 | $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; |
175 | 194 | $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; |
@@ -244,13 +263,14 @@ discard block |
||
244 | 263 | |
245 | 264 | $result = $bookkeeping->create($user); |
246 | 265 | if ($result < 0) { |
247 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
266 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
267 | + // Already exists |
|
248 | 268 | { |
249 | 269 | $error++; |
270 | + } |
|
250 | 271 | $errorforline++; |
251 | 272 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
252 | - } |
|
253 | - else |
|
273 | + } else |
|
254 | 274 | { |
255 | 275 | $error++; |
256 | 276 | $errorforline++; |
@@ -292,13 +312,14 @@ discard block |
||
292 | 312 | |
293 | 313 | $result = $bookkeeping->create($user); |
294 | 314 | if ($result < 0) { |
295 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
315 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
316 | + // Already exists |
|
296 | 317 | { |
297 | 318 | $error++; |
319 | + } |
|
298 | 320 | $errorforline++; |
299 | 321 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
300 | - } |
|
301 | - else |
|
322 | + } else |
|
302 | 323 | { |
303 | 324 | $error++; |
304 | 325 | $errorforline++; |
@@ -318,8 +339,12 @@ discard block |
||
318 | 339 | foreach($listoftax as $numtax) |
319 | 340 | { |
320 | 341 | $arrayofvat = $tabtva; |
321 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
322 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
342 | + if ($numtax == 1) { |
|
343 | + $arrayofvat = $tablocaltax1; |
|
344 | + } |
|
345 | + if ($numtax == 2) { |
|
346 | + $arrayofvat = $tablocaltax2; |
|
347 | + } |
|
323 | 348 | |
324 | 349 | foreach ( $arrayofvat[$key] as $k => $mt ) { |
325 | 350 | if ($mt) { |
@@ -346,13 +371,14 @@ discard block |
||
346 | 371 | |
347 | 372 | $result = $bookkeeping->create($user); |
348 | 373 | if ($result < 0) { |
349 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
374 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
375 | + // Already exists |
|
350 | 376 | { |
351 | 377 | $error++; |
378 | + } |
|
352 | 379 | $errorforline++; |
353 | 380 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
354 | - } |
|
355 | - else |
|
381 | + } else |
|
356 | 382 | { |
357 | 383 | $error++; |
358 | 384 | $errorforline++; |
@@ -367,8 +393,7 @@ discard block |
||
367 | 393 | if (! $errorforline) |
368 | 394 | { |
369 | 395 | $db->commit(); |
370 | - } |
|
371 | - else |
|
396 | + } else |
|
372 | 397 | { |
373 | 398 | $db->rollback(); |
374 | 399 | |
@@ -382,12 +407,10 @@ discard block |
||
382 | 407 | |
383 | 408 | if (empty($error) && count($tabpay) > 0) { |
384 | 409 | setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
385 | - } |
|
386 | - elseif (count($tabpay) == $error) |
|
410 | + } elseif (count($tabpay) == $error) |
|
387 | 411 | { |
388 | 412 | setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
389 | - } |
|
390 | - else |
|
413 | + } else |
|
391 | 414 | { |
392 | 415 | setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
393 | 416 | } |
@@ -482,8 +505,12 @@ discard block |
||
482 | 505 | $listoftax = array(0, 1, 2); |
483 | 506 | foreach ($listoftax as $numtax) { |
484 | 507 | $arrayofvat = $tabtva; |
485 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
486 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
508 | + if ($numtax == 1) { |
|
509 | + $arrayofvat = $tablocaltax1; |
|
510 | + } |
|
511 | + if ($numtax == 2) { |
|
512 | + $arrayofvat = $tablocaltax2; |
|
513 | + } |
|
487 | 514 | |
488 | 515 | foreach ($arrayofvat[$key] as $k => $mt) { |
489 | 516 | if ($mt) { |
@@ -537,8 +564,7 @@ discard block |
||
537 | 564 | print '<div class="tabsAction tabsActionNoBottom">'; |
538 | 565 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
539 | 566 | print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
540 | - } |
|
541 | - else { |
|
567 | + } else { |
|
542 | 568 | print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
543 | 569 | } |
544 | 570 | print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
@@ -610,8 +636,9 @@ discard block |
||
610 | 636 | if (empty($accountoshow) || $accountoshow == 'NotDefined') |
611 | 637 | { |
612 | 638 | print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>'; |
639 | + } else { |
|
640 | + print $accountoshow; |
|
613 | 641 | } |
614 | - else print $accountoshow; |
|
615 | 642 | print '</td>'; |
616 | 643 | // Subledger account |
617 | 644 | print "<td>"; |
@@ -619,8 +646,9 @@ discard block |
||
619 | 646 | if (empty($accountoshow) || $accountoshow == 'NotDefined') |
620 | 647 | { |
621 | 648 | print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
649 | + } else { |
|
650 | + print $accountoshow; |
|
622 | 651 | } |
623 | - else print $accountoshow; |
|
624 | 652 | print '</td>'; |
625 | 653 | print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; |
626 | 654 | print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; |
@@ -644,8 +672,9 @@ discard block |
||
644 | 672 | if (empty($accountoshow) || $accountoshow == 'NotDefined') |
645 | 673 | { |
646 | 674 | print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>'; |
675 | + } else { |
|
676 | + print $accountoshow; |
|
647 | 677 | } |
648 | - else print $accountoshow; |
|
649 | 678 | print "</td>"; |
650 | 679 | // Subledger account |
651 | 680 | print "<td>"; |
@@ -663,8 +692,12 @@ discard block |
||
663 | 692 | $listoftax = array(0, 1, 2); |
664 | 693 | foreach ($listoftax as $numtax) { |
665 | 694 | $arrayofvat = $tabtva; |
666 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
667 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
695 | + if ($numtax == 1) { |
|
696 | + $arrayofvat = $tablocaltax1; |
|
697 | + } |
|
698 | + if ($numtax == 2) { |
|
699 | + $arrayofvat = $tablocaltax2; |
|
700 | + } |
|
668 | 701 | |
669 | 702 | foreach ( $arrayofvat[$key] as $k => $mt ) { |
670 | 703 | if ($mt) { |
@@ -678,8 +711,9 @@ discard block |
||
678 | 711 | if (empty($accountoshow) || $accountoshow == 'NotDefined') |
679 | 712 | { |
680 | 713 | print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>'; |
714 | + } else { |
|
715 | + print $accountoshow; |
|
681 | 716 | } |
682 | - else print $accountoshow; |
|
683 | 717 | print "</td>"; |
684 | 718 | // Subledger account |
685 | 719 | print "<td>"; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $bookkeeping->doc_type = 'customer_invoice'; |
296 | 296 | $bookkeeping->fk_doc = $key; |
297 | 297 | $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
298 | - $bookkeeping->thirdparty_code = $companystatic->code_client; |
|
298 | + $bookkeeping->thirdparty_code = $companystatic->code_client; |
|
299 | 299 | $bookkeeping->subledger_account = ''; |
300 | 300 | $bookkeeping->subledger_label = ''; |
301 | 301 | $bookkeeping->numero_compte = $k; |
@@ -550,12 +550,12 @@ discard block |
||
550 | 550 | |
551 | 551 | // Button to write into Ledger |
552 | 552 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
553 | - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
554 | - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
|
553 | + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
554 | + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
|
555 | 555 | } |
556 | 556 | print '<div class="tabsAction tabsActionNoBottom">'; |
557 | 557 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
558 | - print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
558 | + print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
559 | 559 | } |
560 | 560 | else { |
561 | 561 | print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | */ |
31 | 31 | |
32 | 32 | require '../../main.inc.php'; |
33 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; |
|
37 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; |
|
38 | -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
|
39 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; |
|
40 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; |
|
37 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
38 | +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
39 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; |
|
40 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
41 | 41 | |
42 | -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors")); |
|
42 | +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors")); |
|
43 | 43 | |
44 | 44 | $id_journal = GETPOST('id_journal', 'int'); |
45 | -$action = GETPOST('action','aZ09'); |
|
45 | +$action = GETPOST('action', 'aZ09'); |
|
46 | 46 | |
47 | 47 | $date_startmonth = GETPOST('date_startmonth'); |
48 | 48 | $date_startday = GETPOST('date_startday'); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $pastmonthyear = $year_current; |
76 | 76 | if ($pastmonth == 0) { |
77 | 77 | $pastmonth = 12; |
78 | - $pastmonthyear --; |
|
78 | + $pastmonthyear--; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); |
@@ -94,71 +94,71 @@ discard block |
||
94 | 94 | $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; |
95 | 95 | $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; |
96 | 96 | //$sql .= " ct.accountancy_code_sell as account_tva"; |
97 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; |
|
98 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; |
|
99 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
100 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; |
|
101 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; |
|
97 | +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
98 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; |
|
99 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; |
|
100 | +$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; |
|
101 | +$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; |
|
102 | 102 | //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'"; |
103 | 103 | $sql .= " WHERE fd.fk_code_ventilation > 0"; |
104 | -$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy |
|
104 | +$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy |
|
105 | 105 | $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ? |
106 | -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
107 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; |
|
106 | +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
107 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; |
|
108 | 108 | } else { |
109 | - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; |
|
109 | + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
|
110 | 110 | } |
111 | 111 | $sql .= " AND fd.product_type IN (0,1)"; |
112 | 112 | if ($date_start && $date_end) |
113 | - $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; |
|
113 | + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
114 | 114 | if ($in_bookkeeping == 'already') |
115 | - $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; |
|
115 | + $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; |
|
116 | 116 | if ($in_bookkeeping == 'notyet') |
117 | - $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; |
|
117 | + $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; |
|
118 | 118 | $sql .= " ORDER BY f.datef"; |
119 | 119 | |
120 | 120 | dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); |
121 | 121 | $result = $db->query($sql); |
122 | 122 | if ($result) { |
123 | - $tabfac = array (); |
|
124 | - $tabht = array (); |
|
125 | - $tabtva = array (); |
|
126 | - $def_tva = array (); |
|
127 | - $tabttc = array (); |
|
128 | - $tablocaltax1 = array (); |
|
129 | - $tablocaltax2 = array (); |
|
130 | - $tabcompany = array (); |
|
123 | + $tabfac = array(); |
|
124 | + $tabht = array(); |
|
125 | + $tabtva = array(); |
|
126 | + $def_tva = array(); |
|
127 | + $tabttc = array(); |
|
128 | + $tablocaltax1 = array(); |
|
129 | + $tablocaltax2 = array(); |
|
130 | + $tabcompany = array(); |
|
131 | 131 | |
132 | 132 | $num = $db->num_rows($result); |
133 | 133 | |
134 | 134 | // Variables |
135 | - $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'; |
|
136 | - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; |
|
135 | + $cptcli = (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'; |
|
136 | + $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; |
|
137 | 137 | |
138 | 138 | $i = 0; |
139 | - while ( $i < $num ) { |
|
139 | + while ($i < $num) { |
|
140 | 140 | $obj = $db->fetch_object($result); |
141 | 141 | |
142 | 142 | // Controls |
143 | - $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; |
|
143 | + $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli; |
|
144 | 144 | |
145 | 145 | $compta_prod = $obj->compte; |
146 | 146 | if (empty($compta_prod)) { |
147 | 147 | if ($obj->product_type == 0) |
148 | - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; |
|
148 | + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; |
|
149 | 149 | else |
150 | - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; |
|
150 | + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; |
|
151 | 151 | } |
152 | 152 | |
153 | - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); |
|
154 | - $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
155 | - $compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
156 | - $compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
153 | + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); |
|
154 | + $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
155 | + $compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
156 | + $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
157 | 157 | |
158 | 158 | // Define array to display all VAT rates that use this accounting account $compta_tva |
159 | - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) |
|
159 | + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) |
|
160 | 160 | { |
161 | - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); |
|
161 | + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Situation invoices handling |
@@ -185,25 +185,25 @@ discard block |
||
185 | 185 | //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; |
186 | 186 | |
187 | 187 | // Avoid warnings |
188 | - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
189 | - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
190 | - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
191 | - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
192 | - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
188 | + if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
189 | + if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
190 | + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
191 | + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
192 | + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
193 | 193 | |
194 | 194 | $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; |
195 | 195 | $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; |
196 | 196 | $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; |
197 | 197 | $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio; |
198 | 198 | $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio; |
199 | - $tabcompany[$obj->rowid] = array ( |
|
199 | + $tabcompany[$obj->rowid] = array( |
|
200 | 200 | 'id' => $obj->socid, |
201 | 201 | 'name' => $obj->name, |
202 | 202 | 'code_client' => $obj->code_client, |
203 | 203 | 'code_compta' => $compta_soc |
204 | 204 | ); |
205 | 205 | |
206 | - $i ++; |
|
206 | + $i++; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | 209 | dol_print_error($db); |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | $invoicestatic->ref = (string) $val["ref"]; |
236 | 236 | |
237 | 237 | // Thirdparty |
238 | - if (! $errorforline) |
|
238 | + if (!$errorforline) |
|
239 | 239 | { |
240 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
240 | + foreach ($tabttc[$key] as $k => $mt) { |
|
241 | 241 | if ($mt) { |
242 | 242 | $bookkeeping = new BookKeeping($db); |
243 | 243 | $bookkeeping->doc_date = $val["date"]; |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | $bookkeeping->date_create = $now; |
247 | 247 | $bookkeeping->doc_type = 'customer_invoice'; |
248 | 248 | $bookkeeping->fk_doc = $key; |
249 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
249 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
250 | 250 | $bookkeeping->thirdparty_code = $companystatic->code_client; |
251 | 251 | $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; |
252 | - $bookkeeping->subledger_label = ''; // TODO To complete |
|
252 | + $bookkeeping->subledger_label = ''; // TODO To complete |
|
253 | 253 | $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; |
254 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount"); |
|
254 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount"); |
|
255 | 255 | $bookkeeping->montant = $mt; |
256 | 256 | $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
257 | 257 | $bookkeeping->debit = ($mt >= 0) ? $mt : 0; |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | // Product / Service |
283 | - if (! $errorforline) |
|
283 | + if (!$errorforline) |
|
284 | 284 | { |
285 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
285 | + foreach ($tabht[$key] as $k => $mt) { |
|
286 | 286 | if ($mt) { |
287 | 287 | // get compte id and label |
288 | 288 | $accountingaccount = new AccountingAccount($db); |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | $bookkeeping->date_create = $now; |
295 | 295 | $bookkeeping->doc_type = 'customer_invoice'; |
296 | 296 | $bookkeeping->fk_doc = $key; |
297 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
297 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
298 | 298 | $bookkeeping->thirdparty_code = $companystatic->code_client; |
299 | 299 | $bookkeeping->subledger_account = ''; |
300 | 300 | $bookkeeping->subledger_label = ''; |
301 | 301 | $bookkeeping->numero_compte = $k; |
302 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; |
|
302 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label; |
|
303 | 303 | $bookkeeping->montant = $mt; |
304 | 304 | $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
305 | 305 | $bookkeeping->debit = ($mt < 0) ? -$mt : 0; |
@@ -330,16 +330,16 @@ discard block |
||
330 | 330 | |
331 | 331 | // VAT |
332 | 332 | // var_dump($tabtva); |
333 | - if (! $errorforline) |
|
333 | + if (!$errorforline) |
|
334 | 334 | { |
335 | - $listoftax=array(0, 1, 2); |
|
336 | - foreach($listoftax as $numtax) |
|
335 | + $listoftax = array(0, 1, 2); |
|
336 | + foreach ($listoftax as $numtax) |
|
337 | 337 | { |
338 | 338 | $arrayofvat = $tabtva; |
339 | 339 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
340 | 340 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
341 | 341 | |
342 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
342 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
343 | 343 | if ($mt) { |
344 | 344 | $bookkeeping = new BookKeeping($db); |
345 | 345 | $bookkeeping->doc_date = $val["date"]; |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | $bookkeeping->date_create = $now; |
349 | 349 | $bookkeeping->doc_type = 'customer_invoice'; |
350 | 350 | $bookkeeping->fk_doc = $key; |
351 | - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
351 | + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add |
|
352 | 352 | $bookkeeping->thirdparty_code = $companystatic->code_client; |
353 | 353 | $bookkeeping->subledger_account = ''; |
354 | 354 | $bookkeeping->subledger_label = ''; |
355 | 355 | $bookkeeping->numero_compte = $k; |
356 | - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:''); |
|
356 | + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); |
|
357 | 357 | $bookkeeping->montant = $mt; |
358 | 358 | $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
359 | 359 | $bookkeeping->debit = ($mt < 0) ? -$mt : 0; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
385 | - if (! $errorforline) |
|
385 | + if (!$errorforline) |
|
386 | 386 | { |
387 | 387 | $db->commit(); |
388 | 388 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if ($error >= 10) |
394 | 394 | { |
395 | 395 | setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); |
396 | - break; // Break in the foreach |
|
396 | + break; // Break in the foreach |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -411,20 +411,20 @@ discard block |
||
411 | 411 | setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
412 | 412 | } |
413 | 413 | |
414 | - $action=''; |
|
414 | + $action = ''; |
|
415 | 415 | |
416 | 416 | // Must reload data, so we make a redirect |
417 | 417 | if (count($tabpay) != $error) |
418 | 418 | { |
419 | - $param='id_journal='.$id_journal; |
|
420 | - $param.='&date_startday='.$date_startday; |
|
421 | - $param.='&date_startmonth='.$date_startmonth; |
|
422 | - $param.='&date_startyear='.$date_startyear; |
|
423 | - $param.='&date_endday='.$date_endday; |
|
424 | - $param.='&date_endmonth='.$date_endmonth; |
|
425 | - $param.='&date_endyear='.$date_endyear; |
|
426 | - $param.='&in_bookeeping='.$in_bookeeping; |
|
427 | - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); |
|
419 | + $param = 'id_journal='.$id_journal; |
|
420 | + $param .= '&date_startday='.$date_startday; |
|
421 | + $param .= '&date_startmonth='.$date_startmonth; |
|
422 | + $param .= '&date_startyear='.$date_startyear; |
|
423 | + $param .= '&date_endday='.$date_endday; |
|
424 | + $param .= '&date_endmonth='.$date_endmonth; |
|
425 | + $param .= '&date_endyear='.$date_endyear; |
|
426 | + $param .= '&in_bookeeping='.$in_bookeeping; |
|
427 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
428 | 428 | exit; |
429 | 429 | } |
430 | 430 | } |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | |
443 | 443 | $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; |
444 | 444 | |
445 | - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
|
445 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
446 | 446 | |
447 | 447 | $companystatic = new Client($db); |
448 | 448 | $invoicestatic = new Facture($db); |
449 | 449 | |
450 | - foreach ( $tabfac as $key => $val ) |
|
450 | + foreach ($tabfac as $key => $val) |
|
451 | 451 | { |
452 | 452 | $companystatic->id = $tabcompany[$key]['id']; |
453 | 453 | $companystatic->name = $tabcompany[$key]['name']; |
@@ -460,18 +460,18 @@ discard block |
||
460 | 460 | |
461 | 461 | // Third party |
462 | 462 | foreach ($tabttc[$key] as $k => $mt) { |
463 | - print '"' . $key . '"' . $sep; |
|
464 | - print '"' . $date . '"' . $sep; |
|
465 | - print '"' . $val["ref"] . '"' . $sep; |
|
466 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; |
|
467 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
468 | - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; |
|
469 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
470 | - print '"' . $langs->trans("Code_tiers") . '"' . $sep; |
|
471 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; |
|
472 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
473 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
474 | - print '"' . $journal . '"'; |
|
463 | + print '"'.$key.'"'.$sep; |
|
464 | + print '"'.$date.'"'.$sep; |
|
465 | + print '"'.$val["ref"].'"'.$sep; |
|
466 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
467 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
468 | + print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep; |
|
469 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
470 | + print '"'.$langs->trans("Code_tiers").'"'.$sep; |
|
471 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Code_tiers").'"'.$sep; |
|
472 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
473 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
474 | + print '"'.$journal.'"'; |
|
475 | 475 | print "\n"; |
476 | 476 | } |
477 | 477 | |
@@ -480,18 +480,18 @@ discard block |
||
480 | 480 | $accountingaccount = new AccountingAccount($db); |
481 | 481 | $accountingaccount->fetch(null, $k, true); |
482 | 482 | if ($mt) { |
483 | - print '"' . $key . '"' . $sep; |
|
484 | - print '"' . $date . '"' . $sep; |
|
485 | - print '"' . $val["ref"] . '"' . $sep; |
|
486 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; |
|
487 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
488 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
489 | - print '""' . $sep; |
|
490 | - print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; |
|
491 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; |
|
492 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
493 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
494 | - print '"' . $journal . '"'; |
|
483 | + print '"'.$key.'"'.$sep; |
|
484 | + print '"'.$date.'"'.$sep; |
|
485 | + print '"'.$val["ref"].'"'.$sep; |
|
486 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
487 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
488 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
489 | + print '""'.$sep; |
|
490 | + print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; |
|
491 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; |
|
492 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
493 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
494 | + print '"'.$journal.'"'; |
|
495 | 495 | print "\n"; |
496 | 496 | } |
497 | 497 | } |
@@ -505,18 +505,18 @@ discard block |
||
505 | 505 | |
506 | 506 | foreach ($arrayofvat[$key] as $k => $mt) { |
507 | 507 | if ($mt) { |
508 | - print '"' . $key . '"' . $sep; |
|
509 | - print '"' . $date . '"' . $sep; |
|
510 | - print '"' . $val["ref"] . '"' . $sep; |
|
511 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; |
|
512 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
513 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
514 | - print '""' . $sep; |
|
515 | - print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep; |
|
516 | - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep; |
|
517 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
518 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
519 | - print '"' . $journal . '"'; |
|
508 | + print '"'.$key.'"'.$sep; |
|
509 | + print '"'.$date.'"'.$sep; |
|
510 | + print '"'.$val["ref"].'"'.$sep; |
|
511 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; |
|
512 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
513 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
514 | + print '""'.$sep; |
|
515 | + print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$sep; |
|
516 | + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; |
|
517 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
518 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
519 | + print '"'.$journal.'"'; |
|
520 | 520 | print "\n"; |
521 | 521 | } |
522 | 522 | } |
@@ -530,21 +530,21 @@ discard block |
||
530 | 530 | |
531 | 531 | llxHeader('', $langs->trans("SellsJournal")); |
532 | 532 | |
533 | - $nom = $langs->trans("SellsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); |
|
533 | + $nom = $langs->trans("SellsJournal").' - '.$accountingjournalstatic->getNomUrl(1); |
|
534 | 534 | $nomlink = ''; |
535 | 535 | $periodlink = ''; |
536 | 536 | $exportlink = ''; |
537 | - $builddate=dol_now(); |
|
538 | - $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
539 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) |
|
537 | + $builddate = dol_now(); |
|
538 | + $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
539 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) |
|
540 | 540 | $description .= $langs->trans("DepositsAreNotIncluded"); |
541 | 541 | else |
542 | 542 | $description .= $langs->trans("DepositsAreIncluded"); |
543 | 543 | |
544 | - $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
545 | - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
544 | + $listofchoices = array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
545 | + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1).' - '.$form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1).' - '.$langs->trans("AlreadyInGeneralLedger").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
546 | 546 | |
547 | - $varlink = 'id_journal=' . $id_journal; |
|
547 | + $varlink = 'id_journal='.$id_journal; |
|
548 | 548 | |
549 | 549 | journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
550 | 550 | |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | } |
556 | 556 | print '<div class="tabsAction tabsActionNoBottom">'; |
557 | 557 | if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
558 | - print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
558 | + print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
559 | 559 | } |
560 | 560 | else { |
561 | - print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
561 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
562 | 562 | } |
563 | - print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
|
563 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
564 | 564 | print '</div>'; |
565 | 565 | |
566 | 566 | // TODO Avoid using js. We can use a direct link with $param |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | print "<table class=\"noborder\" width=\"100%\">"; |
589 | 589 | print "<tr class=\"liste_titre\">"; |
590 | 590 | print "<td></td>"; |
591 | - print "<td>" . $langs->trans("Date") . "</td>"; |
|
592 | - print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; |
|
593 | - print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
594 | - print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
595 | - print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
596 | - print "<td align='right'>" . $langs->trans("Debit") . "</td>"; |
|
597 | - print "<td align='right'>" . $langs->trans("Credit") . "</td>"; |
|
591 | + print "<td>".$langs->trans("Date")."</td>"; |
|
592 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>"; |
|
593 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
594 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
595 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
596 | + print "<td align='right'>".$langs->trans("Debit")."</td>"; |
|
597 | + print "<td align='right'>".$langs->trans("Credit")."</td>"; |
|
598 | 598 | print "</tr>\n"; |
599 | 599 | |
600 | 600 | $r = ''; |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $invoicestatic = new Facture($db); |
603 | 603 | $companystatic = new Client($db); |
604 | 604 | |
605 | - foreach ( $tabfac as $key => $val ) { |
|
605 | + foreach ($tabfac as $key => $val) { |
|
606 | 606 | $invoicestatic->id = $key; |
607 | 607 | $invoicestatic->ref = $val["ref"]; |
608 | 608 | $invoicestatic->type = $val["type"]; |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | $date = dol_print_date($val["date"], 'day'); |
611 | 611 | |
612 | 612 | // Third party |
613 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
613 | + foreach ($tabttc[$key] as $k => $mt) { |
|
614 | 614 | print '<tr class="oddeven">'; |
615 | 615 | print "<td><!-- Thirdparty --></td>"; |
616 | - print "<td>" . $date . "</td>"; |
|
617 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
616 | + print "<td>".$date."</td>"; |
|
617 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
618 | 618 | $companystatic->id = $tabcompany[$key]['id']; |
619 | 619 | $companystatic->name = $tabcompany[$key]['name']; |
620 | 620 | $companystatic->customer_code = $tabcompany[$key]['code_client']; |
@@ -636,22 +636,22 @@ discard block |
||
636 | 636 | } |
637 | 637 | else print $accountoshow; |
638 | 638 | print '</td>'; |
639 | - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; |
|
640 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
641 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
639 | + print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>"; |
|
640 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
641 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
642 | 642 | print "</tr>"; |
643 | 643 | } |
644 | 644 | |
645 | 645 | // Product / Service |
646 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
646 | + foreach ($tabht[$key] as $k => $mt) { |
|
647 | 647 | $accountingaccount = new AccountingAccount($db); |
648 | 648 | $accountingaccount->fetch(null, $k, true); |
649 | 649 | |
650 | 650 | if ($mt) { |
651 | 651 | print '<tr class="oddeven">'; |
652 | 652 | print "<td><!-- Product --></td>"; |
653 | - print "<td>" . $date . "</td>"; |
|
654 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
653 | + print "<td>".$date."</td>"; |
|
654 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
655 | 655 | // Account |
656 | 656 | print "<td>"; |
657 | 657 | $accountoshow = length_accountg($k); |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | print '</td>'; |
667 | 667 | $companystatic->id = $tabcompany[$key]['id']; |
668 | 668 | $companystatic->name = $tabcompany[$key]['name']; |
669 | - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>"; |
|
670 | - print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
671 | - print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
669 | + print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label."</td>"; |
|
670 | + print "<td align='right'>".($mt < 0 ? price(-$mt) : '')."</td>"; |
|
671 | + print "<td align='right'>".($mt >= 0 ? price($mt) : '')."</td>"; |
|
672 | 672 | print "</tr>"; |
673 | 673 | } |
674 | 674 | } |
@@ -680,12 +680,12 @@ discard block |
||
680 | 680 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
681 | 681 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
682 | 682 | |
683 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
683 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
684 | 684 | if ($mt) { |
685 | 685 | print '<tr class="oddeven">'; |
686 | 686 | print "<td><!-- VAT --></td>"; |
687 | - print "<td>" . $date . "</td>"; |
|
688 | - print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; |
|
687 | + print "<td>".$date."</td>"; |
|
688 | + print "<td>".$invoicestatic->getNomUrl(1)."</td>"; |
|
689 | 689 | // Account |
690 | 690 | print "<td>"; |
691 | 691 | $accountoshow = length_accountg($k); |
@@ -698,10 +698,10 @@ discard block |
||
698 | 698 | // Subledger account |
699 | 699 | print "<td>"; |
700 | 700 | print '</td>'; |
701 | - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); |
|
701 | + print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); |
|
702 | 702 | print "</td>"; |
703 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
704 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
703 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
704 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
705 | 705 | print "</tr>"; |
706 | 706 | } |
707 | 707 | } |
@@ -28,48 +28,48 @@ discard block |
||
28 | 28 | * \brief Page with bank journal |
29 | 29 | */ |
30 | 30 | require '../../main.inc.php'; |
31 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
37 | -require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; |
|
38 | -require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; |
|
39 | -require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; |
|
40 | -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; |
|
41 | -require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; |
|
42 | -require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; |
|
43 | -require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; |
|
44 | -require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php'; |
|
45 | -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
|
46 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; |
|
47 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
|
48 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; |
|
49 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
50 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; |
|
51 | -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; |
|
52 | -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; |
|
53 | -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; |
|
54 | -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
|
55 | - |
|
56 | -$langs->loadLangs(array("companies","other","compta","banks",'bills','donations',"accountancy","trips","salaries","hrm")); |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
37 | +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
|
38 | +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
39 | +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
|
40 | +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; |
|
41 | +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; |
|
42 | +require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; |
|
43 | +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; |
|
44 | +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; |
|
45 | +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
46 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; |
|
47 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
48 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
49 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
50 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; |
|
51 | +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
52 | +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; |
|
53 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; |
|
54 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
55 | + |
|
56 | +$langs->loadLangs(array("companies", "other", "compta", "banks", 'bills', 'donations', "accountancy", "trips", "salaries", "hrm")); |
|
57 | 57 | |
58 | 58 | // Multi journal |
59 | 59 | $id_journal = GETPOST('id_journal', 'int'); |
60 | 60 | |
61 | -$date_startmonth = GETPOST('date_startmonth','int'); |
|
62 | -$date_startday = GETPOST('date_startday','int'); |
|
63 | -$date_startyear = GETPOST('date_startyear','int'); |
|
64 | -$date_endmonth = GETPOST('date_endmonth','int'); |
|
65 | -$date_endday = GETPOST('date_endday','int'); |
|
66 | -$date_endyear = GETPOST('date_endyear','int'); |
|
67 | -$in_bookkeeping = GETPOST('in_bookkeeping','aZ09'); |
|
61 | +$date_startmonth = GETPOST('date_startmonth', 'int'); |
|
62 | +$date_startday = GETPOST('date_startday', 'int'); |
|
63 | +$date_startyear = GETPOST('date_startyear', 'int'); |
|
64 | +$date_endmonth = GETPOST('date_endmonth', 'int'); |
|
65 | +$date_endday = GETPOST('date_endday', 'int'); |
|
66 | +$date_endyear = GETPOST('date_endyear', 'int'); |
|
67 | +$in_bookkeeping = GETPOST('in_bookkeeping', 'aZ09'); |
|
68 | 68 | if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; |
69 | 69 | |
70 | 70 | $now = dol_now(); |
71 | 71 | |
72 | -$action = GETPOST('action','aZ09'); |
|
72 | +$action = GETPOST('action', 'aZ09'); |
|
73 | 73 | |
74 | 74 | // Security check |
75 | 75 | if ($user->societe_id > 0 && empty($id_journal)) |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $pastmonthyear = $year_current; |
88 | 88 | if ($pastmonth == 0) { |
89 | 89 | $pastmonth = 12; |
90 | - $pastmonthyear --; |
|
90 | + $pastmonthyear--; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); |
@@ -106,22 +106,22 @@ discard block |
||
106 | 106 | $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,"; |
107 | 107 | $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,"; |
108 | 108 | $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; |
109 | -$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; |
|
110 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; |
|
111 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; |
|
112 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; |
|
113 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; |
|
114 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; |
|
115 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; |
|
116 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; |
|
117 | -$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; |
|
118 | -$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy |
|
109 | +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; |
|
110 | +$sql .= " JOIN ".MAIN_DB_PREFIX."bank_account as ba on b.fk_account=ba.rowid"; |
|
111 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; |
|
112 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; |
|
113 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; |
|
114 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; |
|
115 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid"; |
|
116 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; |
|
117 | +$sql .= " WHERE ba.fk_accountancy_journal=".$id_journal; |
|
118 | +$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy |
|
119 | 119 | if ($date_start && $date_end) |
120 | - $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; |
|
120 | + $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; |
|
121 | 121 | if ($in_bookkeeping == 'already') |
122 | - $sql .= " AND (b.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; |
|
122 | + $sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; |
|
123 | 123 | if ($in_bookkeeping == 'notyet') |
124 | - $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; |
|
124 | + $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; |
|
125 | 125 | $sql .= " ORDER BY b.datev"; |
126 | 126 | //print $sql; |
127 | 127 | |
@@ -152,34 +152,34 @@ discard block |
||
152 | 152 | //print $sql; |
153 | 153 | |
154 | 154 | // Variables |
155 | - $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word |
|
156 | - $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word |
|
157 | - $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word |
|
158 | - $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word |
|
159 | - $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word |
|
160 | - $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word |
|
155 | + $account_supplier = (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word |
|
156 | + $account_customer = (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word |
|
157 | + $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word |
|
158 | + $account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word |
|
159 | + $account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word |
|
160 | + $account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word |
|
161 | 161 | |
162 | 162 | $tabcompany = array(); |
163 | 163 | $tabuser = array(); |
164 | - $tabpay = array (); |
|
165 | - $tabbq = array (); |
|
166 | - $tabtp = array (); |
|
167 | - $tabtype = array (); |
|
164 | + $tabpay = array(); |
|
165 | + $tabbq = array(); |
|
166 | + $tabtp = array(); |
|
167 | + $tabtype = array(); |
|
168 | 168 | |
169 | 169 | // Loop on each line into llx_bank table. For each line, we should get: |
170 | 170 | // one line tabpay = line into bank |
171 | 171 | // one line for bank record = tabbq |
172 | 172 | // one line for thirdparty record = tabtp |
173 | 173 | $i = 0; |
174 | - while ( $i < $num ) |
|
174 | + while ($i < $num) |
|
175 | 175 | { |
176 | 176 | $obj = $db->fetch_object($result); |
177 | 177 | |
178 | 178 | $lineisapurchase = -1; |
179 | 179 | $lineisasale = -1; |
180 | 180 | // Old method to detect if it's a sale or purchase |
181 | - if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1; |
|
182 | - if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1; |
|
181 | + if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase = 1; |
|
182 | + if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale = 1; |
|
183 | 183 | // Try a more reliable method to detect if record is a supplier payment or a customer payment |
184 | 184 | if ($lineisapurchase < 0) |
185 | 185 | { |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | // Set accountancy code for thirdparty |
199 | 199 | $compta_soc = 'NotDefined'; |
200 | 200 | if ($lineisapurchase > 0) |
201 | - $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); |
|
201 | + $compta_soc = (!empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); |
|
202 | 202 | if ($lineisasale > 0) |
203 | - $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); |
|
203 | + $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer); |
|
204 | 204 | |
205 | - $tabcompany[$obj->rowid] = array ( |
|
205 | + $tabcompany[$obj->rowid] = array( |
|
206 | 206 | 'id' => $obj->socid, |
207 | 207 | 'name' => $obj->name, |
208 | 208 | 'code_compta' => $compta_soc, |
209 | 209 | ); |
210 | 210 | |
211 | 211 | // Set accountancy code for user |
212 | - $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); |
|
212 | + $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); |
|
213 | 213 | |
214 | - $tabuser[$obj->rowid] = array ( |
|
214 | + $tabuser[$obj->rowid] = array( |
|
215 | 215 | 'id' => $obj->userid, |
216 | 216 | 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), |
217 | 217 | 'lastname' => $obj->lastname, |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | |
222 | 222 | // Variable bookkeeping |
223 | 223 | $tabpay[$obj->rowid]["date"] = $obj->do; |
224 | - $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... |
|
225 | - $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later |
|
224 | + $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... |
|
225 | + $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later |
|
226 | 226 | $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; |
227 | 227 | $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; |
228 | 228 | $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | //var_dump($tabpay); |
238 | 238 | |
239 | 239 | // By default |
240 | - $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. |
|
240 | + $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. |
|
241 | 241 | $tabtype[$obj->rowid] = 'unknown'; |
242 | 242 | |
243 | 243 | // get_url may return -1 which is not traversable |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | |
266 | 266 | if ($links[$key]['type'] == 'payment') { |
267 | 267 | $paymentstatic->id = $links[$key]['url_id']; |
268 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); |
|
268 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2); |
|
269 | 269 | $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
270 | 270 | } else if ($links[$key]['type'] == 'payment_supplier') { |
271 | 271 | $paymentsupplierstatic->id = $links[$key]['url_id']; |
272 | 272 | $paymentsupplierstatic->ref = $links[$key]['url_id']; |
273 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); |
|
273 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
274 | 274 | $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
275 | 275 | } else if ($links[$key]['type'] == 'company') { |
276 | 276 | $societestatic->id = $links[$key]['url_id']; |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | $userstatic->id = $links[$key]['url_id']; |
282 | 282 | $userstatic->name = $links[$key]['label']; |
283 | 283 | if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); |
284 | - else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
284 | + else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
285 | 285 | if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; |
286 | 286 | } else if ($links[$key]['type'] == 'sc') { |
287 | 287 | $chargestatic->id = $links[$key]['url_id']; |
288 | 288 | $chargestatic->ref = $links[$key]['url_id']; |
289 | 289 | |
290 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); |
|
290 | + $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
291 | 291 | if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
292 | 292 | if ($reg[1] == 'socialcontribution') |
293 | 293 | $reg[1] = 'SocialContribution'; |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
300 | 300 | |
301 | 301 | $sqlmid = 'SELECT cchgsoc.accountancy_code'; |
302 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; |
|
303 | - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; |
|
304 | - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; |
|
305 | - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; |
|
306 | - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; |
|
302 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc "; |
|
303 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; |
|
304 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; |
|
305 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; |
|
306 | + $sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid; |
|
307 | 307 | |
308 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); |
|
308 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
309 | 309 | $resultmid = $db->query($sqlmid); |
310 | 310 | if ($resultmid) { |
311 | 311 | $objmid = $db->fetch_object($resultmid); |
@@ -314,37 +314,37 @@ discard block |
||
314 | 314 | } else if ($links[$key]['type'] == 'payment_donation') { |
315 | 315 | $paymentdonstatic->id = $links[$key]['url_id']; |
316 | 316 | $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
317 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); |
|
317 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
318 | 318 | $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
319 | 319 | $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; |
320 | 320 | } else if ($links[$key]['type'] == 'payment_vat') { |
321 | 321 | $paymentvatstatic->id = $links[$key]['url_id']; |
322 | 322 | $paymentvatstatic->ref = $links[$key]['url_id']; |
323 | 323 | $paymentvatstatic->label = $links[$key]['label']; |
324 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); |
|
324 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
325 | 325 | $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
326 | 326 | $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; |
327 | 327 | } else if ($links[$key]['type'] == 'payment_salary') { |
328 | 328 | $paymentsalstatic->id = $links[$key]['url_id']; |
329 | 329 | $paymentsalstatic->ref = $links[$key]['url_id']; |
330 | 330 | $paymentsalstatic->label = $links[$key]['label']; |
331 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); |
|
331 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
332 | 332 | $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
333 | 333 | } else if ($links[$key]['type'] == 'payment_expensereport') { |
334 | 334 | $paymentexpensereportstatic->id = $links[$key]['url_id']; |
335 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); |
|
335 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentexpensereportstatic->getNomUrl(2); |
|
336 | 336 | $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
337 | 337 | } else if ($links[$key]['type'] == 'payment_various') { |
338 | 338 | $paymentvariousstatic->id = $links[$key]['url_id']; |
339 | 339 | $paymentvariousstatic->ref = $links[$key]['url_id']; |
340 | 340 | $paymentvariousstatic->label = $links[$key]['label']; |
341 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); |
|
341 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
342 | 342 | $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
343 | 343 | $paymentvariousstatic->fetch($paymentvariousstatic->id); |
344 | - $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
344 | + $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
345 | 345 | $tabtp[$obj->rowid][$account_various] += $obj->amount; |
346 | 346 | } else if ($links[$key]['type'] == 'banktransfert') { |
347 | - $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); |
|
347 | + $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer"); |
|
348 | 348 | $tabtp[$obj->rowid][$account_transfer] += $obj->amount; |
349 | 349 | $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
350 | 350 | $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $tabbq[$obj->rowid][$compta_bank] += $obj->amount; |
356 | 356 | |
357 | 357 | // If not links were found to know amount on thirdparty, we init it. |
358 | - if (empty($tabtp[$obj->rowid])) $tabtp[$obj->rowid]['NotDefined']= $tabbq[$obj->rowid][$compta_bank]; |
|
358 | + if (empty($tabtp[$obj->rowid])) $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
359 | 359 | |
360 | 360 | // Check account number is ok |
361 | 361 | /*if ($action == 'writebookkeeping') // Make test now in such a case |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | */ |
392 | 392 | |
393 | 393 | // Write bookkeeping |
394 | -if (! $error && $action == 'writebookkeeping') { |
|
394 | +if (!$error && $action == 'writebookkeeping') { |
|
395 | 395 | $now = dol_now(); |
396 | 396 | |
397 | 397 | $error = 0; |
398 | - foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank |
|
398 | + foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
399 | 399 | |
400 | 400 | $ref = getSourceDocRef($val, $tabtype[$key]); |
401 | 401 | |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | var_dump($tabbq);exit;*/ |
410 | 410 | |
411 | 411 | // Bank |
412 | - if (! $errorforline && is_array($tabbq[$key])) |
|
412 | + if (!$errorforline && is_array($tabbq[$key])) |
|
413 | 413 | { |
414 | 414 | // Line into bank account |
415 | - foreach ( $tabbq[$key] as $k => $mt ) |
|
415 | + foreach ($tabbq[$key] as $k => $mt) |
|
416 | 416 | { |
417 | 417 | if ($mt) { |
418 | 418 | $bookkeeping = new BookKeeping($db); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $bookkeeping->montant = $mt; |
427 | 427 | $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
428 | 428 | $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
429 | - $bookkeeping->credit = ($mt < 0 ? - $mt : 0); |
|
429 | + $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
430 | 430 | $bookkeeping->code_journal = $journal; |
431 | 431 | $bookkeeping->journal_label = $journal_label; |
432 | 432 | $bookkeeping->fk_user_author = $user->id; |
@@ -435,16 +435,16 @@ discard block |
||
435 | 435 | // No subledger_account value for the bank line but add a specific label_operation |
436 | 436 | if ($tabtype[$key] == 'payment') { |
437 | 437 | $bookkeeping->subledger_account = ''; |
438 | - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; |
|
438 | + $bookkeeping->label_operation = $tabcompany[$key]['name'].' - '.$ref; |
|
439 | 439 | } else if ($tabtype[$key] == 'payment_supplier') { |
440 | 440 | $bookkeeping->subledger_account = ''; |
441 | - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; |
|
441 | + $bookkeeping->label_operation = $tabcompany[$key]['name'].' - '.$ref; |
|
442 | 442 | } else if ($tabtype[$key] == 'payment_expensereport') { |
443 | 443 | $bookkeeping->subledger_account = ''; |
444 | - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; |
|
444 | + $bookkeeping->label_operation = $tabuser[$key]['name'].' - '.$ref; |
|
445 | 445 | } else if ($tabtype[$key] == 'payment_salary') { |
446 | 446 | $bookkeeping->subledger_account = ''; |
447 | - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; |
|
447 | + $bookkeeping->label_operation = $tabuser[$key]['name'].' - '.$ref; |
|
448 | 448 | } else if ($tabtype[$key] == 'payment_vat') { |
449 | 449 | $bookkeeping->subledger_account = ''; |
450 | 450 | $bookkeeping->label_operation = $ref; |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | // Third party |
482 | - if (! $errorforline && is_array($tabtp[$key])) |
|
482 | + if (!$errorforline && is_array($tabtp[$key])) |
|
483 | 483 | { |
484 | 484 | // Line into thirdparty account |
485 | - foreach ( $tabtp[$key] as $k => $mt ) { |
|
485 | + foreach ($tabtp[$key] as $k => $mt) { |
|
486 | 486 | if ($mt) { |
487 | 487 | $bookkeeping = new BookKeeping($db); |
488 | 488 | $bookkeeping->doc_date = $val["date"]; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $bookkeeping->fk_docdet = $val["fk_bank"]; |
493 | 493 | $bookkeeping->montant = $mt; |
494 | 494 | $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
495 | - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); |
|
495 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
496 | 496 | $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
497 | 497 | $bookkeeping->code_journal = $journal; |
498 | 498 | $bookkeeping->journal_label = $journal_label; |
@@ -500,25 +500,25 @@ discard block |
||
500 | 500 | $bookkeeping->date_create = $now; |
501 | 501 | |
502 | 502 | if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
503 | - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; |
|
503 | + $bookkeeping->label_operation = $tabcompany[$key]['name'].' - '.$ref; |
|
504 | 504 | $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; |
505 | 505 | $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
506 | 506 | $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; |
507 | 507 | $bookkeeping->label_compte = ''; |
508 | 508 | } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
509 | - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; |
|
509 | + $bookkeeping->label_operation = $tabcompany[$key]['name'].' - '.$ref; |
|
510 | 510 | $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; |
511 | 511 | $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
512 | 512 | $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; |
513 | 513 | $bookkeeping->label_compte = ''; |
514 | 514 | } else if ($tabtype[$key] == 'payment_expensereport') { |
515 | - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; |
|
515 | + $bookkeeping->label_operation = $tabuser[$key]['name'].' - '.$ref; |
|
516 | 516 | $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
517 | 517 | $bookkeeping->subledger_label = $tabuser[$key]['name']; |
518 | 518 | $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; |
519 | 519 | $bookkeeping->label_compte = ''; |
520 | 520 | } else if ($tabtype[$key] == 'payment_salary') { |
521 | - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; |
|
521 | + $bookkeeping->label_operation = $tabuser[$key]['name'].' - '.$ref; |
|
522 | 522 | $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
523 | 523 | $bookkeeping->subledger_label = $tabuser[$key]['name']; |
524 | 524 | $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - if (! $errorforline) |
|
587 | + if (!$errorforline) |
|
588 | 588 | { |
589 | 589 | $db->commit(); |
590 | 590 | } |
@@ -593,11 +593,11 @@ discard block |
||
593 | 593 | //print 'KO for line '.$key.' '.$error.'<br>'; |
594 | 594 | $db->rollback(); |
595 | 595 | |
596 | - $MAXNBERRORS=5; |
|
596 | + $MAXNBERRORS = 5; |
|
597 | 597 | if ($error >= $MAXNBERRORS) |
598 | 598 | { |
599 | 599 | setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
600 | - break; // Break in the foreach |
|
600 | + break; // Break in the foreach |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
@@ -619,15 +619,15 @@ discard block |
||
619 | 619 | // Must reload data, so we make a redirect |
620 | 620 | if (count($tabpay) != $error) |
621 | 621 | { |
622 | - $param='id_journal='.$id_journal; |
|
623 | - $param.='&date_startday='.$date_startday; |
|
624 | - $param.='&date_startmonth='.$date_startmonth; |
|
625 | - $param.='&date_startyear='.$date_startyear; |
|
626 | - $param.='&date_endday='.$date_endday; |
|
627 | - $param.='&date_endmonth='.$date_endmonth; |
|
628 | - $param.='&date_endyear='.$date_endyear; |
|
629 | - $param.='&in_bookeeping='.$in_bookeeping; |
|
630 | - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); |
|
622 | + $param = 'id_journal='.$id_journal; |
|
623 | + $param .= '&date_startday='.$date_startday; |
|
624 | + $param .= '&date_startmonth='.$date_startmonth; |
|
625 | + $param .= '&date_startyear='.$date_startyear; |
|
626 | + $param .= '&date_endday='.$date_endday; |
|
627 | + $param .= '&date_endmonth='.$date_endmonth; |
|
628 | + $param .= '&date_endyear='.$date_endyear; |
|
629 | + $param .= '&in_bookeeping='.$in_bookeeping; |
|
630 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
631 | 631 | exit; |
632 | 632 | } |
633 | 633 | } |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | if ($action == 'exportcsv') { // ISO and not UTF8 ! |
639 | 639 | $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; |
640 | 640 | |
641 | - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
|
641 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
642 | 642 | |
643 | 643 | $companystatic = new Client($db); |
644 | 644 | $userstatic = new User($db); |
645 | 645 | |
646 | - foreach ( $tabpay as $key => $val ) { |
|
646 | + foreach ($tabpay as $key => $val) { |
|
647 | 647 | $date = dol_print_date($db->jdate($val["date"]), 'day'); |
648 | 648 | |
649 | 649 | $ref = getSourceDocRef($val, $tabtype[$key]); |
650 | 650 | |
651 | 651 | // |
652 | - if (! empty($tabcompany[$key]['id'])) |
|
652 | + if (!empty($tabcompany[$key]['id'])) |
|
653 | 653 | { |
654 | 654 | $companystatic->id = $tabcompany[$key]['id']; |
655 | 655 | $companystatic->name = $tabcompany[$key]['name']; |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | $companystatic->id = 0; |
660 | 660 | $companystatic->name = ''; |
661 | 661 | } |
662 | - if (! empty($tabuser[$key]['id'])) |
|
662 | + if (!empty($tabuser[$key]['id'])) |
|
663 | 663 | { |
664 | 664 | $userstatic->id = $tabuser[$key]['id']; |
665 | 665 | $userstatic->lastname = $tabuser[$key]['lastname']; |
@@ -673,64 +673,64 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | // Bank |
676 | - foreach ( $tabbq[$key] as $k => $mt ) { |
|
677 | - print '"' . $journal . '"' . $sep; |
|
678 | - print '"' . $date . '"' . $sep; |
|
679 | - print '"' . $val["type_payment"] . '"' . $sep; |
|
680 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
681 | - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
682 | - print " " . $sep; |
|
676 | + foreach ($tabbq[$key] as $k => $mt) { |
|
677 | + print '"'.$journal.'"'.$sep; |
|
678 | + print '"'.$date.'"'.$sep; |
|
679 | + print '"'.$val["type_payment"].'"'.$sep; |
|
680 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
681 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
682 | + print " ".$sep; |
|
683 | 683 | if ($companystatic->name == '') { |
684 | - print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep; |
|
684 | + print '"'.$val['bank_account_ref']." - ".utf8_decode($reflabel).'"'.$sep; |
|
685 | 685 | } else { |
686 | - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; |
|
686 | + print '"'.$val['bank_account_ref'].' - '.utf8_decode($companystatic->name).'"'.$sep; |
|
687 | 687 | } |
688 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
689 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; |
|
688 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
689 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'; |
|
690 | 690 | print "\n"; |
691 | 691 | } |
692 | 692 | |
693 | 693 | // Third party |
694 | 694 | if (is_array($tabtp[$key])) { |
695 | - foreach ( $tabtp[$key] as $k => $mt ) { |
|
695 | + foreach ($tabtp[$key] as $k => $mt) { |
|
696 | 696 | if ($mt) { |
697 | - print '"' . $journal . '"' . $sep; |
|
698 | - print '"' . $date . '"' . $sep; |
|
699 | - print '"' . $val["type_payment"] . '"' . $sep; |
|
700 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
697 | + print '"'.$journal.'"'.$sep; |
|
698 | + print '"'.$date.'"'.$sep; |
|
699 | + print '"'.$val["type_payment"].'"'.$sep; |
|
700 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
701 | 701 | if ($tabtype[$key] == 'payment_supplier') { |
702 | - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; |
|
703 | - } else if($tabtype[$key] == 'payment') { |
|
704 | - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; |
|
702 | + print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep; |
|
703 | + } else if ($tabtype[$key] == 'payment') { |
|
704 | + print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep; |
|
705 | 705 | } else { |
706 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
706 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
707 | 707 | } |
708 | - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
708 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
709 | 709 | if ($companystatic->name == '') { |
710 | - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep; |
|
710 | + print '"'.$langs->trans('ThirdParty')." - ".utf8_decode($reflabel).'"'.$sep; |
|
711 | 711 | } else { |
712 | - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; |
|
712 | + print '"'.$langs->trans('ThirdParty')." - ".utf8_decode($companystatic->name).'"'.$sep; |
|
713 | 713 | } |
714 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
715 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; |
|
714 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
715 | + print '"'.($mt >= 0 ? price($mt) : '').'"'; |
|
716 | 716 | print "\n"; |
717 | 717 | } |
718 | 718 | } |
719 | 719 | } else { |
720 | - foreach ( $tabbq[$key] as $k => $mt ) { |
|
721 | - print '"' . $journal . '"' . $sep; |
|
722 | - print '"' . $date . '"' . $sep; |
|
723 | - print '"' . $val["type_payment"] . '"' . $sep; |
|
724 | - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; |
|
725 | - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; |
|
726 | - print " " . $sep; |
|
720 | + foreach ($tabbq[$key] as $k => $mt) { |
|
721 | + print '"'.$journal.'"'.$sep; |
|
722 | + print '"'.$date.'"'.$sep; |
|
723 | + print '"'.$val["type_payment"].'"'.$sep; |
|
724 | + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; |
|
725 | + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; |
|
726 | + print " ".$sep; |
|
727 | 727 | if ($companystatic->name == '') { |
728 | - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep; |
|
728 | + print '"'.$val['bank_account_ref'].' - '.utf8_decode($reflabel).'"'.$sep; |
|
729 | 729 | } else { |
730 | - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; |
|
730 | + print '"'.$val['bank_account_ref'].' - '.utf8_decode($companystatic->name).'"'.$sep; |
|
731 | 731 | } |
732 | - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; |
|
733 | - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; |
|
732 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
733 | + print '"'.($mt >= 0 ? price($mt) : '').'"'; |
|
734 | 734 | print "\n"; |
735 | 735 | } |
736 | 736 | } |
@@ -755,25 +755,25 @@ discard block |
||
755 | 755 | |
756 | 756 | llxHeader('', $langs->trans("FinanceJournal")); |
757 | 757 | |
758 | - $nom = $langs->trans("FinanceJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); |
|
759 | - $builddate=dol_now(); |
|
758 | + $nom = $langs->trans("FinanceJournal").' - '.$accountingjournalstatic->getNomUrl(1); |
|
759 | + $builddate = dol_now(); |
|
760 | 760 | //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
761 | - $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
761 | + $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
762 | 762 | |
763 | - $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
764 | - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
763 | + $listofchoices = array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
764 | + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1).' - '.$form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1).' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
765 | 765 | |
766 | - $varlink = 'id_journal=' . $id_journal; |
|
766 | + $varlink = 'id_journal='.$id_journal; |
|
767 | 767 | |
768 | 768 | journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
769 | 769 | |
770 | 770 | |
771 | 771 | // Test that setup is complete |
772 | - $sql='SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL'; |
|
773 | - $resql=$db->query($sql); |
|
772 | + $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL'; |
|
773 | + $resql = $db->query($sql); |
|
774 | 774 | if ($resql) |
775 | 775 | { |
776 | - $obj=$db->fetch_object($resql); |
|
776 | + $obj = $db->fetch_object($resql); |
|
777 | 777 | if ($obj->nb > 0) |
778 | 778 | { |
779 | 779 | print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
@@ -793,8 +793,8 @@ discard block |
||
793 | 793 | |
794 | 794 | |
795 | 795 | print '<div class="tabsAction tabsActionNoBottom">'; |
796 | - print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
797 | - print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
|
796 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
797 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
798 | 798 | print '</div>'; |
799 | 799 | |
800 | 800 | // TODO Avoid using js. We can use a direct link with $param |
@@ -824,32 +824,32 @@ discard block |
||
824 | 824 | print "<table class=\"noborder\" width=\"100%\">"; |
825 | 825 | print "<tr class=\"liste_titre\">"; |
826 | 826 | print "<td></td>"; |
827 | - print "<td>" . $langs->trans("Date") . "</td>"; |
|
828 | - print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>"; |
|
829 | - print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
830 | - print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
831 | - print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
832 | - print "<td>" . $langs->trans("PaymentMode") . "</td>"; |
|
833 | - print "<td align='right'>" . $langs->trans("Debit") . "</td>"; |
|
834 | - print "<td align='right'>" . $langs->trans("Credit") . "</td>"; |
|
827 | + print "<td>".$langs->trans("Date")."</td>"; |
|
828 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
829 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
830 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
831 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
832 | + print "<td>".$langs->trans("PaymentMode")."</td>"; |
|
833 | + print "<td align='right'>".$langs->trans("Debit")."</td>"; |
|
834 | + print "<td align='right'>".$langs->trans("Credit")."</td>"; |
|
835 | 835 | print "</tr>\n"; |
836 | 836 | |
837 | 837 | $r = ''; |
838 | 838 | |
839 | - foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank |
|
839 | + foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
840 | 840 | $date = dol_print_date($db->jdate($val["date"]), 'day'); |
841 | 841 | |
842 | 842 | $ref = getSourceDocRef($val, $tabtype[$key]); |
843 | 843 | |
844 | 844 | // Bank |
845 | - foreach ( $tabbq[$key] as $k => $mt ) |
|
845 | + foreach ($tabbq[$key] as $k => $mt) |
|
846 | 846 | { |
847 | 847 | //var_dump($tabpay[$key]); |
848 | 848 | print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
849 | 849 | print '<tr class="oddeven">'; |
850 | 850 | print "<td></td>"; |
851 | - print "<td>" . $date . "</td>"; |
|
852 | - print "<td>" . $ref . "</td>"; |
|
851 | + print "<td>".$date."</td>"; |
|
852 | + print "<td>".$ref."</td>"; |
|
853 | 853 | // Ledger account |
854 | 854 | print "<td>"; |
855 | 855 | $accounttoshow = length_accountg($k); |
@@ -872,25 +872,25 @@ discard block |
||
872 | 872 | //var_dump($tabpay[$key]); |
873 | 873 | print $langs->trans("Bank"); |
874 | 874 | print ' '.$val['bank_account_ref']; |
875 | - if (! empty($val['soclib'])) { |
|
876 | - print " - " . $val['soclib']; |
|
875 | + if (!empty($val['soclib'])) { |
|
876 | + print " - ".$val['soclib']; |
|
877 | 877 | } |
878 | 878 | print "</td>"; |
879 | - print "<td>" . $val["type_payment"] . "</td>"; |
|
880 | - print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
881 | - print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
879 | + print "<td>".$val["type_payment"]."</td>"; |
|
880 | + print "<td align='right'>".($mt >= 0 ? price($mt) : '')."</td>"; |
|
881 | + print "<td align='right'>".($mt < 0 ? price(-$mt) : '')."</td>"; |
|
882 | 882 | print "</tr>"; |
883 | 883 | } |
884 | 884 | |
885 | 885 | // Third party |
886 | 886 | if (is_array($tabtp[$key])) { |
887 | - foreach ( $tabtp[$key] as $k => $mt ) { |
|
887 | + foreach ($tabtp[$key] as $k => $mt) { |
|
888 | 888 | if ($k != 'type') { |
889 | 889 | print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
890 | 890 | print '<tr class="oddeven">'; |
891 | 891 | print "<td></td>"; |
892 | - print "<td>" . $date . "</td>"; |
|
893 | - print "<td>" . $ref . "</td>"; |
|
892 | + print "<td>".$date."</td>"; |
|
893 | + print "<td>".$ref."</td>"; |
|
894 | 894 | // Ledger account |
895 | 895 | print "<td>"; |
896 | 896 | $account_ledger = $k; |
@@ -906,17 +906,17 @@ discard block |
||
906 | 906 | if ($tabtype[$key] == 'unknown') |
907 | 907 | { |
908 | 908 | // We will accept writing, but into a waiting account |
909 | - print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will a waiting account |
|
909 | + print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will a waiting account |
|
910 | 910 | } |
911 | 911 | else |
912 | 912 | { |
913 | 913 | // We will refuse writing |
914 | - $errorstring='UnknownAccountForThirdpartyBlocking'; |
|
915 | - if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; |
|
916 | - if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; |
|
917 | - if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; |
|
918 | - if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; |
|
919 | - if ($tabtype[$key] == 'payment_vat') $errorstring='MainAccountForVatPaymentNotDefined'; |
|
914 | + $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
915 | + if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined'; |
|
916 | + if ($tabtype[$key] == 'payment_supplier') $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
917 | + if ($tabtype[$key] == 'payment_expensereport') $errorstring = 'MainAccountForUsersNotDefined'; |
|
918 | + if ($tabtype[$key] == 'payment_salary') $errorstring = 'MainAccountForUsersNotDefined'; |
|
919 | + if ($tabtype[$key] == 'payment_vat') $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
920 | 920 | print '<span class="error">'.$langs->trans($errorstring).'</span>'; |
921 | 921 | } |
922 | 922 | } |
@@ -941,20 +941,20 @@ discard block |
||
941 | 941 | } |
942 | 942 | } |
943 | 943 | print "</td>"; |
944 | - print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>"; |
|
945 | - print "<td>" . $val["type_payment"] . "</td>"; |
|
946 | - print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
947 | - print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
944 | + print "<td>".$reflabel.' '.$val['soclib']."</td>"; |
|
945 | + print "<td>".$val["type_payment"]."</td>"; |
|
946 | + print "<td align='right'>".($mt < 0 ? price(-$mt) : '')."</td>"; |
|
947 | + print "<td align='right'>".($mt >= 0 ? price($mt) : '')."</td>"; |
|
948 | 948 | print "</tr>"; |
949 | 949 | } |
950 | 950 | } |
951 | 951 | } else { |
952 | - foreach ( $tabbq[$key] as $k => $mt ) { |
|
952 | + foreach ($tabbq[$key] as $k => $mt) { |
|
953 | 953 | print '<!-- Wait bank.rowid='.$key.' -->'; |
954 | 954 | print '<tr class="oddeven">'; |
955 | 955 | print "<td></td>"; |
956 | - print "<td>" . $date . "</td>"; |
|
957 | - print "<td>" . $ref . "</td>"; |
|
956 | + print "<td>".$date."</td>"; |
|
957 | + print "<td>".$ref."</td>"; |
|
958 | 958 | // Ledger account |
959 | 959 | print "<td>"; |
960 | 960 | /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
@@ -972,10 +972,10 @@ discard block |
||
972 | 972 | else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); |
973 | 973 | */ |
974 | 974 | print "</td>"; |
975 | - print "<td>" . $reflabel . "</td>"; |
|
976 | - print "<td>" . $val["type_payment"] . "</td>"; |
|
977 | - print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
978 | - print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
975 | + print "<td>".$reflabel."</td>"; |
|
976 | + print "<td>".$val["type_payment"]."</td>"; |
|
977 | + print "<td align='right'>".($mt < 0 ? price(-$mt) : '')."</td>"; |
|
978 | + print "<td align='right'>".($mt >= 0 ? price($mt) : '')."</td>"; |
|
979 | 979 | print "</tr>"; |
980 | 980 | } |
981 | 981 | } |
@@ -1026,19 +1026,19 @@ discard block |
||
1026 | 1026 | if ($reflabel == '(payment_salary)') { |
1027 | 1027 | $reflabel = $langs->trans('Employee'); |
1028 | 1028 | } |
1029 | - $ref=$reflabel; |
|
1029 | + $ref = $reflabel; |
|
1030 | 1030 | if ($typerecord == 'payment') |
1031 | 1031 | { |
1032 | 1032 | $sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref'; |
1033 | 1033 | $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; |
1034 | - $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; |
|
1035 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1034 | + $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"]; |
|
1035 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1036 | 1036 | $resultmid = $db->query($sqlmid); |
1037 | 1037 | if ($resultmid) { |
1038 | - $ref=$langs->trans("Invoice"); |
|
1038 | + $ref = $langs->trans("Invoice"); |
|
1039 | 1039 | while ($objmid = $db->fetch_object($resultmid)) |
1040 | 1040 | { |
1041 | - $ref.=' '.$objmid->ref; |
|
1041 | + $ref .= ' '.$objmid->ref; |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | else dol_print_error($db); |
@@ -1046,15 +1046,15 @@ discard block |
||
1046 | 1046 | elseif ($typerecord == 'payment_supplier') |
1047 | 1047 | { |
1048 | 1048 | $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
1049 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1050 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; |
|
1051 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1049 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1050 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"]; |
|
1051 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1052 | 1052 | $resultmid = $db->query($sqlmid); |
1053 | 1053 | if ($resultmid) { |
1054 | - $ref=$langs->trans("SupplierInvoice"); |
|
1055 | - while($objmid = $db->fetch_object($resultmid)) |
|
1054 | + $ref = $langs->trans("SupplierInvoice"); |
|
1055 | + while ($objmid = $db->fetch_object($resultmid)) |
|
1056 | 1056 | { |
1057 | - $ref.=' '.$objmid->ref; |
|
1057 | + $ref .= ' '.$objmid->ref; |
|
1058 | 1058 | } |
1059 | 1059 | } |
1060 | 1060 | else dol_print_error($db); |
@@ -1062,15 +1062,15 @@ discard block |
||
1062 | 1062 | elseif ($typerecord == 'payment_expensereport') |
1063 | 1063 | { |
1064 | 1064 | $sqlmid = 'SELECT e.rowid as id, e.ref'; |
1065 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; |
|
1066 | - $sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; |
|
1067 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1065 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1066 | + $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; |
|
1067 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1068 | 1068 | $resultmid = $db->query($sqlmid); |
1069 | 1069 | if ($resultmid) { |
1070 | - $ref=$langs->trans("ExpenseReport"); |
|
1071 | - while($objmid = $db->fetch_object($resultmid)) |
|
1070 | + $ref = $langs->trans("ExpenseReport"); |
|
1071 | + while ($objmid = $db->fetch_object($resultmid)) |
|
1072 | 1072 | { |
1073 | - $ref.=' '.$objmid->ref; |
|
1073 | + $ref .= ' '.$objmid->ref; |
|
1074 | 1074 | } |
1075 | 1075 | } |
1076 | 1076 | else dol_print_error($db); |
@@ -1078,15 +1078,15 @@ discard block |
||
1078 | 1078 | elseif ($typerecord == 'payment_salary') |
1079 | 1079 | { |
1080 | 1080 | $sqlmid = 'SELECT s.rowid as ref'; |
1081 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; |
|
1082 | - $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; |
|
1083 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1081 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1082 | + $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"]; |
|
1083 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1084 | 1084 | $resultmid = $db->query($sqlmid); |
1085 | 1085 | if ($resultmid) { |
1086 | - $ref=$langs->trans("SalaryPayment"); |
|
1086 | + $ref = $langs->trans("SalaryPayment"); |
|
1087 | 1087 | while ($objmid = $db->fetch_object($resultmid)) |
1088 | 1088 | { |
1089 | - $ref.=' '.$objmid->ref; |
|
1089 | + $ref .= ' '.$objmid->ref; |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | else dol_print_error($db); |
@@ -1094,15 +1094,15 @@ discard block |
||
1094 | 1094 | elseif ($typerecord == 'payment_vat') |
1095 | 1095 | { |
1096 | 1096 | $sqlmid = 'SELECT v.rowid as ref'; |
1097 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; |
|
1098 | - $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; |
|
1099 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1097 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1098 | + $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"]; |
|
1099 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1100 | 1100 | $resultmid = $db->query($sqlmid); |
1101 | 1101 | if ($resultmid) { |
1102 | - $ref=$langs->trans("PaymentVat"); |
|
1102 | + $ref = $langs->trans("PaymentVat"); |
|
1103 | 1103 | while ($objmid = $db->fetch_object($resultmid)) |
1104 | 1104 | { |
1105 | - $ref.=' '.$objmid->ref; |
|
1105 | + $ref .= ' '.$objmid->ref; |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | else dol_print_error($db); |
@@ -1110,15 +1110,15 @@ discard block |
||
1110 | 1110 | elseif ($typerecord == 'payment_donation') |
1111 | 1111 | { |
1112 | 1112 | $sqlmid = 'SELECT payd.fk_donation as ref'; |
1113 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; |
|
1114 | - $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; |
|
1115 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1113 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1114 | + $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"]; |
|
1115 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1116 | 1116 | $resultmid = $db->query($sqlmid); |
1117 | 1117 | if ($resultmid) { |
1118 | - $ref=$langs->trans("Donation").' '; |
|
1118 | + $ref = $langs->trans("Donation").' '; |
|
1119 | 1119 | while ($objmid = $db->fetch_object($resultmid)) |
1120 | 1120 | { |
1121 | - $ref.=' '.$objmid->ref; |
|
1121 | + $ref .= ' '.$objmid->ref; |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | else dol_print_error($db); |
@@ -1126,15 +1126,15 @@ discard block |
||
1126 | 1126 | elseif ($typerecord == 'payment_various') |
1127 | 1127 | { |
1128 | 1128 | $sqlmid = 'SELECT v.rowid as ref'; |
1129 | - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; |
|
1130 | - $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; |
|
1131 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1129 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1130 | + $sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"]; |
|
1131 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1132 | 1132 | $resultmid = $db->query($sqlmid); |
1133 | 1133 | if ($resultmid) { |
1134 | - $ref=$langs->trans("VariousPayment"); |
|
1134 | + $ref = $langs->trans("VariousPayment"); |
|
1135 | 1135 | while ($objmid = $db->fetch_object($resultmid)) |
1136 | 1136 | { |
1137 | - $ref.=' '.$objmid->ref; |
|
1137 | + $ref .= ' '.$objmid->ref; |
|
1138 | 1138 | } |
1139 | 1139 | } |
1140 | 1140 | else dol_print_error($db); |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | * \brief Page with expense reports journal |
28 | 28 | */ |
29 | 29 | require '../../main.inc.php'; |
30 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; |
|
31 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; |
|
37 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
|
37 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
38 | 38 | |
39 | -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors")); |
|
39 | +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "trips", "errors")); |
|
40 | 40 | |
41 | 41 | $id_journal = GETPOST('id_journal', 'int'); |
42 | -$action = GETPOST('action','aZ09'); |
|
42 | +$action = GETPOST('action', 'aZ09'); |
|
43 | 43 | |
44 | 44 | $date_startmonth = GETPOST('date_startmonth'); |
45 | 45 | $date_startday = GETPOST('date_startday'); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $pastmonthyear = $year_current; |
72 | 72 | if ($pastmonth == 0) { |
73 | 73 | $pastmonth = 12; |
74 | - $pastmonthyear --; |
|
74 | + $pastmonthyear--; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); |
@@ -90,59 +90,59 @@ discard block |
||
90 | 90 | $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; |
91 | 91 | $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; |
92 | 92 | //$sql .= " ct.accountancy_code_buy as account_tva"; |
93 | -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; |
|
93 | +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; |
|
94 | 94 | //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; |
95 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; |
|
96 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; |
|
97 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; |
|
98 | -$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; |
|
95 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; |
|
96 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; |
|
97 | +$sql .= " JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; |
|
98 | +$sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; |
|
99 | 99 | $sql .= " WHERE er.fk_statut > 0"; |
100 | 100 | $sql .= " AND erd.fk_code_ventilation > 0"; |
101 | -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy |
|
101 | +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy |
|
102 | 102 | if ($date_start && $date_end) |
103 | - $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; |
|
103 | + $sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'"; |
|
104 | 104 | if ($in_bookkeeping == 'already') |
105 | - $sql .= " AND er.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; |
|
105 | + $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; |
|
106 | 106 | if ($in_bookkeeping == 'notyet') |
107 | - $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; |
|
107 | + $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; |
|
108 | 108 | $sql .= " ORDER BY er.date_debut"; |
109 | 109 | |
110 | 110 | dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); |
111 | 111 | $result = $db->query($sql); |
112 | 112 | if ($result) { |
113 | 113 | |
114 | - $taber = array (); |
|
115 | - $tabht = array (); |
|
116 | - $tabtva = array (); |
|
117 | - $def_tva = array (); |
|
118 | - $tabttc = array (); |
|
119 | - $tablocaltax1 = array (); |
|
120 | - $tablocaltax2 = array (); |
|
121 | - $tabuser = array (); |
|
114 | + $taber = array(); |
|
115 | + $tabht = array(); |
|
116 | + $tabtva = array(); |
|
117 | + $def_tva = array(); |
|
118 | + $tabttc = array(); |
|
119 | + $tablocaltax1 = array(); |
|
120 | + $tablocaltax2 = array(); |
|
121 | + $tabuser = array(); |
|
122 | 122 | |
123 | 123 | $num = $db->num_rows($result); |
124 | 124 | |
125 | 125 | // Variables |
126 | - $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; |
|
127 | - $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; |
|
126 | + $account_salary = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; |
|
127 | + $account_vat = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; |
|
128 | 128 | |
129 | 129 | $i = 0; |
130 | - while ( $i < $num ) { |
|
130 | + while ($i < $num) { |
|
131 | 131 | $obj = $db->fetch_object($result); |
132 | 132 | |
133 | 133 | // Controls |
134 | - $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; |
|
134 | + $compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; |
|
135 | 135 | $compta_fees = $obj->compte; |
136 | 136 | |
137 | - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); |
|
138 | - $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); |
|
139 | - $compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
140 | - $compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
137 | + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); |
|
138 | + $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); |
|
139 | + $compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
140 | + $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); |
|
141 | 141 | |
142 | 142 | // Define array to display all VAT rates that use this accounting account $compta_tva |
143 | - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) |
|
143 | + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) |
|
144 | 144 | { |
145 | - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); |
|
145 | + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $taber[$obj->rowid]["date"] = $db->jdate($obj->de); |
@@ -151,24 +151,24 @@ discard block |
||
151 | 151 | $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; |
152 | 152 | |
153 | 153 | // Avoid warnings |
154 | - if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; |
|
155 | - if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; |
|
156 | - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
157 | - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
158 | - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
154 | + if (!isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; |
|
155 | + if (!isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; |
|
156 | + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
157 | + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
158 | + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
159 | 159 | |
160 | 160 | $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; |
161 | 161 | $tabht[$obj->rowid][$compta_fees] += $obj->total_ht; |
162 | 162 | $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; |
163 | 163 | $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; |
164 | 164 | $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; |
165 | - $tabuser[$obj->rowid] = array ( |
|
165 | + $tabuser[$obj->rowid] = array( |
|
166 | 166 | 'id' => $obj->uid, |
167 | 167 | 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), |
168 | 168 | 'user_accountancy_code' => $obj->user_accountancy_account |
169 | 169 | ); |
170 | 170 | |
171 | - $i ++; |
|
171 | + $i++; |
|
172 | 172 | } |
173 | 173 | } else { |
174 | 174 | dol_print_error($db); |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | $db->begin(); |
187 | 187 | |
188 | 188 | // Thirdparty |
189 | - if (! $errorforline) |
|
189 | + if (!$errorforline) |
|
190 | 190 | { |
191 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
191 | + foreach ($tabttc[$key] as $k => $mt) { |
|
192 | 192 | if ($mt) { |
193 | 193 | $bookkeeping = new BookKeeping($db); |
194 | 194 | $bookkeeping->doc_date = $val["date"]; |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Fees |
232 | - if (! $errorforline) |
|
232 | + if (!$errorforline) |
|
233 | 233 | { |
234 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
234 | + foreach ($tabht[$key] as $k => $mt) { |
|
235 | 235 | if ($mt) { |
236 | 236 | // get compte id and label |
237 | 237 | $accountingaccount = new AccountingAccount($db); |
@@ -276,16 +276,16 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | // VAT |
279 | - if (! $errorforline) |
|
279 | + if (!$errorforline) |
|
280 | 280 | { |
281 | - $listoftax=array(0, 1, 2); |
|
282 | - foreach($listoftax as $numtax) |
|
281 | + $listoftax = array(0, 1, 2); |
|
282 | + foreach ($listoftax as $numtax) |
|
283 | 283 | { |
284 | 284 | $arrayofvat = $tabtva; |
285 | 285 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
286 | 286 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
287 | 287 | |
288 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
288 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
289 | 289 | if ($mt) { |
290 | 290 | // get compte id and label |
291 | 291 | $bookkeeping = new BookKeeping($db); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $bookkeeping->subledger_account = ''; |
299 | 299 | $bookkeeping->subledger_label = ''; |
300 | 300 | $bookkeeping->numero_compte = $k; |
301 | - $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'; |
|
301 | + $bookkeeping->label_operation = $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'; |
|
302 | 302 | $bookkeeping->montant = $mt; |
303 | 303 | $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; |
304 | 304 | $bookkeeping->debit = ($mt > 0) ? $mt : 0; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | - if (! $errorforline) |
|
330 | + if (!$errorforline) |
|
331 | 331 | { |
332 | 332 | $db->commit(); |
333 | 333 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if ($error >= 10) |
339 | 339 | { |
340 | 340 | setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); |
341 | - break; // Break in the foreach |
|
341 | + break; // Break in the foreach |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | } |
@@ -355,20 +355,20 @@ discard block |
||
355 | 355 | setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
356 | 356 | } |
357 | 357 | |
358 | - $action=''; |
|
358 | + $action = ''; |
|
359 | 359 | |
360 | 360 | // Must reload data, so we make a redirect |
361 | 361 | if (count($tabpay) != $error) |
362 | 362 | { |
363 | - $param='id_journal='.$id_journal; |
|
364 | - $param.='&date_startday='.$date_startday; |
|
365 | - $param.='&date_startmonth='.$date_startmonth; |
|
366 | - $param.='&date_startyear='.$date_startyear; |
|
367 | - $param.='&date_endday='.$date_endday; |
|
368 | - $param.='&date_endmonth='.$date_endmonth; |
|
369 | - $param.='&date_endyear='.$date_endyear; |
|
370 | - $param.='&in_bookeeping='.$in_bookeeping; |
|
371 | - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); |
|
363 | + $param = 'id_journal='.$id_journal; |
|
364 | + $param .= '&date_startday='.$date_startday; |
|
365 | + $param .= '&date_startmonth='.$date_startmonth; |
|
366 | + $param .= '&date_startyear='.$date_startyear; |
|
367 | + $param .= '&date_endday='.$date_endday; |
|
368 | + $param .= '&date_endmonth='.$date_endmonth; |
|
369 | + $param .= '&date_endyear='.$date_endyear; |
|
370 | + $param .= '&in_bookeeping='.$in_bookeeping; |
|
371 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
372 | 372 | exit; |
373 | 373 | } |
374 | 374 | } |
@@ -494,17 +494,17 @@ discard block |
||
494 | 494 | |
495 | 495 | llxHeader('', $langs->trans("ExpenseReportsJournal")); |
496 | 496 | |
497 | - $nom = $langs->trans("ExpenseReportsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); |
|
497 | + $nom = $langs->trans("ExpenseReportsJournal").' - '.$accountingjournalstatic->getNomUrl(1); |
|
498 | 498 | $nomlink = ''; |
499 | 499 | $periodlink = ''; |
500 | 500 | $exportlink = ''; |
501 | - $builddate=dol_now(); |
|
502 | - $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
501 | + $builddate = dol_now(); |
|
502 | + $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
503 | 503 | |
504 | - $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
505 | - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
504 | + $listofchoices = array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); |
|
505 | + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1).' - '.$form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1).' - '.$langs->trans("AlreadyInGeneralLedger").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
506 | 506 | |
507 | - $varlink = 'id_journal=' . $id_journal; |
|
507 | + $varlink = 'id_journal='.$id_journal; |
|
508 | 508 | |
509 | 509 | journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
510 | 510 | |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | } |
516 | 516 | print '<div class="tabsAction tabsActionNoBottom">'; |
517 | 517 | if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { |
518 | - print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
518 | + print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
519 | 519 | } |
520 | 520 | else { |
521 | - print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
521 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
522 | 522 | } |
523 | 523 | //print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
524 | 524 | print '</div>'; |
@@ -548,13 +548,13 @@ discard block |
||
548 | 548 | print "<table class=\"noborder\" width=\"100%\">"; |
549 | 549 | print "<tr class=\"liste_titre\">"; |
550 | 550 | print "<td></td>"; |
551 | - print "<td>" . $langs->trans("Date") . "</td>"; |
|
552 | - print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>"; |
|
553 | - print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
554 | - print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
555 | - print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
556 | - print "<td align='right'>" . $langs->trans("Debit") . "</td>"; |
|
557 | - print "<td align='right'>" . $langs->trans("Credit") . "</td>"; |
|
551 | + print "<td>".$langs->trans("Date")."</td>"; |
|
552 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("ExpenseReportRef").")</td>"; |
|
553 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
554 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
555 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
556 | + print "<td align='right'>".$langs->trans("Debit")."</td>"; |
|
557 | + print "<td align='right'>".$langs->trans("Credit")."</td>"; |
|
558 | 558 | print "</tr>\n"; |
559 | 559 | |
560 | 560 | $r = ''; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $expensereportstatic = new ExpenseReport($db); |
563 | 563 | $expensereportlinestatic = new ExpenseReportLine($db); |
564 | 564 | |
565 | - foreach ( $taber as $key => $val ) { |
|
565 | + foreach ($taber as $key => $val) { |
|
566 | 566 | $expensereportstatic->id = $key; |
567 | 567 | $expensereportstatic->ref = $val["ref"]; |
568 | 568 | $expensereportlinestatic->comments = html_entity_decode(dol_trunc($val["comments"], 32)); |
@@ -570,15 +570,15 @@ discard block |
||
570 | 570 | $date = dol_print_date($val["date"], 'day'); |
571 | 571 | |
572 | 572 | // Fees |
573 | - foreach ( $tabht[$key] as $k => $mt ) { |
|
573 | + foreach ($tabht[$key] as $k => $mt) { |
|
574 | 574 | $accountingaccount = new AccountingAccount($db); |
575 | 575 | $accountingaccount->fetch(null, $k, true); |
576 | 576 | |
577 | 577 | if ($mt) { |
578 | 578 | print '<tr class="oddeven">'; |
579 | 579 | print "<td><!-- Fees --></td>"; |
580 | - print "<td>" . $date . "</td>"; |
|
581 | - print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>"; |
|
580 | + print "<td>".$date."</td>"; |
|
581 | + print "<td>".$expensereportstatic->getNomUrl(1)."</td>"; |
|
582 | 582 | $userstatic->id = $tabuser[$key]['id']; |
583 | 583 | $userstatic->name = $tabuser[$key]['name']; |
584 | 584 | // Account |
@@ -595,19 +595,19 @@ discard block |
||
595 | 595 | print '</td>'; |
596 | 596 | $userstatic->id = $tabuser[$key]['id']; |
597 | 597 | $userstatic->name = $tabuser[$key]['name']; |
598 | - print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>"; |
|
599 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
600 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
598 | + print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."</td>"; |
|
599 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
600 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
601 | 601 | print "</tr>"; |
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
605 | 605 | // Third party |
606 | - foreach ( $tabttc[$key] as $k => $mt ) { |
|
606 | + foreach ($tabttc[$key] as $k => $mt) { |
|
607 | 607 | print '<tr class="oddeven">'; |
608 | 608 | print "<td><!-- Thirdparty --></td>"; |
609 | - print "<td>" . $date . "</td>"; |
|
610 | - print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>"; |
|
609 | + print "<td>".$date."</td>"; |
|
610 | + print "<td>".$expensereportstatic->getNomUrl(1)."</td>"; |
|
611 | 611 | $userstatic->id = $tabuser[$key]['id']; |
612 | 612 | $userstatic->name = $tabuser[$key]['name']; |
613 | 613 | // Account |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | } |
629 | 629 | else print $accountoshow; |
630 | 630 | print '</td>'; |
631 | - print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; |
|
632 | - print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; |
|
633 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
631 | + print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>"; |
|
632 | + print '<td align="right">'.($mt < 0 ? -price(-$mt) : '')."</td>"; |
|
633 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
634 | 634 | print "</tr>"; |
635 | 635 | } |
636 | 636 | |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | if ($numtax == 1) $arrayofvat = $tablocaltax1; |
642 | 642 | if ($numtax == 2) $arrayofvat = $tablocaltax2; |
643 | 643 | |
644 | - foreach ( $arrayofvat[$key] as $k => $mt ) { |
|
644 | + foreach ($arrayofvat[$key] as $k => $mt) { |
|
645 | 645 | if ($mt) { |
646 | 646 | print '<tr class="oddeven">'; |
647 | 647 | print "<td><!-- VAT --></td>"; |
648 | - print "<td>" . $date . "</td>"; |
|
649 | - print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>"; |
|
648 | + print "<td>".$date."</td>"; |
|
649 | + print "<td>".$expensereportstatic->getNomUrl(1)."</td>"; |
|
650 | 650 | // Account |
651 | 651 | print "<td>"; |
652 | 652 | $accountoshow = length_accountg($k); |
@@ -659,10 +659,10 @@ discard block |
||
659 | 659 | // Subledger account |
660 | 660 | print "<td>"; |
661 | 661 | print '</td>'; |
662 | - print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); |
|
662 | + print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); |
|
663 | 663 | print "</td>"; |
664 | - print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
665 | - print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; |
|
664 | + print '<td align="right">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
665 | + print '<td align="right">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
666 | 666 | print "</tr>"; |
667 | 667 | } |
668 | 668 | } |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | // Dolibarr environment |
30 | 30 | require '../../main.inc.php'; |
31 | 31 | |
32 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
37 | 37 | |
38 | 38 | |
39 | -$action=GETPOST('action','aZ09'); |
|
40 | -$massaction=GETPOST('massaction','alpha'); |
|
41 | -$show_files=GETPOST('show_files','int'); |
|
42 | -$confirm=GETPOST('confirm','alpha'); |
|
39 | +$action = GETPOST('action', 'aZ09'); |
|
40 | +$massaction = GETPOST('massaction', 'alpha'); |
|
41 | +$show_files = GETPOST('show_files', 'int'); |
|
42 | +$confirm = GETPOST('confirm', 'alpha'); |
|
43 | 43 | $toselect = GETPOST('toselect', 'array'); |
44 | 44 | |
45 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
46 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
47 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
48 | -$page = GETPOST("page",'int'); |
|
45 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
46 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
47 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
48 | +$page = GETPOST("page", 'int'); |
|
49 | 49 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
50 | 50 | $offset = $limit * $page; |
51 | 51 | $pageprev = $page - 1; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | if ($sortorder == "") $sortorder = "ASC"; |
54 | 54 | if ($sortfield == "") $sortfield = "bk.rowid"; |
55 | 55 | |
56 | -$search_year = GETPOST ( "search_year" ); |
|
56 | +$search_year = GETPOST("search_year"); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | // Security check |
60 | -$socid = GETPOST("socid",'int'); |
|
60 | +$socid = GETPOST("socid", 'int'); |
|
61 | 61 | // if ($user->societe_id) $socid=$user->societe_id; |
62 | 62 | |
63 | 63 | $object = new Societe($db); |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | if ($action == 'lettering') { |
76 | 76 | |
77 | - $result = $BookKeeping->updatelettrage($_POST['ids']); |
|
77 | + $result = $BookKeeping->updatelettrage($_POST['ids']); |
|
78 | 78 | |
79 | 79 | // var_dump($result); |
80 | - if( $result < 0 ){ |
|
81 | - setEventMessages('', $BookKeeping->errors, 'errors' ); |
|
80 | + if ($result < 0) { |
|
81 | + setEventMessages('', $BookKeeping->errors, 'errors'); |
|
82 | 82 | $error++; |
83 | 83 | |
84 | 84 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | |
89 | 89 | $result = $BookKeeping->LettrageTiers($socid); |
90 | 90 | |
91 | - if( $result < 0 ){ |
|
92 | - setEventMessages('', $BookKeeping->errors, 'errors' ); |
|
91 | + if ($result < 0) { |
|
92 | + setEventMessages('', $BookKeeping->errors, 'errors'); |
|
93 | 93 | $error++; |
94 | 94 | |
95 | 95 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | |
100 | -llxHeader ( '', 'Compta - Grand Livre' ); |
|
100 | +llxHeader('', 'Compta - Grand Livre'); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | /* |
@@ -105,27 +105,27 @@ discard block |
||
105 | 105 | */ |
106 | 106 | $head = societe_prepare_head($object); |
107 | 107 | |
108 | - dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); |
|
108 | + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); |
|
109 | 109 | |
110 | - dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); |
|
110 | + dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"), 0, 'company'); |
|
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | 114 | |
115 | 115 | print '<table width="100%" class="border">'; |
116 | 116 | print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">'; |
117 | - $object->next_prev_filter="te.fournisseur = 1"; |
|
118 | - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); |
|
117 | + $object->next_prev_filter = "te.fournisseur = 1"; |
|
118 | + print $form->showrefnav($object, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom', '', ''); |
|
119 | 119 | print '</td></tr>'; |
120 | 120 | |
121 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
121 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
122 | 122 | { |
123 | 123 | print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | 127 | print '<tr>'; |
128 | - print '<td class="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">'; |
|
128 | + print '<td class="nowrap">'.$langs->trans("SupplierCode").'</td><td colspan="3">'; |
|
129 | 129 | print $object->code_fournisseur; |
130 | 130 | if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
131 | 131 | print '</td>'; |
@@ -134,28 +134,28 @@ discard block |
||
134 | 134 | $langs->load('compta'); |
135 | 135 | print '<tr>'; |
136 | 136 | print '<td>'; |
137 | - print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer); |
|
137 | + print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); |
|
138 | 138 | print '</td><td colspan="3">'; |
139 | - print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer); |
|
139 | + print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); |
|
140 | 140 | print '</td>'; |
141 | 141 | print '</tr>'; |
142 | 142 | |
143 | 143 | |
144 | 144 | // Address |
145 | 145 | print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; |
146 | - dol_print_address($object->address,'gmap','thirdparty',$object->id); |
|
146 | + dol_print_address($object->address, 'gmap', 'thirdparty', $object->id); |
|
147 | 147 | print '</td></tr>'; |
148 | 148 | |
149 | 149 | // Zip / Town |
150 | - print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>'; |
|
150 | + print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town) ? ' / ' : '').$object->town.'</td>'; |
|
151 | 151 | print '</tr>'; |
152 | 152 | |
153 | 153 | // Country |
154 | 154 | print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; |
155 | 155 | //$img=picto_from_langcode($object->country_code); |
156 | - $img=''; |
|
157 | - if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); |
|
158 | - else print ($img?$img.' ':'').$object->country; |
|
156 | + $img = ''; |
|
157 | + if ($object->isInEEC()) print $form->textwithpicto(($img ? $img.' ' : '').$object->country, $langs->trans("CountryIsInEEC"), 1, 0); |
|
158 | + else print ($img ? $img.' ' : '').$object->country; |
|
159 | 159 | print '</td></tr>'; |
160 | 160 | |
161 | 161 | print '</table>'; |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | */ |
174 | 174 | |
175 | 175 | $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering "; |
176 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; |
|
177 | - $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ; |
|
176 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; |
|
177 | + $sql .= " WHERE (bk.code_tiers = '".$object->code_compta_fournisseur."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER."' )"; |
|
178 | 178 | |
179 | 179 | |
180 | 180 | |
181 | - if (dol_strlen ( $search_year )) { |
|
182 | - $sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; |
|
181 | + if (dol_strlen($search_year)) { |
|
182 | + $sql .= " AND ( bk.doc_date BETWEEN '".$search_year."-0-0' AND '".($search_year + 1)."-0-0' )"; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | - $sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset ); |
|
186 | + $sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC"; //. $db->plimit ( $conf->liste_limit + 1, $offset ); |
|
187 | 187 | |
188 | 188 | // echo $sql; |
189 | 189 | // dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG ); |
190 | - $resql = $db->query ( $sql ); |
|
190 | + $resql = $db->query($sql); |
|
191 | 191 | if ($resql) { |
192 | - $num = $db->num_rows ( $resql ); |
|
192 | + $num = $db->num_rows($resql); |
|
193 | 193 | $i = 0; |
194 | 194 | |
195 | 195 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | print "<table class=\"noborder\" width=\"100%\">"; |
201 | 201 | print '<tr class="liste_titre">'; |
202 | 202 | print '<td></td>'; |
203 | - print_liste_field_titre("Doctype", "liste.php", "bk.doc_type" ); |
|
204 | - print_liste_field_titre("Docdate", "liste.php", "bk.doc_date" ); |
|
205 | - print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" ); |
|
203 | + print_liste_field_titre("Doctype", "liste.php", "bk.doc_type"); |
|
204 | + print_liste_field_titre("Docdate", "liste.php", "bk.doc_date"); |
|
205 | + print_liste_field_titre("Docref", "liste.php", "bk.doc_ref"); |
|
206 | 206 | // print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" ); |
207 | 207 | // print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" ); |
208 | - print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" ); |
|
209 | - print_liste_field_titre("Debit", "liste.php", "bk.debit" ); |
|
210 | - print_liste_field_titre("Credit", "liste.php", "bk.credit" ); |
|
211 | - print_liste_field_titre("Amount", "liste.php", "bk.montant" ); |
|
212 | - print_liste_field_titre("Sens", "liste.php", "bk.sens" ); |
|
213 | - print_liste_field_titre("Codejournal", "liste.php", "bk.code_journal" ); |
|
208 | + print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte"); |
|
209 | + print_liste_field_titre("Debit", "liste.php", "bk.debit"); |
|
210 | + print_liste_field_titre("Credit", "liste.php", "bk.credit"); |
|
211 | + print_liste_field_titre("Amount", "liste.php", "bk.montant"); |
|
212 | + print_liste_field_titre("Sens", "liste.php", "bk.sens"); |
|
213 | + print_liste_field_titre("Codejournal", "liste.php", "bk.code_journal"); |
|
214 | 214 | print '<td></td>'; |
215 | 215 | print '<td></td>'; |
216 | 216 | print "</tr>\n"; |
217 | 217 | |
218 | 218 | print '<tr class="liste_titre">'; |
219 | 219 | print '<form action="" method="GET">'; |
220 | - print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">'; |
|
221 | - print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>'; |
|
222 | - print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>'; |
|
223 | - print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>'; |
|
220 | + print '<input type="hidden" name="socid" value="'.$_GET ["socid"].'">'; |
|
221 | + print '<td><input type="text" name="search_doc_type" value="'.$_GET ["search_doc_type"].'"></td>'; |
|
222 | + print '<td><input type="text" name="search_year" value="'.$_GET ["search_year"].'"></td>'; |
|
223 | + print '<td><input type="text" name="search_doc_refe" value="'.$_GET ["search_doc_ref"].'"></td>'; |
|
224 | 224 | // print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>'; |
225 | 225 | // print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>'; |
226 | 226 | print '<td> </td>'; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | print '<td> </td>'; |
230 | 230 | print '<td> </td>'; |
231 | 231 | print '<td align="right">'; |
232 | - print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">'; |
|
232 | + print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; |
|
233 | 233 | print '</td>'; |
234 | 234 | print '<td> </td>'; |
235 | 235 | print '<td> </td>'; |
@@ -243,64 +243,64 @@ discard block |
||
243 | 243 | $credit = 0; |
244 | 244 | $solde = 0; |
245 | 245 | $tmp = ''; |
246 | - while ( $i < $num ) { |
|
247 | - $obj = $db->fetch_object ( $resql ); |
|
246 | + while ($i < $num) { |
|
247 | + $obj = $db->fetch_object($resql); |
|
248 | 248 | |
249 | - if($tmp !=$obj->lettering || empty($tmp) ) |
|
250 | - $tmp =$obj->lettering; |
|
249 | + if ($tmp != $obj->lettering || empty($tmp)) |
|
250 | + $tmp = $obj->lettering; |
|
251 | 251 | |
252 | - if($tmp !=$obj->lettering || empty($obj->lettering)) |
|
253 | - $var = ! $var; |
|
252 | + if ($tmp != $obj->lettering || empty($obj->lettering)) |
|
253 | + $var = !$var; |
|
254 | 254 | |
255 | 255 | |
256 | - $debit+= $obj->debit; |
|
257 | - $credit+= $obj->credit; |
|
256 | + $debit += $obj->debit; |
|
257 | + $credit += $obj->credit; |
|
258 | 258 | |
259 | - $solde+=($obj->credit-$obj->debit); |
|
259 | + $solde += ($obj->credit - $obj->debit); |
|
260 | 260 | print "<tr $bc[$var]>"; |
261 | 261 | |
262 | - print '<td>' . $obj->rowid . '</td>'; |
|
263 | - if(empty($obj->lettering)){ |
|
264 | - print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">'; |
|
265 | - print img_edit (); |
|
266 | - print '</a> ' . $obj->doc_type . '</td>' . "\n"; |
|
262 | + print '<td>'.$obj->rowid.'</td>'; |
|
263 | + if (empty($obj->lettering)) { |
|
264 | + print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num='.$obj->piece_num.'">'; |
|
265 | + print img_edit(); |
|
266 | + print '</a> '.$obj->doc_type.'</td>'."\n"; |
|
267 | 267 | } |
268 | 268 | else |
269 | - print '<td>'.$obj->doc_type . '</td>' . "\n"; |
|
269 | + print '<td>'.$obj->doc_type.'</td>'."\n"; |
|
270 | 270 | |
271 | 271 | |
272 | 272 | |
273 | - print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>'; |
|
274 | - print '<td>' . $obj->doc_ref . '</td>'; |
|
273 | + print '<td>'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>'; |
|
274 | + print '<td>'.$obj->doc_ref.'</td>'; |
|
275 | 275 | // print '<td>' . $obj->numero_compte . '</td>'; |
276 | 276 | // print '<td>' . $obj->code_tiers . '</td>'; |
277 | - print '<td>' . $obj->label_compte . '</td>'; |
|
278 | - print '<td>' . $obj->debit . '</td>'; |
|
279 | - print '<td>' . $obj->credit . '</td>'; |
|
280 | - print '<td>' . $obj->montant . '</td>'; |
|
281 | - print '<td>' . $obj->sens . '</td>'; |
|
282 | - print '<td>' . $obj->code_journal . '</td>'; |
|
283 | - print '<td>' . round($solde, 2) . '</td>'; |
|
284 | - |
|
285 | - if(empty($obj->lettering)){ |
|
286 | - print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>'; |
|
277 | + print '<td>'.$obj->label_compte.'</td>'; |
|
278 | + print '<td>'.$obj->debit.'</td>'; |
|
279 | + print '<td>'.$obj->credit.'</td>'; |
|
280 | + print '<td>'.$obj->montant.'</td>'; |
|
281 | + print '<td>'.$obj->sens.'</td>'; |
|
282 | + print '<td>'.$obj->code_journal.'</td>'; |
|
283 | + print '<td>'.round($solde, 2).'</td>'; |
|
284 | + |
|
285 | + if (empty($obj->lettering)) { |
|
286 | + print '<td><input type="checkbox" name="ids[]" value="'.$obj->rowid.'" /></td>'; |
|
287 | 287 | } |
288 | 288 | else |
289 | - print '<td>' . $obj->lettering . '</td>'; |
|
289 | + print '<td>'.$obj->lettering.'</td>'; |
|
290 | 290 | |
291 | 291 | print "</tr>\n"; |
292 | 292 | |
293 | - $i ++; |
|
293 | + $i++; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | print '<tr class="oddeven">'; |
297 | 297 | |
298 | - print '<td colspan="4">Mouvement totaux</td>' . "\n"; |
|
298 | + print '<td colspan="4">Mouvement totaux</td>'."\n"; |
|
299 | 299 | print '<td></td>'; |
300 | 300 | print '<td></td>'; |
301 | 301 | print '<td></td>'; |
302 | - print '<td><strong>' . $debit . '</strong></td>'; |
|
303 | - print '<td><strong>' . $credit . '</strong></td>'; |
|
302 | + print '<td><strong>'.$debit.'</strong></td>'; |
|
303 | + print '<td><strong>'.$credit.'</strong></td>'; |
|
304 | 304 | print '<td></td>'; |
305 | 305 | print '<td></td>'; |
306 | 306 | print '<td></td>'; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | print "</tr>\n"; |
309 | 309 | |
310 | 310 | print "<tr $bc[$var]>"; |
311 | - print '<td colspan="5">Solde Comptable</td>' . "\n"; |
|
311 | + print '<td colspan="5">Solde Comptable</td>'."\n"; |
|
312 | 312 | print '<td></td>'; |
313 | 313 | print '<td></td>'; |
314 | 314 | print '<td></td>'; |
315 | - print '<td><strong>' . ($credit-$debit) . '</strong></td>'; |
|
315 | + print '<td><strong>'.($credit - $debit).'</strong></td>'; |
|
316 | 316 | print '<td></td>'; |
317 | 317 | print '<td></td>'; |
318 | 318 | print '<td></td>'; |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | print '<input class="butAction" type="submit" value="lettering">'; |
325 | 325 | print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>'; |
326 | 326 | print "</form>"; |
327 | - $db->free ( $resql ); |
|
327 | + $db->free($resql); |
|
328 | 328 | } else { |
329 | - dol_print_error ( $db ); |
|
329 | + dol_print_error($db); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | |
29 | 29 | require '../../main.inc.php'; |
30 | 30 | |
31 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
|
36 | - |
|
37 | -$action=GETPOST('action','aZ09'); |
|
38 | -$massaction=GETPOST('massaction','alpha'); |
|
39 | -$show_files=GETPOST('show_files','int'); |
|
40 | -$confirm=GETPOST('confirm','alpha'); |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
36 | + |
|
37 | +$action = GETPOST('action', 'aZ09'); |
|
38 | +$massaction = GETPOST('massaction', 'alpha'); |
|
39 | +$show_files = GETPOST('show_files', 'int'); |
|
40 | +$confirm = GETPOST('confirm', 'alpha'); |
|
41 | 41 | $toselect = GETPOST('toselect', 'array'); |
42 | 42 | |
43 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
44 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
45 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
46 | -$page = GETPOST("page",'int'); |
|
43 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
44 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
45 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
46 | +$page = GETPOST("page", 'int'); |
|
47 | 47 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
48 | 48 | $offset = $limit * $page; |
49 | 49 | $pageprev = $page - 1; |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | if ($sortorder == "") $sortorder = "ASC"; |
52 | 52 | if ($sortfield == "") $sortfield = "bk.rowid"; |
53 | 53 | |
54 | -$search_year = GETPOST ( "search_year" ); |
|
54 | +$search_year = GETPOST("search_year"); |
|
55 | 55 | |
56 | 56 | // Security check |
57 | -$socid = GETPOST("socid",'int'); |
|
57 | +$socid = GETPOST("socid", 'int'); |
|
58 | 58 | // if ($user->societe_id) $socid=$user->societe_id; |
59 | 59 | |
60 | 60 | $object = new Societe($db); |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | |
74 | 74 | if ($action == 'lettering') { |
75 | 75 | |
76 | - $result = $BookKeeping->updatelettrage($_POST['ids']); |
|
76 | + $result = $BookKeeping->updatelettrage($_POST['ids']); |
|
77 | 77 | |
78 | 78 | // var_dump($result); |
79 | - if( $result < 0 ){ |
|
80 | - setEventMessages('', $BookKeeping->errors, 'errors' ); |
|
79 | + if ($result < 0) { |
|
80 | + setEventMessages('', $BookKeeping->errors, 'errors'); |
|
81 | 81 | $error++; |
82 | 82 | |
83 | 83 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | $result = $BookKeeping->LettrageTiers($socid); |
89 | 89 | |
90 | - if( $result < 0 ){ |
|
91 | - setEventMessages('', $BookKeeping->errors, 'errors' ); |
|
90 | + if ($result < 0) { |
|
91 | + setEventMessages('', $BookKeeping->errors, 'errors'); |
|
92 | 92 | $error++; |
93 | 93 | |
94 | 94 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | -llxHeader ( '', 'Compta - Grand Livre' ); |
|
99 | +llxHeader('', 'Compta - Grand Livre'); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | /* |
@@ -104,27 +104,27 @@ discard block |
||
104 | 104 | */ |
105 | 105 | $head = societe_prepare_head($object); |
106 | 106 | |
107 | - dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); |
|
107 | + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); |
|
108 | 108 | |
109 | - dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); |
|
109 | + dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"), 0, 'company'); |
|
110 | 110 | |
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | 114 | print '<table width="100%" class="border">'; |
115 | 115 | print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">'; |
116 | - $object->next_prev_filter="te.fournisseur = 1"; |
|
117 | - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); |
|
116 | + $object->next_prev_filter = "te.fournisseur = 1"; |
|
117 | + print $form->showrefnav($object, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom', '', ''); |
|
118 | 118 | print '</td></tr>'; |
119 | 119 | |
120 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
120 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
121 | 121 | { |
122 | 122 | print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | print '<tr>'; |
127 | - print '<td class="nowrap">'.$langs->trans("CustomerCode"). '</td><td colspan="3">'; |
|
127 | + print '<td class="nowrap">'.$langs->trans("CustomerCode").'</td><td colspan="3">'; |
|
128 | 128 | print $object->code_client; |
129 | 129 | if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
130 | 130 | print '</td>'; |
@@ -133,28 +133,28 @@ discard block |
||
133 | 133 | $langs->load('compta'); |
134 | 134 | print '<tr>'; |
135 | 135 | print '<td>'; |
136 | - print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); |
|
136 | + print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); |
|
137 | 137 | print '</td><td colspan="3">'; |
138 | - print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); |
|
138 | + print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); |
|
139 | 139 | print '</td>'; |
140 | 140 | print '</tr>'; |
141 | 141 | |
142 | 142 | |
143 | 143 | // Address |
144 | 144 | print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; |
145 | - dol_print_address($object->address,'gmap','thirdparty',$object->id); |
|
145 | + dol_print_address($object->address, 'gmap', 'thirdparty', $object->id); |
|
146 | 146 | print '</td></tr>'; |
147 | 147 | |
148 | 148 | // Zip / Town |
149 | - print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>'; |
|
149 | + print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town) ? ' / ' : '').$object->town.'</td>'; |
|
150 | 150 | print '</tr>'; |
151 | 151 | |
152 | 152 | // Country |
153 | 153 | print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; |
154 | 154 | //$img=picto_from_langcode($object->country_code); |
155 | - $img=''; |
|
156 | - if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); |
|
157 | - else print ($img?$img.' ':'').$object->country; |
|
155 | + $img = ''; |
|
156 | + if ($object->isInEEC()) print $form->textwithpicto(($img ? $img.' ' : '').$object->country, $langs->trans("CountryIsInEEC"), 1, 0); |
|
157 | + else print ($img ? $img.' ' : '').$object->country; |
|
158 | 158 | print '</td></tr>'; |
159 | 159 | |
160 | 160 | print '</table>'; |
@@ -164,23 +164,23 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; |
167 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; |
|
168 | - $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ; |
|
167 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; |
|
168 | + $sql .= " WHERE (bk.code_tiers = '".$object->code_compta."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER."' )"; |
|
169 | 169 | |
170 | 170 | |
171 | 171 | |
172 | - if (dol_strlen ( $search_year )) { |
|
173 | - $sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; |
|
172 | + if (dol_strlen($search_year)) { |
|
173 | + $sql .= " AND ( bk.doc_date BETWEEN '".$search_year."-0-0' AND '".($search_year + 1)."-0-0' )"; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | - $sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset ); |
|
177 | + $sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC"; //. $db->plimit ( $conf->liste_limit + 1, $offset ); |
|
178 | 178 | |
179 | 179 | // echo $sql; |
180 | 180 | // dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG ); |
181 | - $resql = $db->query ( $sql ); |
|
181 | + $resql = $db->query($sql); |
|
182 | 182 | if ($resql) { |
183 | - $num = $db->num_rows ( $resql ); |
|
183 | + $num = $db->num_rows($resql); |
|
184 | 184 | $i = 0; |
185 | 185 | |
186 | 186 | |
@@ -191,27 +191,27 @@ discard block |
||
191 | 191 | print "<table class=\"noborder\" width=\"100%\">"; |
192 | 192 | print '<tr class="liste_titre">'; |
193 | 193 | print '<td></td>'; |
194 | - print_liste_field_titre("Doctype", "liste.php", "bk.doc_type" ); |
|
195 | - print_liste_field_titre("Docdate", "liste.php", "bk.doc_date" ); |
|
196 | - print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" ); |
|
194 | + print_liste_field_titre("Doctype", "liste.php", "bk.doc_type"); |
|
195 | + print_liste_field_titre("Docdate", "liste.php", "bk.doc_date"); |
|
196 | + print_liste_field_titre("Docref", "liste.php", "bk.doc_ref"); |
|
197 | 197 | // print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" ); |
198 | 198 | // print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" ); |
199 | - print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" ); |
|
200 | - print_liste_field_titre("Debit", "liste.php", "bk.debit" ); |
|
201 | - print_liste_field_titre("Credit", "liste.php", "bk.credit" ); |
|
199 | + print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte"); |
|
200 | + print_liste_field_titre("Debit", "liste.php", "bk.debit"); |
|
201 | + print_liste_field_titre("Credit", "liste.php", "bk.credit"); |
|
202 | 202 | // print_liste_field_titre("Amount", "liste.php", "bk.montant" ); |
203 | 203 | // print_liste_field_titre("Sens", "liste.php", "bk.sens" ); |
204 | - print_liste_field_titre("Codejournal", "liste.php", "bk.code_journal" ); |
|
204 | + print_liste_field_titre("Codejournal", "liste.php", "bk.code_journal"); |
|
205 | 205 | print '<td></td>'; |
206 | 206 | print '<td></td>'; |
207 | 207 | print "</tr>\n"; |
208 | 208 | |
209 | 209 | print '<tr class="liste_titre">'; |
210 | 210 | print '<form action="" method="GET">'; |
211 | - print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">'; |
|
212 | - print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>'; |
|
213 | - print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>'; |
|
214 | - print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>'; |
|
211 | + print '<input type="hidden" name="socid" value="'.$_GET ["socid"].'">'; |
|
212 | + print '<td><input type="text" name="search_doc_type" value="'.$_GET ["search_doc_type"].'"></td>'; |
|
213 | + print '<td><input type="text" name="search_year" value="'.$_GET ["search_year"].'"></td>'; |
|
214 | + print '<td><input type="text" name="search_doc_refe" value="'.$_GET ["search_doc_ref"].'"></td>'; |
|
215 | 215 | // print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>'; |
216 | 216 | // print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>'; |
217 | 217 | print '<td> </td>'; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | // print '<td> </td>'; |
221 | 221 | // print '<td> </td>'; |
222 | 222 | print '<td align="right">'; |
223 | - print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">'; |
|
223 | + print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; |
|
224 | 224 | print '</td>'; |
225 | 225 | print '<td> </td>'; |
226 | 226 | print '<td> </td>'; |
@@ -234,54 +234,54 @@ discard block |
||
234 | 234 | $credit = 0; |
235 | 235 | $solde = 0; |
236 | 236 | $tmp = ''; |
237 | - while ( $i < $num ) { |
|
238 | - $obj = $db->fetch_object ( $resql ); |
|
237 | + while ($i < $num) { |
|
238 | + $obj = $db->fetch_object($resql); |
|
239 | 239 | |
240 | - if($tmp !=$obj->lettering_code || empty($tmp) ) |
|
241 | - $tmp =$obj->lettering_code; |
|
240 | + if ($tmp != $obj->lettering_code || empty($tmp)) |
|
241 | + $tmp = $obj->lettering_code; |
|
242 | 242 | |
243 | - if($tmp !=$obj->lettering_code || empty($obj->lettering_code)) |
|
244 | - $var = ! $var; |
|
243 | + if ($tmp != $obj->lettering_code || empty($obj->lettering_code)) |
|
244 | + $var = !$var; |
|
245 | 245 | |
246 | 246 | |
247 | - $debit+= $obj->debit; |
|
248 | - $credit+= $obj->credit; |
|
247 | + $debit += $obj->debit; |
|
248 | + $credit += $obj->credit; |
|
249 | 249 | |
250 | - $solde+=($obj->credit-$obj->debit); |
|
250 | + $solde += ($obj->credit - $obj->debit); |
|
251 | 251 | print "<tr $bc[$var]>"; |
252 | 252 | |
253 | - print '<td>' . $obj->rowid . '</td>'; |
|
254 | - if(empty($obj->lettering_code)){ |
|
255 | - print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">'; |
|
256 | - print img_edit (); |
|
257 | - print '</a> ' . $obj->doc_type . '</td>' . "\n"; |
|
253 | + print '<td>'.$obj->rowid.'</td>'; |
|
254 | + if (empty($obj->lettering_code)) { |
|
255 | + print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num='.$obj->piece_num.'">'; |
|
256 | + print img_edit(); |
|
257 | + print '</a> '.$obj->doc_type.'</td>'."\n"; |
|
258 | 258 | } |
259 | 259 | else |
260 | - print '<td>'.$obj->doc_type . '</td>' . "\n"; |
|
260 | + print '<td>'.$obj->doc_type.'</td>'."\n"; |
|
261 | 261 | |
262 | 262 | |
263 | 263 | |
264 | - print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>'; |
|
265 | - print '<td>' . $obj->doc_ref . '</td>'; |
|
264 | + print '<td>'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>'; |
|
265 | + print '<td>'.$obj->doc_ref.'</td>'; |
|
266 | 266 | // print '<td>' . $obj->numero_compte . '</td>'; |
267 | 267 | // print '<td>' . $obj->code_tiers . '</td>'; |
268 | - print '<td>' . $obj->label_compte . '</td>'; |
|
269 | - print '<td>' . $obj->debit . '</td>'; |
|
270 | - print '<td>' . $obj->credit . '</td>'; |
|
268 | + print '<td>'.$obj->label_compte.'</td>'; |
|
269 | + print '<td>'.$obj->debit.'</td>'; |
|
270 | + print '<td>'.$obj->credit.'</td>'; |
|
271 | 271 | // print '<td>' . $obj->montant . '</td>'; |
272 | 272 | // print '<td>' . $obj->sens . '</td>'; |
273 | - print '<td>' . $obj->code_journal . '</td>'; |
|
274 | - print '<td>' . round($solde, 2) . '</td>'; |
|
273 | + print '<td>'.$obj->code_journal.'</td>'; |
|
274 | + print '<td>'.round($solde, 2).'</td>'; |
|
275 | 275 | |
276 | - if(empty($obj->lettering_code)){ |
|
277 | - print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>'; |
|
276 | + if (empty($obj->lettering_code)) { |
|
277 | + print '<td><input type="checkbox" name="ids[]" value="'.$obj->rowid.'" /></td>'; |
|
278 | 278 | } |
279 | 279 | else |
280 | - print '<td>' . $obj->lettering_code . '</td>'; |
|
280 | + print '<td>'.$obj->lettering_code.'</td>'; |
|
281 | 281 | |
282 | 282 | print "</tr>\n"; |
283 | 283 | |
284 | - $i ++; |
|
284 | + $i++; |
|
285 | 285 | |
286 | 286 | |
287 | 287 | |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | |
291 | 291 | print '<tr class="oddeven">'; |
292 | 292 | |
293 | - print '<td colspan="4">Mouvement totaux</td>' . "\n"; |
|
293 | + print '<td colspan="4">Mouvement totaux</td>'."\n"; |
|
294 | 294 | print '<td></td>'; |
295 | 295 | // print '<td></td>'; |
296 | 296 | // print '<td></td>'; |
297 | - print '<td><strong>' . $debit . '</strong></td>'; |
|
298 | - print '<td><strong>' . $credit . '</strong></td>'; |
|
297 | + print '<td><strong>'.$debit.'</strong></td>'; |
|
298 | + print '<td><strong>'.$credit.'</strong></td>'; |
|
299 | 299 | print '<td></td>'; |
300 | 300 | print '<td></td>'; |
301 | 301 | print '<td></td>'; |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | print "</tr>\n"; |
304 | 304 | |
305 | 305 | print "<tr $bc[$var]>"; |
306 | - print '<td colspan="5">Solde Comptable</td>' . "\n"; |
|
306 | + print '<td colspan="5">Solde Comptable</td>'."\n"; |
|
307 | 307 | // print '<td></td>'; |
308 | 308 | // print '<td></td>'; |
309 | 309 | print '<td></td>'; |
310 | - print '<td><strong>' . ($credit-$debit) . '</strong></td>'; |
|
310 | + print '<td><strong>'.($credit - $debit).'</strong></td>'; |
|
311 | 311 | print '<td></td>'; |
312 | 312 | print '<td></td>'; |
313 | 313 | print '<td></td>'; |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * \brief List operation of book keeping |
25 | 25 | */ |
26 | 26 | require '../../main.inc.php'; |
27 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; |
|
28 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
29 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
|
30 | -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; |
|
31 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; |
|
32 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; |
|
28 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
29 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; |
|
31 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
33 | 33 | |
34 | 34 | // Langs |
35 | 35 | $langs->load("accountancy"); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); |
79 | 79 | |
80 | 80 | // Load variable for pagination |
81 | -$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); |
|
81 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); |
|
82 | 82 | $sortfield = GETPOST('sortfield', 'alpha'); |
83 | 83 | $sortorder = GETPOST('sortorder', 'alpha'); |
84 | -$page = GETPOST('page','int'); |
|
84 | +$page = GETPOST('page', 'int'); |
|
85 | 85 | if ($page < 0) { $page = 0; } |
86 | 86 | $offset = $limit * $page; |
87 | 87 | $pageprev = $page - 1; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $form = new Form($db); |
98 | 98 | |
99 | 99 | |
100 | -if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) { |
|
100 | +if ($action != 'export_file' && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['formfilteraction']) && empty($page)) { |
|
101 | 101 | $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); |
102 | 102 | $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); |
103 | 103 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * Action |
109 | 109 | */ |
110 | 110 | |
111 | -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } |
|
112 | -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
|
111 | +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } |
|
112 | +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } |
|
113 | 113 | |
114 | -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
114 | +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
115 | 115 | { |
116 | 116 | $search_mvt_num = ''; |
117 | 117 | $search_doc_type = ''; |
@@ -132,76 +132,76 @@ discard block |
||
132 | 132 | |
133 | 133 | // Must be after the remove filter action, before the export. |
134 | 134 | $param = ''; |
135 | -$filter = array (); |
|
136 | -if (! empty($search_date_start)) { |
|
135 | +$filter = array(); |
|
136 | +if (!empty($search_date_start)) { |
|
137 | 137 | $filter['t.doc_date>='] = $search_date_start; |
138 | - $tmp=dol_getdate($search_date_start); |
|
139 | - $param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year']; |
|
138 | + $tmp = dol_getdate($search_date_start); |
|
139 | + $param .= '&date_startmonth='.$tmp['mon'].'&date_startday='.$tmp['mday'].'&date_startyear='.$tmp['year']; |
|
140 | 140 | } |
141 | -if (! empty($search_date_end)) { |
|
141 | +if (!empty($search_date_end)) { |
|
142 | 142 | $filter['t.doc_date<='] = $search_date_end; |
143 | - $tmp=dol_getdate($search_date_end); |
|
144 | - $param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year']; |
|
143 | + $tmp = dol_getdate($search_date_end); |
|
144 | + $param .= '&date_endmonth='.$tmp['mon'].'&date_endday='.$tmp['mday'].'&date_endyear='.$tmp['year']; |
|
145 | 145 | } |
146 | -if (! empty($search_doc_date)) { |
|
146 | +if (!empty($search_doc_date)) { |
|
147 | 147 | $filter['t.doc_date'] = $search_doc_date; |
148 | - $tmp=dol_getdate($search_doc_date); |
|
149 | - $param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year']; |
|
148 | + $tmp = dol_getdate($search_doc_date); |
|
149 | + $param .= '&doc_datemonth='.$tmp['mon'].'&doc_dateday='.$tmp['mday'].'&doc_dateyear='.$tmp['year']; |
|
150 | 150 | } |
151 | -if (! empty($search_doc_type)) { |
|
151 | +if (!empty($search_doc_type)) { |
|
152 | 152 | $filter['t.doc_type'] = $search_doc_type; |
153 | - $param .= '&search_doc_type=' . $search_doc_type; |
|
153 | + $param .= '&search_doc_type='.$search_doc_type; |
|
154 | 154 | } |
155 | -if (! empty($search_doc_ref)) { |
|
155 | +if (!empty($search_doc_ref)) { |
|
156 | 156 | $filter['t.doc_ref'] = $search_doc_ref; |
157 | - $param .= '&search_doc_ref=' . $search_doc_ref; |
|
157 | + $param .= '&search_doc_ref='.$search_doc_ref; |
|
158 | 158 | } |
159 | -if (! empty($search_accountancy_code)) { |
|
159 | +if (!empty($search_accountancy_code)) { |
|
160 | 160 | $filter['t.numero_compte'] = $search_accountancy_code; |
161 | - $param .= '&search_accountancy_code=' . $search_accountancy_code; |
|
161 | + $param .= '&search_accountancy_code='.$search_accountancy_code; |
|
162 | 162 | } |
163 | -if (! empty($search_accountancy_code_start)) { |
|
163 | +if (!empty($search_accountancy_code_start)) { |
|
164 | 164 | $filter['t.numero_compte>='] = $search_accountancy_code_start; |
165 | - $param .= '&search_accountancy_code_start=' . $search_accountancy_code_start; |
|
165 | + $param .= '&search_accountancy_code_start='.$search_accountancy_code_start; |
|
166 | 166 | } |
167 | -if (! empty($search_accountancy_code_end)) { |
|
167 | +if (!empty($search_accountancy_code_end)) { |
|
168 | 168 | $filter['t.numero_compte<='] = $search_accountancy_code_end; |
169 | - $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; |
|
169 | + $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; |
|
170 | 170 | } |
171 | -if (! empty($search_accountancy_aux_code)) { |
|
171 | +if (!empty($search_accountancy_aux_code)) { |
|
172 | 172 | $filter['t.subledger_account'] = $search_accountancy_aux_code; |
173 | - $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; |
|
173 | + $param .= '&search_accountancy_aux_code='.$search_accountancy_aux_code; |
|
174 | 174 | } |
175 | -if (! empty($search_accountancy_aux_code_start)) { |
|
175 | +if (!empty($search_accountancy_aux_code_start)) { |
|
176 | 176 | $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; |
177 | - $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; |
|
177 | + $param .= '&search_accountancy_aux_code_start='.$search_accountancy_aux_code_start; |
|
178 | 178 | } |
179 | -if (! empty($search_accountancy_aux_code_end)) { |
|
179 | +if (!empty($search_accountancy_aux_code_end)) { |
|
180 | 180 | $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; |
181 | - $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; |
|
181 | + $param .= '&search_accountancy_aux_code_end='.$search_accountancy_aux_code_end; |
|
182 | 182 | } |
183 | -if (! empty($search_mvt_label)) { |
|
183 | +if (!empty($search_mvt_label)) { |
|
184 | 184 | $filter['t.label_operation'] = $search_mvt_label; |
185 | - $param .= '&search_mvt_label=' . $search_mvt_label; |
|
185 | + $param .= '&search_mvt_label='.$search_mvt_label; |
|
186 | 186 | } |
187 | -if (! empty($search_direction)) { |
|
187 | +if (!empty($search_direction)) { |
|
188 | 188 | $filter['t.sens'] = $search_direction; |
189 | - $param .= '&search_direction=' . $search_direction; |
|
189 | + $param .= '&search_direction='.$search_direction; |
|
190 | 190 | } |
191 | -if (! empty($search_ledger_code)) { |
|
191 | +if (!empty($search_ledger_code)) { |
|
192 | 192 | $filter['t.code_journal'] = $search_ledger_code; |
193 | - $param .= '&search_ledger_code=' . $search_ledger_code; |
|
193 | + $param .= '&search_ledger_code='.$search_ledger_code; |
|
194 | 194 | } |
195 | -if (! empty($search_mvt_num)) { |
|
195 | +if (!empty($search_mvt_num)) { |
|
196 | 196 | $filter['t.piece_num'] = $search_mvt_num; |
197 | - $param .= '&search_mvt_num=' . $search_mvt_num; |
|
197 | + $param .= '&search_mvt_num='.$search_mvt_num; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | if ($action == 'delbookkeeping') { |
201 | 201 | |
202 | 202 | $import_key = GETPOST('importkey', 'alpha'); |
203 | 203 | |
204 | - if (! empty($import_key)) { |
|
204 | + if (!empty($import_key)) { |
|
205 | 205 | $result = $object->deleteByImportkey($import_key); |
206 | 206 | if ($result < 0) { |
207 | 207 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | if ($action == 'delbookkeepingyearconfirm') { |
214 | 214 | |
215 | 215 | $delyear = GETPOST('delyear', 'int'); |
216 | - if ($delyear==-1) { |
|
217 | - $delyear=0; |
|
216 | + if ($delyear == -1) { |
|
217 | + $delyear = 0; |
|
218 | 218 | } |
219 | - $deljournal = GETPOST('deljournal','alpha'); |
|
220 | - if ($deljournal==-1) { |
|
221 | - $deljournal=0; |
|
219 | + $deljournal = GETPOST('deljournal', 'alpha'); |
|
220 | + if ($deljournal == -1) { |
|
221 | + $deljournal = 0; |
|
222 | 222 | } |
223 | 223 | |
224 | - if (! empty($delyear) || ! empty($deljournal)) |
|
224 | + if (!empty($delyear) || !empty($deljournal)) |
|
225 | 225 | { |
226 | - $result = $object->deleteByYearAndJournal($delyear,$deljournal); |
|
226 | + $result = $object->deleteByYearAndJournal($delyear, $deljournal); |
|
227 | 227 | if ($result < 0) { |
228 | 228 | setEventMessages($object->error, $object->errors, 'errors'); |
229 | 229 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | $mvt_num = GETPOST('mvt_num', 'int'); |
247 | 247 | |
248 | - if (! empty($mvt_num)) { |
|
248 | + if (!empty($mvt_num)) { |
|
249 | 249 | $result = $object->deleteMvtNum($mvt_num); |
250 | 250 | if ($result < 0) { |
251 | 251 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | setEventMessages($object->error, $object->errors, 'errors'); |
304 | 304 | } |
305 | 305 | |
306 | -$num=count($object->lines); |
|
306 | +$num = count($object->lines); |
|
307 | 307 | |
308 | 308 | if ($action == 'delmouv') { |
309 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); |
|
309 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); |
|
310 | 310 | print $formconfirm; |
311 | 311 | } |
312 | 312 | if ($action == 'delbookkeepingyear') { |
313 | 313 | |
314 | - $form_question = array (); |
|
314 | + $form_question = array(); |
|
315 | 315 | $delyear = GETPOST('delyear'); |
316 | 316 | $deljournal = GETPOST('deljournal'); |
317 | 317 | |
@@ -321,16 +321,16 @@ discard block |
||
321 | 321 | $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); |
322 | 322 | $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); |
323 | 323 | |
324 | - $form_question['delyear'] = array ( |
|
324 | + $form_question['delyear'] = array( |
|
325 | 325 | 'name' => 'delyear', |
326 | 326 | 'type' => 'select', |
327 | 327 | 'label' => $langs->trans('DelYear'), |
328 | 328 | 'values' => $year_array, |
329 | 329 | 'default' => $delyear |
330 | 330 | ); |
331 | - $form_question['deljournal'] = array ( |
|
331 | + $form_question['deljournal'] = array( |
|
332 | 332 | 'name' => 'deljournal', |
333 | - 'type' => 'other', // We don't use select here, the journal_array is already a select html component |
|
333 | + 'type' => 'other', // We don't use select here, the journal_array is already a select html component |
|
334 | 334 | 'label' => $langs->trans('DelJournal'), |
335 | 335 | 'value' => $journal_array, |
336 | 336 | 'default' => $deljournal |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | } |
342 | 342 | |
343 | 343 | //$param=''; param started before |
344 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
345 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
344 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; |
|
345 | +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; |
|
346 | 346 | |
347 | -print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; |
|
347 | +print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
|
348 | 348 | print '<input type="hidden" name="action" value="list">'; |
349 | 349 | if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
350 | 350 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -353,20 +353,20 @@ discard block |
||
353 | 353 | print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
354 | 354 | print '<input type="hidden" name="page" value="'.$page.'">'; |
355 | 355 | |
356 | -$listofformat=AccountancyExport::getType(); |
|
357 | -$button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">'; |
|
358 | -if (count($filter)) $button.= $langs->trans("ExportFilteredList"); |
|
359 | -else $button.= $langs->trans("ExportList"); |
|
360 | -$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')'; |
|
361 | -$button.= '</a>'; |
|
356 | +$listofformat = AccountancyExport::getType(); |
|
357 | +$button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : '').'">'; |
|
358 | +if (count($filter)) $button .= $langs->trans("ExportFilteredList"); |
|
359 | +else $button .= $langs->trans("ExportList"); |
|
360 | +$button .= ' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')'; |
|
361 | +$button .= '</a>'; |
|
362 | 362 | |
363 | -$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>'; |
|
363 | +$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">'.$langs->trans("GroupByAccountAccounting").'</a>'; |
|
364 | 364 | |
365 | 365 | print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby, '', $limit); |
366 | 366 | |
367 | -print '<div class="tabsAction tabsActionNoBottom">' . "\n"; |
|
368 | -print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>'; |
|
369 | -print '<div class="inline-block divButAction"><a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a></div>'; |
|
367 | +print '<div class="tabsAction tabsActionNoBottom">'."\n"; |
|
368 | +print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">'.$langs->trans("NewAccountingMvt").'</a></div>'; |
|
369 | +print '<div class="inline-block divButAction"><a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DelBookKeeping").'</a></div>'; |
|
370 | 370 | |
371 | 371 | print '</div>'; |
372 | 372 | |
@@ -374,26 +374,26 @@ discard block |
||
374 | 374 | print '<table class="noborder" width="100%">'; |
375 | 375 | |
376 | 376 | print '<tr class="liste_titre_filter">'; |
377 | -print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; |
|
377 | +print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>'; |
|
378 | 378 | print '<td class="liste_titre center">'; |
379 | 379 | print '<div class="nowrap">'; |
380 | -print $langs->trans('From') . ' '; |
|
380 | +print $langs->trans('From').' '; |
|
381 | 381 | print $form->select_date($search_date_start, 'date_start', 0, 0, 1); |
382 | 382 | print '</div>'; |
383 | 383 | print '<div class="nowrap">'; |
384 | -print $langs->trans('to') . ' '; |
|
384 | +print $langs->trans('to').' '; |
|
385 | 385 | print $form->select_date($search_date_end, 'date_end', 0, 0, 1); |
386 | 386 | print '</div>'; |
387 | 387 | print '</td>'; |
388 | -print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>'; |
|
388 | +print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>'; |
|
389 | 389 | print '<td class="liste_titre">'; |
390 | 390 | print '<div class="nowrap">'; |
391 | 391 | print $langs->trans('From').' '; |
392 | -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); |
|
392 | +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); |
|
393 | 393 | print '</div>'; |
394 | 394 | print '<div class="nowrap">'; |
395 | 395 | print $langs->trans('to').' '; |
396 | -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); |
|
396 | +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); |
|
397 | 397 | print '</div>'; |
398 | 398 | print '</td>'; |
399 | 399 | print '<td class="liste_titre">'; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | print $langs->trans('From').' '; |
402 | 402 | // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not |
403 | 403 | // use setup of keypress to select thirdparty and this hang browser on large database. |
404 | -if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
|
404 | +if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
|
405 | 405 | { |
406 | 406 | print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); |
407 | 407 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | print $langs->trans('to').' '; |
415 | 415 | // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not |
416 | 416 | // use setup of keypress to select thirdparty and this hang browser on large database. |
417 | -if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
|
417 | +if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
|
418 | 418 | { |
419 | 419 | print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); |
420 | 420 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | print '</div>'; |
426 | 426 | print '</td>'; |
427 | 427 | print '<td class="liste_titre">'; |
428 | -print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>'; |
|
428 | +print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>'; |
|
429 | 429 | print '</td>'; |
430 | 430 | print '<td class="liste_titre center"> </td>'; |
431 | 431 | print '<td class="liste_titre center"> </td>'; |
432 | -print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>'; |
|
432 | +print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.$search_ledger_code.'"></td>'; |
|
433 | 433 | print '<td class="liste_titre center">'; |
434 | -$searchpicto=$form->showFilterButtons(); |
|
434 | +$searchpicto = $form->showFilterButtons(); |
|
435 | 435 | print $searchpicto; |
436 | 436 | print '</td>'; |
437 | 437 | print '</tr>'; |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); |
447 | 447 | print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); |
448 | 448 | print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); |
449 | -$checkpicto=''; |
|
450 | -if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); |
|
449 | +$checkpicto = ''; |
|
450 | +if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); |
|
451 | 451 | print_liste_field_titre($checkpicto, $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); |
452 | 452 | print "</tr>\n"; |
453 | 453 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $total_debit = 0; |
456 | 456 | $total_credit = 0; |
457 | 457 | |
458 | -$i=0; |
|
458 | +$i = 0; |
|
459 | 459 | while ($i < min($num, $limit)) |
460 | 460 | { |
461 | 461 | $line = $object->lines[$i]; |
@@ -465,23 +465,23 @@ discard block |
||
465 | 465 | |
466 | 466 | print '<tr class="oddeven">'; |
467 | 467 | |
468 | - print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->piece_num . '</a></td>'; |
|
469 | - print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>'; |
|
470 | - print '<td class="nowrap">' . $line->doc_ref . '</td>'; |
|
471 | - print '<td>' . length_accountg($line->numero_compte) . '</td>'; |
|
472 | - print '<td>' . length_accounta($line->subledger_account) . '</td>'; |
|
473 | - print '<td>' . $line->label_operation . '</td>'; |
|
474 | - print '<td align="right">' . ($line->debit ? price($line->debit) : ''). '</td>'; |
|
475 | - print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>'; |
|
468 | + print '<td><a href="./card.php?piece_num='.$line->piece_num.'">'.$line->piece_num.'</a></td>'; |
|
469 | + print '<td align="center">'.dol_print_date($line->doc_date, 'day').'</td>'; |
|
470 | + print '<td class="nowrap">'.$line->doc_ref.'</td>'; |
|
471 | + print '<td>'.length_accountg($line->numero_compte).'</td>'; |
|
472 | + print '<td>'.length_accounta($line->subledger_account).'</td>'; |
|
473 | + print '<td>'.$line->label_operation.'</td>'; |
|
474 | + print '<td align="right">'.($line->debit ? price($line->debit) : '').'</td>'; |
|
475 | + print '<td align="right">'.($line->credit ? price($line->credit) : '').'</td>'; |
|
476 | 476 | |
477 | 477 | $accountingjournal = new AccountingJournal($db); |
478 | - $result = $accountingjournal->fetch('',$line->code_journal); |
|
479 | - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal); |
|
480 | - print '<td align="center">' . $journaltoshow . '</td>'; |
|
478 | + $result = $accountingjournal->fetch('', $line->code_journal); |
|
479 | + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); |
|
480 | + print '<td align="center">'.$journaltoshow.'</td>'; |
|
481 | 481 | |
482 | 482 | print '<td align="center">'; |
483 | - print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a> '; |
|
484 | - print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>'; |
|
483 | + print '<a href="./card.php?piece_num='.$line->piece_num.'">'.img_edit().'</a> '; |
|
484 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.'">'.img_delete().'</a>'; |
|
485 | 485 | print '</td>'; |
486 | 486 | print "</tr>\n"; |
487 | 487 |
@@ -86,8 +86,12 @@ discard block |
||
86 | 86 | $offset = $limit * $page; |
87 | 87 | $pageprev = $page - 1; |
88 | 88 | $pagenext = $page + 1; |
89 | -if ($sortorder == "") $sortorder = "ASC"; |
|
90 | -if ($sortfield == "") $sortfield = "t.rowid"; |
|
89 | +if ($sortorder == "") { |
|
90 | + $sortorder = "ASC"; |
|
91 | +} |
|
92 | +if ($sortfield == "") { |
|
93 | + $sortfield = "t.rowid"; |
|
94 | +} |
|
91 | 95 | |
92 | 96 | |
93 | 97 | $object = new BookKeeping($db); |
@@ -111,9 +115,11 @@ discard block |
||
111 | 115 | if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } |
112 | 116 | if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
113 | 117 | |
114 | -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
118 | +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) { |
|
119 | + // All tests are required to be compatible with all browsers |
|
115 | 120 | { |
116 | 121 | $search_mvt_num = ''; |
122 | +} |
|
117 | 123 | $search_doc_type = ''; |
118 | 124 | $search_doc_ref = ''; |
119 | 125 | $search_doc_date = ''; |
@@ -226,15 +232,13 @@ discard block |
||
226 | 232 | $result = $object->deleteByYearAndJournal($delyear,$deljournal); |
227 | 233 | if ($result < 0) { |
228 | 234 | setEventMessages($object->error, $object->errors, 'errors'); |
229 | - } |
|
230 | - else |
|
235 | + } else |
|
231 | 236 | { |
232 | 237 | setEventMessages("RecordDeleted", null, 'mesgs'); |
233 | 238 | } |
234 | 239 | Header("Location: list.php"); |
235 | 240 | exit; |
236 | - } |
|
237 | - else |
|
241 | + } else |
|
238 | 242 | { |
239 | 243 | setEventMessages("NoRecordDeleted", null, 'warnings'); |
240 | 244 | Header("Location: list.php"); |
@@ -249,8 +253,7 @@ discard block |
||
249 | 253 | $result = $object->deleteMvtNum($mvt_num); |
250 | 254 | if ($result < 0) { |
251 | 255 | setEventMessages($object->error, $object->errors, 'errors'); |
252 | - } |
|
253 | - else |
|
256 | + } else |
|
254 | 257 | { |
255 | 258 | setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); |
256 | 259 | } |
@@ -267,8 +270,7 @@ discard block |
||
267 | 270 | if ($result < 0) |
268 | 271 | { |
269 | 272 | setEventMessages($object->error, $object->errors, 'errors'); |
270 | - } |
|
271 | - else |
|
273 | + } else |
|
272 | 274 | { |
273 | 275 | $accountancyexport = new AccountancyExport($db); |
274 | 276 | $accountancyexport->export($object->lines); |
@@ -341,12 +343,18 @@ discard block |
||
341 | 343 | } |
342 | 344 | |
343 | 345 | //$param=''; param started before |
344 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
345 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
346 | +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
347 | + $param.='&contextpage='.$contextpage; |
|
348 | +} |
|
349 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
350 | + $param.='&limit='.$limit; |
|
351 | +} |
|
346 | 352 | |
347 | 353 | print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; |
348 | 354 | print '<input type="hidden" name="action" value="list">'; |
349 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
355 | +if ($optioncss != '') { |
|
356 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
357 | +} |
|
350 | 358 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
351 | 359 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
352 | 360 | print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
@@ -355,8 +363,11 @@ discard block |
||
355 | 363 | |
356 | 364 | $listofformat=AccountancyExport::getType(); |
357 | 365 | $button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">'; |
358 | -if (count($filter)) $button.= $langs->trans("ExportFilteredList"); |
|
359 | -else $button.= $langs->trans("ExportList"); |
|
366 | +if (count($filter)) { |
|
367 | + $button.= $langs->trans("ExportFilteredList"); |
|
368 | +} else { |
|
369 | + $button.= $langs->trans("ExportList"); |
|
370 | +} |
|
360 | 371 | $button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')'; |
361 | 372 | $button.= '</a>'; |
362 | 373 | |
@@ -404,8 +415,7 @@ discard block |
||
404 | 415 | if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
405 | 416 | { |
406 | 417 | print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); |
407 | -} |
|
408 | -else |
|
418 | +} else |
|
409 | 419 | { |
410 | 420 | print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">'; |
411 | 421 | } |
@@ -417,8 +427,7 @@ discard block |
||
417 | 427 | if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) |
418 | 428 | { |
419 | 429 | print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); |
420 | -} |
|
421 | -else |
|
430 | +} else |
|
422 | 431 | { |
423 | 432 | print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">'; |
424 | 433 | } |
@@ -447,7 +456,9 @@ discard block |
||
447 | 456 | print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); |
448 | 457 | print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); |
449 | 458 | $checkpicto=''; |
450 | -if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); |
|
459 | +if ($massactionbutton) { |
|
460 | + $checkpicto=$form->showCheckAddButtons('checkforselect', 1); |
|
461 | +} |
|
451 | 462 | print_liste_field_titre($checkpicto, $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); |
452 | 463 | print "</tr>\n"; |
453 | 464 | |
@@ -489,8 +500,11 @@ discard block |
||
489 | 500 | } |
490 | 501 | |
491 | 502 | print '<tr class="liste_total">'; |
492 | -if ($num < $limit) print '<td align="left" colspan="7">'.$langs->trans("Total").'</td>'; |
|
493 | -else print '<td align="left" colspan="7">'.$langs->trans("Totalforthispage").'</td>'; |
|
503 | +if ($num < $limit) { |
|
504 | + print '<td align="left" colspan="7">'.$langs->trans("Total").'</td>'; |
|
505 | +} else { |
|
506 | + print '<td align="left" colspan="7">'.$langs->trans("Totalforthispage").'</td>'; |
|
507 | +} |
|
494 | 508 | print '</td>'; |
495 | 509 | print '<td align="right">'; |
496 | 510 | print price($total_debit); |