Commit c0d7b5014b121e89134182756a9e6e6df3576be7

Authored by Darkjeff
1 parent ba292a41
Exists in 3.5 and in 1 other branch 3.6

purchase ventilation Ok

Showing 1 changed file with 54 additions and 8 deletions   Show diff stats
accountingex/supplier/liste.php
... ... @@ -83,7 +83,7 @@ if ($action == 'ventil') {
83 83 $sql .= " SET fk_code_ventilation = " . $monCompte;
84 84 $sql .= " WHERE rowid = " . $monId;
85 85  
86   - dol_syslog('accountingext/supplier/liste.php:: sql=' . $sql);
  86 + dol_syslog('accountingex/supplier/liste.php:: sql=' . $sql, LOG_DEBUG);
87 87 if ($db->query($sql)) {
88 88 print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
89 89 } else {
... ... @@ -150,14 +150,14 @@ if (! empty($conf-&gt;global-&gt;ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) {
150 150 $offset = $limit * $page;
151 151  
152 152 $sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, ";
153   -$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy";
  153 +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, l.product_type as type, p.accountancy_code_buy as code_buy";
154 154 $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
155 155 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
156 156 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
157 157 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
158 158 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
159 159 $sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
160   -$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL)";
  160 +$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')";
161 161 if (! empty($conf->multicompany->enabled)) {
162 162 $sql .= " AND f.entity = '" . $conf->entity . "'";
163 163 }
... ... @@ -168,7 +168,7 @@ if ($conf-&gt;global-&gt;ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO &gt; 0) {
168 168 }
169 169 $sql .= $db->plimit($limit + 1, $offset);
170 170  
171   -dol_syslog('accountingext/supplier/liste.php:: $sql=' . $sql);
  171 +dol_syslog('accountingext/supplier/liste.php:: $sql=' . $sql, LOG_DEBUG);
172 172 $result = $db->query($sql);
173 173 if ($result) {
174 174 $num_lignes = $db->num_rows($result);
... ... @@ -201,6 +201,48 @@ if ($result) {
201 201 while ( $i < min($num_lignes, $limit) ) {
202 202 $objp = $db->fetch_object($result);
203 203 $var = ! $var;
  204 +
  205 +
  206 + // product_type: 0 = service ? 1 = product
  207 + // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
  208 + // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
  209 + $code_buy_notset = '';
  210 +
  211 + if (empty($objp->code_buy)) {
  212 + $code_buy_notset = 'color:red';
  213 +
  214 + }else {
  215 + $code_buy_notset = 'color:blue';
  216 +
  217 + }
  218 +
  219 + if ($objp->type == 1) {
  220 + $objp->code_buy2 = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
  221 +
  222 + } else {
  223 + $objp->code_buy2 = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
  224 + }
  225 +
  226 +
  227 + if ($objp->type == 1) {
  228 + $objp->code_buy2 = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
  229 +
  230 + } else {
  231 + $objp->code_buy2 = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
  232 +
  233 +
  234 +
  235 + }
  236 +
  237 +
  238 +
  239 +
  240 +
  241 +
  242 +
  243 +
  244 +
  245 +
204 246 print "<tr $bc[$var]>";
205 247  
206 248 // Ref facture
... ... @@ -225,20 +267,24 @@ if ($result) {
225 267  
226 268 print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
227 269  
228   - print '<td>' . stripslashes(nl2br($objp->description)) . '</td>';
  270 + print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
229 271  
230 272 print '<td align="right">';
231 273 print price($objp->price);
232 274 print '</td>';
233 275  
234   - print '<td align="right">';
235   - print $objp->code_buy;
  276 + print '<td align="center" style="' . $code_buy_notset . '">';
  277 + print $objp->code_buy2;
  278 + print '</td>';
  279 +
  280 + print '<td align="center" style="' . $code_buy_notset . '">';
  281 + print $objp->type;
236 282 print '</td>';
237 283  
238 284 // Colonne choix du compte
239 285 print '<td align="center">';
240 286 //print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1);
241   - print $form->selectarray("codeventil[]",$cgs, $cgn[$objp->code_buy]);
  287 + print $form->selectarray("codeventil[]",$cgs, $cgn[$objp->code_buy2]);
242 288 print '</td>';
243 289 // Colonne choix ligne a ventiler
244 290 print '<td align="center">';
... ...