diff --git a/ChangeLog b/ChangeLog index 18f9fbe2dcb..a0aecd64a9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,7 +24,10 @@ Following changes may create regressions for some external modules, but were nec * All methods set_draft() were renamed into setDraft(). * Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject. * Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated. -* Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION +* Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION. +* Method dolEscapeXML was moved from functions.lib.php into function2.lib.php (not used enough to be loaded by default). +* Removed deprecated use of string in dol_print_date(). Only date allowed. + ***** ChangeLog for 9.0.1 compared to 9.0.0 ***** diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 8cc396f3bc1..9dd7f6c405b 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -407,18 +407,17 @@ foreach ($accounts as $key=>$type) $found++; - $obj = new Account($db); - $obj->fetch($key); + $result = $objecttmp->fetch($key); - $solde = $obj->solde(1); + $solde = $objecttmp->solde(1); - if (! empty($lastcurrencycode) && $lastcurrencycode != $obj->currency_code) + if (! empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) { $lastcurrencycode='various'; // We found several different currencies } if ($lastcurrencycode != 'various') { - $lastcurrencycode=$obj->currency_code; + $lastcurrencycode=$objecttmp->currency_code; } print ''; @@ -426,14 +425,14 @@ foreach ($accounts as $key=>$type) // Ref if (! empty($arrayfields['b.ref']['checked'])) { - print ''.$obj->getNomUrl(1).''; + print ''.$objecttmp->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } // Label if (! empty($arrayfields['b.label']['checked'])) { - print ''.$obj->label.''; + print ''.$objecttmp->label.''; if (! $i) $totalarray['nbfield']++; } @@ -441,7 +440,7 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['accountype']['checked'])) { print ''; - print $obj->type_lib[$obj->type]; + print $objecttmp->type_lib[$objecttmp->type]; print ''; if (! $i) $totalarray['nbfield']++; } @@ -449,7 +448,7 @@ foreach ($accounts as $key=>$type) // Number if (! empty($arrayfields['b.number']['checked'])) { - print ''.$obj->number.''; + print ''.$objecttmp->number.''; if (! $i) $totalarray['nbfield']++; } @@ -460,12 +459,12 @@ foreach ($accounts as $key=>$type) if (! empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $obj->account_number, 1); + $accountingaccount->fetch('', $objecttmp->account_number, 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); } else { - print $obj->account_number; + print $objecttmp->account_number; } print ''; if (! $i) $totalarray['nbfield']++; @@ -478,7 +477,7 @@ foreach ($accounts as $key=>$type) if (! empty($conf->accounting->enabled)) { $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($obj->fk_accountancy_journal); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); print $accountingjournal->getNomUrl(0, 1, 1, '', 1); } else @@ -493,7 +492,7 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['b.currency_code']['checked'])) { print ''; - print $obj->currency_code; + print $objecttmp->currency_code; print ''; if (! $i) $totalarray['nbfield']++; } @@ -502,11 +501,11 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['toreconcile']['checked'])) { print ''; - if ($obj->rappro) + if ($objecttmp->rappro) { - $result=$obj->load_board($user, $obj->id); + $result=$objecttmp->load_board($user, $objecttmp->id); if ($result<0) { - setEventMessages($obj->error, $obj->errors, 'errors'); + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { print $result->nbtodo; if ($result->nbtodolate) print '   ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; @@ -520,14 +519,14 @@ foreach ($accounts as $key=>$type) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['b.datec']['checked'])) { print ''; - print dol_print_date($obj->date_creation, 'dayhour'); + print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; if (! $i) $totalarray['nbfield']++; } @@ -535,7 +534,7 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['b.tms']['checked'])) { print ''; - print dol_print_date($obj->date_update, 'dayhour'); + print dol_print_date($objecttmp->date_update, 'dayhour'); print ''; if (! $i) $totalarray['nbfield']++; } @@ -543,7 +542,7 @@ foreach ($accounts as $key=>$type) // Status if (! empty($arrayfields['b.clos']['checked'])) { - print ''.$obj->getLibStatut(5).''; + print ''.$objecttmp->getLibStatut(5).''; if (! $i) $totalarray['nbfield']++; } @@ -551,7 +550,7 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['balance']['checked'])) { print ''; - print ''.price($solde, 0, $langs, 0, -1, -1, $obj->currency_code).''; + print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield']; @@ -563,15 +562,15 @@ foreach ($accounts as $key=>$type) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + if (in_array($objecttmp->id, $arrayofselected)) $selected=1; + print ''; } print ''; if (! $i) $totalarray['nbfield']++; print ''; - $total[$obj->currency_code] += $solde; + $total[$objecttmp->currency_code] += $solde; $i++; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 142dd1b0e1e..b462095278d 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1592,6 +1592,9 @@ class BonPrelevement extends CommonObject { // phpcs:enable global $conf; + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $CrLf = "\n"; $Rowing = sprintf("%06d", $row_idfac); diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index fa44c8dbcc9..87b32902684 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -224,9 +224,9 @@ class FormAccounting extends Form /** * Return select filter with date of transaction * - * @param string $htmlname Name of select field - * @param string $selectedkey Value - * @return string HTML edit field + * @param string $htmlname Name of select field + * @param string $selectedkey Value + * @return string HTML edit field */ public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { @@ -247,7 +247,7 @@ class FormAccounting extends Form } while ($obj = $this->db->fetch_object($resql)) { - $options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext'); + $options[$obj->import_key] = $obj->import_key; } return Form::selectarray($htmlname, $options, $selectedkey); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 916e46c6ab5..1f6b029acc0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -886,17 +886,6 @@ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') } -/** - * Encode string for xml usage - * - * @param string $string String to encode - * @return string String encoded - */ -function dolEscapeXML($string) -{ - return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); -} - /** * Returns text escaped for inclusion into javascript code * @@ -1785,8 +1774,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg) || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 { - // TODO Remove this. This part of code should not be used. - dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); + // This part of code should not be used. + /*dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' $syear = (! empty($reg[1]) ? $reg[1] : ''); @@ -1797,7 +1786,9 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang $ssec = (! empty($reg[6]) ? $reg[6] : ''); $time=dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); - $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); + $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt);*/ + dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); + return ''; } else { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 616f0bed7db..ffdf161fc7a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2414,28 +2414,39 @@ function getModuleDirForApiClass($module) return $moduledirforclass; } -/* +/** * Return 2 hexa code randomly * - * @param $min int Between 0 and 255 - * @param $max int Between 0 and 255 - * @return String + * @param int $min Between 0 and 255 + * @param int $max Between 0 and 255 + * @return string A color string '12' */ -function random_color_part($min = 0, $max = 255) +function randomColorPart($min = 0, $max = 255) { return str_pad(dechex(mt_rand($min, $max)), 2, '0', STR_PAD_LEFT); } -/* +/** * Return hexadecimal color randomly * - * @param $min int Between 0 and 255 - * @param $max int Between 0 and 255 - * @return String + * @param int $min Between 0 and 255 + * @param int $max Between 0 and 255 + * @return string A color string '123456' */ -function random_color($min = 0, $max = 255) +function randomColor($min = 0, $max = 255) { - return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max); + return randomColorPart($min, $max) . randomColorPart($min, $max) . randomColorPart($min, $max); +} + +/** + * Encode string for xml usage + * + * @param string $string String to encode + * @return string String encoded + */ +function dolEscapeXML($string) +{ + return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); } /** diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1ba60bf9b41..b97b29ad47f 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -117,7 +117,7 @@ class pdf_crabe extends ModelePDFFactures /** * Issuer - * @var Company object that emits + * @var Societe object that emits */ public $emetteur; @@ -856,7 +856,7 @@ class pdf_crabe extends ModelePDFFactures $invoice->fetch($obj->fk_facture_source); $pdf->SetXY($tab3_posx, $tab3_top+$y); - $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0); + $pdf->MultiCell(20, 3, dol_print_date($db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index da45babde4f..5e18b895c97 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -928,7 +928,7 @@ class pdf_sponge extends ModelePDFFactures $invoice->fetch($obj->fk_facture_source); $pdf->SetXY($tab3_posx, $tab3_top+$y); - $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0); + $pdf->MultiCell(20, 3, dol_print_date($db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); @@ -1829,7 +1829,7 @@ class pdf_sponge extends ModelePDFFactures * Define Array Column Field * * @param object $object common object - * @param outputlangs $outputlangs langs + * @param Translate $outputlangs langs * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php index acf1aad36ce..fba0810e7cd 100644 --- a/htdocs/core/tpl/bloc_comment.tpl.php +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -64,9 +64,11 @@ if (!empty($object->comments)) $fk_user = $comment->fk_user_author; $userstatic->fetch($fk_user); - if(empty($TColors[$fk_user])) { - $bgcolor = random_color(180, 240); - if(!empty($userstatic->color)) { + if (empty($TColors[$fk_user])) + { + $bgcolor = randomColor(180, 240); + if (!empty($userstatic->color)) + { $bgcolor = $userstatic->color; } $color = (colorIsLight($bgcolor))?'555':'fff'; diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 98db1318aa7..1823e5f0a93 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -173,10 +173,10 @@ else print ''; print '' . $user->getFullName($langs) . ''; print '' . $obj->label . ''; - print '' . dol_print_date($obj->date_debut, 'day'); + print '' . dol_print_date($db->jdate($obj->date_debut), 'day'); print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; print ''; - print '' . dol_print_date($obj->date_fin, 'day'); + print '' . dol_print_date($db->jdate($obj->date_fin), 'day'); print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; print ''; print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b02295c94e3..cd9cd846a5c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2016 Marcos GarcĂ­a * Copyright (C) 2013-2018 Juanjo Menent @@ -981,7 +981,7 @@ if ($resql) if (! empty($arrayfields['p.datec']['checked'])) { print ''; - print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (! $i) $totalarray['nbfield']++; } @@ -989,7 +989,7 @@ if ($resql) if (! empty($arrayfields['p.tms']['checked'])) { print ''; - print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 6f5a63129de..b3fb66116bf 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -479,6 +479,20 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S { $obj = $db->fetch_object($resql); + $projectstatic->id = $obj->projectid; + $projectstatic->ref = $obj->ref; + $projectstatic->title = $obj->title; + $projectstatic->statut = $obj->status; + $projectstatic->public = $obj->public; + $projectstatic->dateo = $db->jdate($obj->projdateo); + $projectstatic->datee = $db->jdate($obj->projdatee); + + $taskstatic->projectstatus = $obj->projectstatus; + $taskstatic->progress = $obj->progress; + $taskstatic->fk_statut = $obj->status; + $taskstatic->dateo = $db->jdate($obj->dateo); + $taskstatic->datee = $db->jdate($obj->datee); + $username=''; if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user { @@ -490,14 +504,6 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; //print ''.$username.''; print ''; - $projectstatic->id=$obj->projectid; - $projectstatic->ref=$obj->ref; - $projectstatic->title=$obj->title; - $projectstatic->statut = $obj->status; - $projectstatic->public = $obj->public; - $projectstatic->dateo = $db->jdate($obj->projdateo); - $projectstatic->datee = $db->jdate($obj->projdatee); - print $projectstatic->getNomUrl(1, '', 0, '', '
'); print ''; if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) @@ -517,14 +523,8 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S } else print $langs->trans("NoTasks"); print ''; - $taskstatic->projectstatus = $obj->projectstatus; - $taskstatic->progress = $obj->progress; - $taskstatic->fk_statut = $obj->status; - $taskstatic->dateo = $db->jdate($obj->dateo); - $taskstatic->datee = $db->jdate($obj->datee); print ''.dol_print_date($db->jdate($obj->dateo), 'day').''; print ''.dol_print_date($db->jdate($obj->datee), 'day'); - print dol_print_date($obj->date_end, 'dayhour'); if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print ''; print ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 108bd5db11a..73b691500fd 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -519,21 +519,21 @@ if ($action == "view_ticketlist") // Date ticket if (!empty($arrayfields['t.datec']['checked'])) { print ''; - print dol_print_date($obj->datec, 'dayhour'); + print dol_print_date($db->jdate($obj->datec), 'dayhour'); print ''; } // Date read if (!empty($arrayfields['t.date_read']['checked'])) { print ''; - print dol_print_date($obj->date_read, 'dayhour'); + print dol_print_date($db->jdate($obj->date_read), 'dayhour'); print ''; } // Date close if (!empty($arrayfields['t.date_close']['checked'])) { print ''; - print dol_print_date($obj->date_close, 'dayhour'); + print dol_print_date($db->jdate($obj->date_close), 'dayhour'); print ''; } @@ -616,7 +616,7 @@ if ($action == "view_ticketlist") } if (!empty($arrayfields['t.tms']['checked'])) { - print '' . dol_print_date($obj->tms, 'dayhour') . ''; + print '' . dol_print_date($db->jdate($obj->tms), 'dayhour') . ''; } // Extra fields diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 05b05424b4f..451198945fc 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -1049,46 +1049,47 @@ function getProductsForCategory($authentication, $id, $lang = '') if ($res) { $iProduct = 0; + $tmpproduct = new Product($db); + $products=array(); while ($rec = $db->fetch_array($res)) { - $obj = new Product($db); - $obj->fetch($rec['fk_'.$field]); - if($obj->status > 0 ) + $tmpproduct->fetch($rec['fk_'.$field]); + if ($tmpproduct->status > 0) { $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($obj->id, 2, 0, 0, $product, 'product') . $obj->id ."/photos/"; + $pdir = get_exdir($tmpproduct->id, 2, 0, 0, $tmpproduct, 'product') . $tmpproduct->id ."/photos/"; $dir = $dir . '/'. $pdir; $products[] = array( - 'id' => $obj->id, - 'ref' => $obj->ref, - 'ref_ext' => $obj->ref_ext, - 'label' => ! empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, - 'description' => ! empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, - 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), - 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), - 'note' => ! empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, - 'status_tosell' => $obj->status, - 'status_tobuy' => $obj->status_buy, - 'type' => $obj->type, - 'barcode' => $obj->barcode, - 'barcode_type' => $obj->barcode_type, - 'country_id' => $obj->country_id>0?$obj->country_id:'', - 'country_code' => $obj->country_code, - 'custom_code' => $obj->customcode, + 'id' => $tmpproduct->id, + 'ref' => $tmpproduct->ref, + 'ref_ext' => $tmpproduct->ref_ext, + 'label' => ! empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label, + 'description' => ! empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description, + 'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($tmpproduct->date_modification, 'dayhourrfc'), + 'note' => ! empty($tmpproduct->multilangs[$langs->defaultlang]["note"]) ? $tmpproduct->multilangs[$langs->defaultlang]["note"] : $tmpproduct->note, + 'status_tosell' => $tmpproduct->status, + 'status_tobuy' => $tmpproduct->status_buy, + 'type' => $tmpproduct->type, + 'barcode' => $tmpproduct->barcode, + 'barcode_type' => $tmpproduct->barcode_type, + 'country_id' => $tmpproduct->country_id>0?$tmpproduct->country_id:'', + 'country_code' => $tmpproduct->country_code, + 'custom_code' => $tmpproduct->customcode, - 'price_net' => $obj->price, - 'price' => $obj->price_ttc, - 'vat_rate' => $obj->tva_tx, + 'price_net' => $tmpproduct->price, + 'price' => $tmpproduct->price_ttc, + 'vat_rate' => $tmpproduct->tva_tx, - 'price_base_type' => $obj->price_base_type, + 'price_base_type' => $tmpproduct->price_base_type, - 'stock_real' => $obj->stock_reel, - 'stock_alert' => $obj->seuil_stock_alerte, - 'pmp' => $obj->pmp, - 'import_key' => $obj->import_key, + 'stock_real' => $tmpproduct->stock_reel, + 'stock_alert' => $tmpproduct->seuil_stock_alerte, + 'pmp' => $tmpproduct->pmp, + 'import_key' => $tmpproduct->import_key, 'dir' => $pdir, - 'images' => $obj->liste_photos($dir, $nbmax) + 'images' => $tmpproduct->liste_photos($dir, $nbmax) ); //Retreive all extrafield for thirdsparty @@ -1096,11 +1097,11 @@ function getProductsForCategory($authentication, $id, $lang = '') $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('product', true); //Get extrafield values - $obj->fetch_optionals(); + $tmpproduct->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { - $products[$iProduct]=array_merge($products[$iProduct], array('options_'.$key => $obj->array_options['options_'.$key])); + $products[$iProduct]=array_merge($products[$iProduct], array('options_'.$key => $tmpproduct->array_options['options_'.$key])); } $iProduct++; @@ -1117,7 +1118,7 @@ function getProductsForCategory($authentication, $id, $lang = '') { $errorcode='NORECORDS_FOR_ASSOCIATION'; $errorlabel='No products associated'.$sql; $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - dol_syslog("getProductsForCategory:: ".$c->error, LOG_DEBUG); + dol_syslog("getProductsForCategory:: ".$errorcode, LOG_DEBUG); } } else