# WARNING: head commit changed in the meantime

Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
new_add_hook_load_state_board
This commit is contained in:
Regis Houssin 2022-03-23 15:53:09 +01:00
commit fcb1bdaca1
27 changed files with 394 additions and 204 deletions

View File

@ -29,7 +29,7 @@
/** /**
* \file htdocs/accountancy/class/accountancyimport.class.php * \file htdocs/accountancy/class/accountancyimport.class.php
* \ingroup Accountancy (Double entries) * \ingroup Accountancy (Double entries)
* \brief Class accountancy import * \brief Class with methods for accountancy import
*/ */
@ -52,68 +52,91 @@ class AccountancyImport
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
global $conf;
$this->db = $db; $this->db = $db;
} }
/**
* Clean amount
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param int $record_key Record key
* @return mixed Value
*/
public function cleanAmount(&$arrayrecord, $listfields, $record_key)
{
$value_trim = trim($arrayrecord[$record_key]['val']);
return floatval($value_trim);
}
/**
* Clean value with trim
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $listfields Fields list to add
* @param int $record_key Record key
* @return mixed Value
*/
public function cleanValue(&$arrayrecord, $listfields, $record_key)
{
return trim($arrayrecord[$record_key]['val']);
}
/** /**
* Compute amount * Compute amount
* *
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param string $fieldname Field name with alias
* @param array $listfields Fields list to add * @param array $listfields Fields list to add
* @param array $listvalues Values list to add * @param int $record_key Record key
* @return int <0 if KO, >0 if OK * @return mixed Value
*/ */
public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues) public function computeAmount(&$arrayrecord, $listfields, $record_key)
{ {
$fieldArr = explode('.', $fieldname); // get fields indexes
if (count($fieldArr) > 0) { $field_index_list = array_flip($listfields);
$fieldname = $fieldArr[1]; if (isset($field_index_list['debit']) && isset($field_index_list['credit'])) {
} $debit_index = $field_index_list['debit'];
$credit_index = $field_index_list['credit'];
$debit = floatval(trim($arrayrecord[11]['val'])); $debit = floatval($arrayrecord[$debit_index]['val']);
$credit = floatval(trim($arrayrecord[12]['val'])); $credit = floatval($arrayrecord[$credit_index]['val']);
if (!empty($debit)) { if (!empty($debit)) {
$amount = $debit; $amount = $debit;
} else { } else {
$amount = $credit; $amount = $credit;
} }
$listfields[] = $fieldname; return "'" . $this->db->escape(abs($amount)) . "'";
$listvalues[] = "'" . abs($amount) . "'"; }
return 1; return "''";
} }
/** /**
* Compute sens * Compute direction
* *
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param string $fieldname Field name with alias
* @param array $listfields Fields list to add * @param array $listfields Fields list to add
* @param array $listvalues Values list to add * @param int $record_key Record key
* @return int <0 if KO, >0 if OK * @return mixed Value
*/ */
public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues) public function computeDirection(&$arrayrecord, $listfields, $record_key)
{ {
$fieldArr = explode('.', $fieldname); $field_index_list = array_flip($listfields);
if (count($fieldArr) > 0) { if (isset($field_index_list['debit'])) {
$fieldname = $fieldArr[1]; $debit_index = $field_index_list['debit'];
}
$debit = floatval(trim($arrayrecord[11]['val'])); $debit = floatval($arrayrecord[$debit_index]['val']);
if (!empty($debit)) { if (!empty($debit)) {
$sens = 'D'; $sens = 'D';
} else { } else {
$sens = 'C'; $sens = 'C';
} }
$listfields[] = $fieldname; return "'" . $this->db->escape($sens) . "'";
$listvalues[] = "'" . $sens . "'"; }
return 1; return "''";
} }
} }

View File

@ -1546,19 +1546,19 @@ if ($id > 0) {
print '</td><td td colspan="3">'; print '</td><td td colspan="3">';
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} elseif (GETPOST("afaire") == 2) { } elseif (GETPOST("afaire") == 2) {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} else { } else {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} }
print ' - '; print ' - ';
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} elseif (GETPOST("afaire") == 2) { } elseif (GETPOST("afaire") == 2) {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} else { } else {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
} }
print '</td></tr>'; print '</td></tr>';
@ -1996,11 +1996,15 @@ if ($id > 0) {
// Date start // Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionStart").'</td><td>';
// Test a date before the 27 march and one after
//print dol_print_date($object->datep, 'dayhour', 'gmt');
//print dol_print_date($object->datep, 'dayhour', 'tzuser');
//print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datep, 'dayhour', 'tzuser'); print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
} else { } else {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser')); print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
} }
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));
@ -2011,10 +2015,10 @@ if ($id > 0) {
// Date end // Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datef, 'dayhour', 'tzuser'); print dol_print_date($object->datef, 'dayhour', 'tzuserrel');
} else { } else {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser')); print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
} }
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) { if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));

View File

@ -208,6 +208,9 @@ if (empty($reshook)) {
$object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->model_pdf = GETPOST('modelpdf', 'alpha');
$object->usenewprice = GETPOST('usenewprice', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->frequency = $frequency; $object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max; $object->nb_gen_max = $nb_gen_max;
@ -261,8 +264,6 @@ if (empty($reshook)) {
} else { } else {
$db->rollback(); $db->rollback();
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = "create"; $action = "create";
} }
} }
@ -1027,12 +1028,14 @@ if ($action == 'create') {
// Payment term // Payment term
print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>"; print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $object->cond_reglement_id, 'cond_reglement_id', -1, 0, 0, '');
//$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
print "</td></tr>"; print "</td></tr>";
// Payment mode // Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>"; print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1); print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
//$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
print "</td></tr>"; print "</td></tr>";
// Project // Project
@ -1040,8 +1043,9 @@ if ($action == 'create') {
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>'; print '<tr><td>'.$langs->trans('Project').'</td><td>';
print img_picto('', 'project');
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
print '</td></tr>'; print '</td></tr>';
} }
@ -1074,7 +1078,8 @@ if ($action == 'create') {
// Frequency + unit // Frequency + unit
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm')); print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;";
print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm'));
print "</td></tr>"; print "</td></tr>";
// Date next run // Date next run
@ -1474,15 +1479,16 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<table class="nobordernopadding">'; print '<table class="nobordernopadding">';
print '<tr><td>'; print '<tr><td>';
print "<input type='text' name='frequency' value='".$object->frequency."' size='5' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm')); print "<input type='text' name='frequency' value='".$object->frequency."' size='5' />&nbsp;";
print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm'));
print '</td>'; print '</td>';
print '<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>'; print '<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>'; print '</tr></table></form>';
} else { } else {
if ($object->frequency > 0) { if ($object->frequency > 0) {
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
} else { } else {
print $langs->trans("NotARecurringInvoiceTemplate"); print '<span class="opacitymedium">'.$langs->trans("NotARecurringInvoiceTemplate").'</span>';
} }
} }
print '</td></tr>'; print '</td></tr>';

View File

@ -3857,7 +3857,6 @@ if ($action == 'create') {
print "</form>\n"; print "</form>\n";
} elseif ($id > 0 || !empty($ref)) { } elseif ($id > 0 || !empty($ref)) {
if (empty($object->id)) { if (empty($object->id)) {
llxHeader();
$langs->load('errors'); $langs->load('errors');
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>'; echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
llxFooter(); llxFooter();

View File

@ -309,10 +309,10 @@ class FactureRec extends CommonInvoice
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL"); $sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL");
$sql .= ", ".((int) $user->id); $sql .= ", ".((int) $user->id);
$sql .= ", ".(!empty($facsrc->fk_project) ? ((int) $facsrc->fk_project) : "null"); $sql .= ", ".(!empty($this->fk_project) ? ((int) $this->fk_project) : "null");
$sql .= ", ".(!empty($facsrc->fk_account) ? ((int) $facsrc->fk_account) : "null"); $sql .= ", ".(!empty($facsrc->fk_account) ? ((int) $facsrc->fk_account) : "null");
$sql .= ", ".($facsrc->cond_reglement_id > 0 ? ((int) $facsrc->cond_reglement_id) : "null"); $sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null");
$sql .= ", ".($facsrc->mode_reglement_id > 0 ? ((int) $facsrc->mode_reglement_id) : "null"); $sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "null");
$sql .= ", ".((int) $this->usenewprice); $sql .= ", ".((int) $this->usenewprice);
$sql .= ", ".((int) $this->frequency); $sql .= ", ".((int) $this->frequency);
$sql .= ", '".$this->db->escape($this->unit_frequency)."'"; $sql .= ", '".$this->db->escape($this->unit_frequency)."'";
@ -344,6 +344,9 @@ class FactureRec extends CommonInvoice
$tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')';
} }
$default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
$default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
$result_insert = $this->addline( $result_insert = $this->addline(
$facsrc->lines[$i]->desc, $facsrc->lines[$i]->desc,
$facsrc->lines[$i]->subprice, $facsrc->lines[$i]->subprice,
@ -363,8 +366,8 @@ class FactureRec extends CommonInvoice
$facsrc->lines[$i]->label, $facsrc->lines[$i]->label,
$facsrc->lines[$i]->fk_unit, $facsrc->lines[$i]->fk_unit,
$facsrc->lines[$i]->multicurrency_subprice, $facsrc->lines[$i]->multicurrency_subprice,
0, $default_start_fill,
0, $default_end_fill,
null, null,
$facsrc->lines[$i]->pa_ht $facsrc->lines[$i]->pa_ht
); );

View File

@ -1831,7 +1831,7 @@ class BonPrelevement extends CommonObject
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d'); $DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
if ($type != 'bank-transfer') { if ($type != 'bank-transfer') {
// SEPA Paiement Information of buyer for Direct debit // SEPA Paiement Information of buyer for Direct Debit
$XML_DEBITOR = ''; $XML_DEBITOR = '';
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf; $XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;
$XML_DEBITOR .= ' <PmtId>'.$CrLf; $XML_DEBITOR .= ' <PmtId>'.$CrLf;
@ -1884,7 +1884,7 @@ class BonPrelevement extends CommonObject
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
$XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
$XML_CREDITOR .= ' </PmtId>'.$CrLf; $XML_CREDITOR .= ' </PmtId>'.$CrLf;
if ($this->sepa_xml_pti_in_ctti) { if (!empty($this->sepa_xml_pti_in_ctti)) {
$XML_CREDITOR .= ' <PmtTpInf>' . $CrLf; $XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;
// Can be 'NORM' for normal or 'HIGH' for high priority level // Can be 'NORM' for normal or 'HIGH' for high priority level
@ -2076,7 +2076,7 @@ class BonPrelevement extends CommonObject
$RefBon = $obj->ref; $RefBon = $obj->ref;
if ($type != 'bank-transfer') { if ($type != 'bank-transfer') {
// SEPA Paiement Information of my company for Direct debit // SEPA Paiement Information of my company for Direct Debit
$XML_SEPA_INFO = ''; $XML_SEPA_INFO = '';
$XML_SEPA_INFO .= ' <PmtInf>'.$CrLf; $XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;
$XML_SEPA_INFO .= ' <PmtInfId>'.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf; $XML_SEPA_INFO .= ' <PmtInfId>'.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf;
@ -2147,7 +2147,7 @@ class BonPrelevement extends CommonObject
//$XML_SEPA_INFO .= ' <BtchBookg>False</BtchBookg>'.$CrLf; //$XML_SEPA_INFO .= ' <BtchBookg>False</BtchBookg>'.$CrLf;
$XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf; $XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;
$XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf; $XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;
if (!$this->sepa_xml_pti_in_ctti) { if (!empty($this->sepa_xml_pti_in_ctti) && !empty($format)) { // @TODO Using $format (FRST ou RCUR) in a section for a Credit Transfer looks strange.
$XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf; $XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;
$XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf; $XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf; $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;

View File

@ -376,7 +376,7 @@ class Contact extends CommonObject
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $user; global $user, $hookmanager;
$this->nb = array(); $this->nb = array();
$clause = "WHERE"; $clause = "WHERE";
@ -394,6 +394,12 @@ class Contact extends CommonObject
if ($user->socid > 0) { if ($user->socid > 0) {
$sql .= " AND sp.fk_soc = ".((int) $user->socid); $sql .= " AND sp.fk_soc = ".((int) $user->socid);
} }
// Add where from hooks
if (is_object($hookmanager)) {
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View File

@ -233,10 +233,10 @@ class Contrat extends CommonObject
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70),
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>75),
'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial suivi', 'enabled'=>1, 'visible'=>-1, 'position'=>85), 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90),
'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105),
'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115),
@ -245,7 +245,7 @@ class Contrat extends CommonObject
'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130),
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed')) 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'notnull'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed'))
); );
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES

View File

@ -212,6 +212,29 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
print dol_get_fiche_head($head, 'customreports', $title, -1, $picto); print dol_get_fiche_head($head, 'customreports', $title, -1, $picto);
} }
$newarrayoftype = array();
foreach ($arrayoftype as $key => $val) {
if (dol_eval($val['enabled'], 1, 1, '1')) {
$newarrayoftype[$key] = $arrayoftype[$key];
}
if ($val['langs']) {
$langs->load($val['langs']);
}
}
$count = 0;
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
$arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1);
$count = 0;
$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count);
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
$count = 0;
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
// Check parameters // Check parameters
if ($action == 'viewgraph') { if ($action == 'viewgraph') {
if (!count($search_measures)) { if (!count($search_measures)) {
@ -253,10 +276,18 @@ if (is_array($search_groupby) && count($search_groupby)) {
} }
$sql = "SELECT DISTINCT ".$fieldtocount." as val"; $sql = "SELECT DISTINCT ".$fieldtocount." as val";
if (strpos($fieldtocount, 'te.') === 0) { if (strpos($fieldtocount, 'te.') === 0) {
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.'_extrafields as te'; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te";
} else { } else {
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; $tabletouse = $object->table_element;
$tablealiastouse = 't';
if (!empty($arrayofgroupby[$gval])) {
$tmpval = explode('.', $gval);
$tabletouse = $arrayofgroupby[$gval]['table'];
$tablealiastouse = $tmpval[0];
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse;
} }
// Add the where here // Add the where here
@ -272,7 +303,7 @@ if (is_array($search_groupby) && count($search_groupby)) {
} }
}*/ }*/
$sql .= ' LIMIT '.($MAXUNIQUEVALFORGROUP + 1); $sql .= " LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
@ -319,8 +350,17 @@ if (is_array($search_groupby) && count($search_groupby)) {
$arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated; $arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated;
} }
// Add also the possible NULL value if field is a parent field that is not a strict join
$tmpfield = explode('.', $gval);
if ($tmpfield[0] != 't' || (is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) {
dol_syslog("The group by field ".$gval." may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values");
//var_dump($gval); var_dump($object->fields);
$arrayofvaluesforgroupby['g_'.$gkey]['__NULL__'] = $langs->transnoentitiesnoconv("NotDefined");
}
asort($arrayofvaluesforgroupby['g_'.$gkey]); asort($arrayofvaluesforgroupby['g_'.$gkey]);
// Add a protection/error to refuse the request if number of differentr values for the group by is higher than $MAXUNIQUEVALFORGROUP
if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) { if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
$langs->load("errors"); $langs->load("errors");
if (strpos($fieldtocount, 'te.') === 0) { if (strpos($fieldtocount, 'te.') === 0) {
@ -380,15 +420,6 @@ print '<div class="liste_titre liste_titre_bydiv centpercent">';
// Select object // Select object
print '<div class="divadvancedsearchfield center floatnone">'; print '<div class="divadvancedsearchfield center floatnone">';
print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> '; print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> ';
$newarrayoftype = array();
foreach ($arrayoftype as $key => $val) {
if (dol_eval($val['enabled'], 1, 1, '1')) {
$newarrayoftype[$key] = $arrayoftype[$key];
}
if ($val['langs']) {
$langs->load($val['langs']);
}
}
print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1); print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1);
if (empty($conf->use_javascript_ajax)) { if (empty($conf->use_javascript_ajax)) {
print '<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans("Refresh").'">'; print '<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans("Refresh").'">';
@ -412,17 +443,18 @@ print '</div>';
// Add measures into array // Add measures into array
$count = 0; $count = 0;
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
//var_dump($arrayofmesures); //var_dump($arrayofmesures);
print '<div class="divadvancedsearchfield clearboth">'; print '<div class="divadvancedsearchfield clearboth">';
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>'; print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>';
print $form->multiselectarray('search_measures', $arrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields $simplearrayofmesures = array();
foreach ($arrayofmesures as $key => $val) {
$simplearrayofmesures[$key] = $arrayofmesures[$key]['label'];
}
print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields
print '</div>'; print '</div>';
// XAxis // XAxis
$count = 0; $count = 0;
$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count);
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
print '<div class="divadvancedsearchfield">'; print '<div class="divadvancedsearchfield">';
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>'; print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>';
//var_dump($arrayofxaxis); //var_dump($arrayofxaxis);
@ -431,8 +463,6 @@ print '</div>';
// Group by // Group by
$count = 0; $count = 0;
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
print '<div class="divadvancedsearchfield">'; print '<div class="divadvancedsearchfield">';
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>'; print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>';
print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields
@ -454,18 +484,38 @@ if ($mode == 'grid') {
continue; continue;
} }
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofyaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position']); $arrayofyaxis['t.'.$key.'-year'] = array(
$arrayofyaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position']); 'label' => $langs->trans($val['label']).' ('.$YYYY.')',
$arrayofyaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position']); 'position' => $val['position'],
'table' => $object->table_element
);
$arrayofyaxis['t.'.$key.'-month'] = array(
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')',
'position' => $val['position'],
'table' => $object->table_element
);
$arrayofyaxis['t.'.$key.'-day'] = array(
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')',
'position' => $val['position'],
'table' => $object->table_element
);
} else { } else {
$arrayofyaxis['t.'.$key] = array('label' => $val['label'], 'position' => (int) $val['position']); $arrayofyaxis['t.'.$key] = array(
'label' => $val['label'],
'position' => (int) $val['position'],
'table' => $object->table_element
);
} }
} }
// Add measure from extrafields // Add measure from extrafields
if ($object->isextrafieldmanaged) { if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) { if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
$arrayofyaxis['te.'.$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key]); $arrayofyaxis['te.'.$key] = array(
'label' => $extrafields->attributes[$object->table_element]['label'][$key],
'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key],
'table' => $object->table_element
);
} }
} }
} }
@ -495,7 +545,7 @@ $sql = '';
if (!empty($search_measures) && !empty($search_xaxis)) { if (!empty($search_measures) && !empty($search_xaxis)) {
$fieldid = 'rowid'; $fieldid = 'rowid';
$sql = 'SELECT '; $sql = "SELECT ";
foreach ($search_xaxis as $key => $val) { foreach ($search_xaxis as $key => $val) {
if (preg_match('/\-year$/', $val)) { if (preg_match('/\-year$/', $val)) {
$tmpval = preg_replace('/\-year$/', '', $val); $tmpval = preg_replace('/\-year$/', '', $val);
@ -542,40 +592,72 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
} }
} }
$sql = preg_replace('/,\s*$/', '', $sql); $sql = preg_replace('/,\s*$/', '', $sql);
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
// Add measure from extrafields // Add measure from extrafields
if ($object->isextrafieldmanaged) { if ($object->isextrafieldmanaged) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
} }
if ($object->ismultientitymanaged) { // Add table for link for multientity
if ($object->ismultientitymanaged) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
if ($object->ismultientitymanaged == 1) { if ($object->ismultientitymanaged == 1) {
// Nothing here // No table to add here
} else { } else {
$tmparray = explode('@', $object->ismultientitymanaged); $tmparray = explode('@', $object->ismultientitymanaged);
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON t.".$tmparray[0]." = parenttable.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttableforentity ON t.".$tmparray[0]." = parenttableforentity.rowid";
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; $sql .= " AND parenttableforentity.entity IN (".getEntity($tmparray[1]).")";
} }
} }
// Add INNER JOIN for all parent tables
//var_dump($arrayofxaxis); var_dump($search_xaxis);
$listoftablesalreadyadded = array($object->table_element => $object->table_element); $listoftablesalreadyadded = array($object->table_element => $object->table_element);
// Add LEFT JOIN for all parent tables mentionned into the Xaxis
//var_dump($arrayofxaxis); var_dump($search_xaxis);
foreach ($search_xaxis as $key => $val) { foreach ($search_xaxis as $key => $val) {
if (!empty($arrayofxaxis[$val])) { if (!empty($arrayofxaxis[$val])) {
$tmpval = explode('.', $val); $tmpval = explode('.', $val);
//var_dump($arrayofxaxis[$val]['table']); //var_dump($arrayofxaxis[$val]['table']);
if (! in_array($arrayofxaxis[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added if (! in_array($arrayofxaxis[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$arrayofxaxis[$val]['table'].' as '.$db->sanitize($tmpval[0]); $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofxaxis[$val]['table']." as ".$db->sanitize($tmpval[0])." ON t.".str_replace('t__', '', $db->sanitize($tmpval[0]))." = ".$db->sanitize($tmpval[0]).".rowid";
$listoftablesalreadyadded[$arrayofxaxis[$val]['table']] = $arrayofxaxis[$val]['table']; $listoftablesalreadyadded[$arrayofxaxis[$val]['table']] = $arrayofxaxis[$val]['table'];
} }
} else { } else {
dol_print_error($db, 'Found an key into search_xaxis not found into arrayofxaxis'); dol_print_error($db, 'Found a key into search_xaxis not found into arrayofxaxis');
} }
} }
$sql .= ' WHERE 1 = 1'; // Add LEFT JOIN for all parent tables mentionned into the Group by
if ($object->ismultientitymanaged == 1) { //var_dump($arrayofgroupby); var_dump($search_groupby);
$sql .= ' AND t.entity IN ('.getEntity($object->element).')'; foreach ($search_groupby as $key => $val) {
if (!empty($arrayofgroupby[$val])) {
$tmpval = explode('.', $val);
//var_dump($arrayofxaxis[$val]['table']);
if (! in_array($arrayofgroupby[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofgroupby[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
$listoftablesalreadyadded[$arrayofgroupby[$val]['table']] = $arrayofgroupby[$val]['table'];
}
} else {
dol_print_error($db, 'Found a key into search_groupby not found into arrayofgroupby');
}
}
// Add LEFT JOIN for all parent tables mentionned into the Yaxis
//var_dump($arrayofgroupby); var_dump($search_groupby);
foreach ($search_measures as $key => $val) {
if (!empty($arrayofmesures[$val])) {
$tmpval = explode('.', $val);
//var_dump($arrayofxaxis[$val]['table']);
if (! in_array($arrayofmesures[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofmesures[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
$listoftablesalreadyadded[$arrayofmesures[$val]['table']] = $arrayofmesures[$val]['table'];
}
} else {
dol_print_error($db, 'Found a key into search_measures not found into arrayofmesures');
}
}
$sql .= " WHERE 1 = 1";
if ($object->ismultientitymanaged == 1) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
$sql .= " AND t.entity IN (".getEntity($object->element).")";
} }
// Add the where here // Add the where here
$sqlfilters = $search_component_params_hidden; $sqlfilters = $search_component_params_hidden;
@ -588,7 +670,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
print $errormessage; print $errormessage;
} }
} }
$sql .= ' GROUP BY '; $sql .= " GROUP BY ";
foreach ($search_xaxis as $key => $val) { foreach ($search_xaxis as $key => $val) {
if (preg_match('/\-year$/', $val)) { if (preg_match('/\-year$/', $val)) {
$tmpval = preg_replace('/\-year$/', '', $val); $tmpval = preg_replace('/\-year$/', '', $val);
@ -653,7 +735,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
$legend = array(); $legend = array();
foreach ($search_measures as $key => $val) { foreach ($search_measures as $key => $val) {
$legend[] = $langs->trans($arrayofmesures[$val]); $legend[] = $langs->trans($arrayofmesures[$val]['label']);
} }
$useagroupby = (is_array($search_groupby) && count($search_groupby)); $useagroupby = (is_array($search_groupby) && count($search_groupby));
@ -684,7 +766,7 @@ if ($sql) {
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) { if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey]; $xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
} }
$labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->trans("Empty") : $langs->trans("NotDefined"))); $labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->transnoentitiesnoconv("Empty") : $langs->transnoentitiesnoconv("NotDefined")));
if ($oldlabeltouse && ($labeltouse != $oldlabeltouse)) { if ($oldlabeltouse && ($labeltouse != $oldlabeltouse)) {
$xi++; // Increase $xi $xi++; // Increase $xi
@ -878,26 +960,62 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
if ($level == 0) { if ($level == 0) {
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record. // Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
$arrayofmesures[$tablealias.'.count'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count'; $arrayofmesures[$tablealias.'.count'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count',
'position' => 0,
'table' => $object->table_element
);
} }
// Add main fields of object // Add main fields of object
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) { if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>'; $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
$arrayofmesures[$tablealias.'.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>'; 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
$arrayofmesures[$tablealias.'.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>'; 'position' => ($val['position']+($count * 100000)).'.1',
$arrayofmesures[$tablealias.'.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>'; 'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
'position' => ($val['position']+($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
'position' => ($val['position']+($count * 100000)).'.3',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
'position' => ($val['position']+($count * 100000)).'.4',
'table' => $object->table_element
);
} }
} }
// Add extrafields to Measures // Add extrafields to Measures
if ($object->isextrafieldmanaged) { if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) { if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
$arrayofmesures[$tablealias.'e.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>'; $arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array(
$arrayofmesures[$tablealias.'e.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>'; 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
$arrayofmesures[$tablealias.'e.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>'; 'position' => ($val['position']+($count * 100000)).'.1',
$arrayofmesures[$tablealias.'e.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>'; 'table' => $object->table_element
);
$arrayofmesures[$tablealias.'e.'.$key.'-average'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
'position' => ($val['position']+($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'e.'.$key.'-min'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
'position' => ($val['position']+($count * 100000)).'.3',
'table' => $object->table_element
);
$arrayofmesures[$tablealias.'e.'.$key.'-max'] = array(
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
'position' => ($val['position']+($count * 100000)).'.4',
'table' => $object->table_element
);
} }
} }
} }
@ -905,19 +1023,16 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4); $tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1]; $newobject = $tmptype[1];
dol_include_once($tmptype[2]); dol_include_once($tmptype[2]);
if (class_exists($newobject)) { if (class_exists($newobject)) {
$tmpobject = new $newobject($db); $tmpobject = new $newobject($db);
/*var_dump($val['label']); //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
var_dump($tmptype);
var_dump($arrayofmesures);
var_dump('t-'.$key);*/
$count++; $count++;
$arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count); $arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
} else { } else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
} }
} }
} }
@ -1027,7 +1142,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4); $tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1]; $newobject = $tmptype[1];
dol_include_once($tmptype[2]); dol_include_once($tmptype[2]);
if (class_exists($newobject)) { if (class_exists($newobject)) {
@ -1036,7 +1151,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
$count++; $count++;
$arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count); $arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
} else { } else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
} }
} }
} }
@ -1100,14 +1215,31 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
continue; continue;
} }
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1'); $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2'); 'label' => img_picto('', $object->picto,
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3'); 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1',
'table' => $object->table_element
);
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2',
'table' => $object->table_element
);
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3',
'table' => $object->table_element
);
} else { } else {
$arrayofgroupby[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000))); $arrayofgroupby[$tablealias.'.'.$key] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)),
'table' => $object->table_element
);
} }
} }
} }
// Add extrafields to Group by // Add extrafields to Group by
if ($object->isextrafieldmanaged) { if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
@ -1117,26 +1249,28 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) { if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
continue; continue;
} }
$arrayofgroupby[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000)); $arrayofgroupby[$tablealias.'e.'.$key] = array(
'label' => img_picto('', $object->picto,
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
'table' => $object->table_element
);
} }
} }
// Add fields for parent objects // Add fields for parent objects
foreach ($object->fields as $key => $val) { foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) { if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4); $tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) { if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1]; $newobject = $tmptype[1];
dol_include_once($tmptype[2]); dol_include_once($tmptype[2]);
if (class_exists($newobject)) { if (class_exists($newobject)) {
$tmpobject = new $newobject($db); $tmpobject = new $newobject($db);
/*var_dump($val['label']); //var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
var_dump($tmptype);
var_dump($arrayofmesures);
var_dump('t-'.$key);*/
$count++; $count++;
$arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count); $arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
} else { } else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n"; print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
} }
} }
} }

View File

@ -9111,6 +9111,7 @@ function dol_getmypid()
* 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '2,7') to be used to search into a multiselect string '1,2,3,4' * 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '2,7') to be used to search into a multiselect string '1,2,3,4'
* @param integer $nofirstand 1=Do not output the first 'AND' * @param integer $nofirstand 1=Do not output the first 'AND'
* @return string $res The statement to append to the SQL query * @return string $res The statement to append to the SQL query
* @see dolSqlDateFilter()
*/ */
function natural_search($fields, $value, $mode = 0, $nofirstand = 0) function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
{ {

View File

@ -609,7 +609,7 @@ class pdf_eratosthene extends ModelePDFCommandes
} }
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -461,7 +461,7 @@ class pdf_storm extends ModelePDFDeliveryOrder
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -562,7 +562,7 @@ class pdf_espadon extends ModelePdfExpedition
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -383,10 +383,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures
} }
// Define substitution array // Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); // Set tags __...__
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet = $this->get_substitutionarray_object($object, $outputlangs); $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // Set tags object_...
$array_user = $this->get_substitutionarray_user($user, $outputlangs); $array_user = $this->get_substitutionarray_user($user, $outputlangs); // Set tags myuser_...
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array(); $array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array();

View File

@ -477,7 +477,7 @@ class pdf_crabe extends ModelePDFFactures
} }
$tab_top += $extra_under_address_shift; $tab_top += $extra_under_address_shift;
$tab_top_newpage += $extra_under_address_shift; $tab_top_newpage += 0;
// Incoterm // Incoterm
$height_incoterms = 0; $height_incoterms = 0;

View File

@ -460,7 +460,7 @@ class pdf_sponge extends ModelePDFFactures
} }
$tab_top += $extra_under_address_shift; $tab_top += $extra_under_address_shift;
$tab_top_newpage += $extra_under_address_shift; $tab_top_newpage += 0;
// Define heigth of table for lines (for first page) // Define heigth of table for lines (for first page)
@ -685,7 +685,7 @@ class pdf_sponge extends ModelePDFFactures
} }
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -612,19 +612,8 @@ class ImportCsv extends ModeleImports
break; break;
} }
$classinstance = new $class($this->db); $classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, ($key - 1)));
if ($res < 0) { $newval = $res; // We get new value computed.
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
$this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
} else {
$this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
}
$this->errors[$error]['type'] = 'FOREIGNKEY';
$errorforthistable++;
$error++;
} else {
$newval = $arrayrecord[($key - 1)]['val']; //We get new value computed.
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
$newval = price2num($newval); $newval = price2num($newval);
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
@ -716,6 +705,8 @@ class ImportCsv extends ModeleImports
} }
// We add hidden fields (but only if there is at least one field to add into table) // We add hidden fields (but only if there is at least one field to add into table)
// We process here all the fields that were declared into the array ->import_fieldshidden_array of the descriptor file.
// Previously we processed the ->import_fields_array.
if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) {
// Loop on each hidden fields to add them into listfields/listvalues // Loop on each hidden fields to add them into listfields/listvalues
foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { foreach ($objimport->array_import_fieldshidden[0] as $key => $val) {
@ -749,14 +740,13 @@ class ImportCsv extends ModeleImports
break; break;
} }
$classinstance = new $class($this->db); $classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues)); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, ($key - 1)));
if ($res < 0) { $fieldArr = explode('.', $fieldname);
if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict'])); if (count($fieldArr) > 0) {
else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; $fieldname = $fieldArr[1];
$this->errors[$error]['type'] = 'FOREIGNKEY';
$errorforthistable++;
$error++;
} }
$listfields[] = $fieldname;
$listvalues[] = $res;
} }
} }
} else { } else {

View File

@ -654,18 +654,7 @@ class ImportXlsx extends ModeleImports
} }
$classinstance = new $class($this->db); $classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
if ($res < 0) { $newval = $res; // We get new value computed.
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) {
$this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
} else {
$this->errors[$error]['lib'] = 'ErrorFieldValueNotIn';
}
$this->errors[$error]['type'] = 'FOREIGNKEY';
$errorforthistable++;
$error++;
} else {
$newval = $arrayrecord[($key)]['val']; //We get new value computed.
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') {
$newval = price2num($newval); $newval = price2num($newval);
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') {
@ -757,6 +746,8 @@ class ImportXlsx extends ModeleImports
} }
// We add hidden fields (but only if there is at least one field to add into table) // We add hidden fields (but only if there is at least one field to add into table)
// We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file.
// Previously we processed the ->import_fields_array.
if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) {
// Loop on each hidden fields to add them into listfields/listvalues // Loop on each hidden fields to add them into listfields/listvalues
foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { foreach ($objimport->array_import_fieldshidden[0] as $key => $val) {
@ -791,13 +782,12 @@ class ImportXlsx extends ModeleImports
} }
$classinstance = new $class($this->db); $classinstance = new $class($this->db);
$res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues)); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues));
if ($res < 0) { $fieldArr = explode('.', $fieldname);
if (!empty($objimport->array_import_convertvalue[0][$fieldname]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, end($listvalues), 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$fieldname]['dict'])); if (count($fieldArr) > 0) {
else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; $fieldname = $fieldArr[1];
$this->errors[$error]['type'] = 'FOREIGNKEY';
$errorforthistable++;
$error++;
} }
$listfields[] = $fieldname;
$listvalues[] = $res;
} }
} }
} else { } else {

View File

@ -354,8 +354,12 @@ class modAccounting extends DolibarrModules
'b.sens'=>'rule-computeDirection' 'b.sens'=>'rule-computeDirection'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r]=array( $this->import_convertvalue_array[$r]=array(
'b.piece_num' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanValue', 'element' => 'Accountancy'),
'b.numero_compte'=>array('rule'=>'accountingaccount'), 'b.numero_compte'=>array('rule'=>'accountingaccount'),
'b.subledger_account'=>array('rule'=>'accountingaccount'), 'b.subledger_account'=>array('rule'=>'accountingaccount'),
'b.debit' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
'b.credit' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
'b.multicurrency_amount' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'cleanAmount', 'element' => 'Accountancy'),
'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'), 'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'),
'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'), 'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'),
); );

View File

@ -622,7 +622,7 @@ class pdf_cyan extends ModelePDFPropales
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -566,7 +566,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
} }
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }

View File

@ -71,7 +71,9 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA
if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) {
global $mysoc; global $mysoc;
if (empty($disableedit)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?mode=vatforalllines&id='.$object->id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?mode=vatforalllines&id='.$object->id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').'</a>';
}
//print '<script>$(document).ready(function() { $(".clickvatforalllines").click(function() { jQuery(".classvatforalllines").toggle(); }); });</script>'; //print '<script>$(document).ready(function() { $(".clickvatforalllines").click(function() { jQuery(".classvatforalllines").toggle(); }); });</script>';
if (GETPOST('mode', 'aZ09') == 'vatforalllines') { if (GETPOST('mode', 'aZ09') == 'vatforalllines') {
print '<div class="classvatforalllines inline-block nowraponall">'; print '<div class="classvatforalllines inline-block nowraponall">';

View File

@ -172,13 +172,13 @@ if (($line->info_bits & 2) == 2) {
print '<div class="clearboth nowraponall daterangeofline-facturedetrec">'; print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
} }
if ($line->date_start_fill) { if ($line->date_start_fill) {
print '<span class="opacitymedium">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($line->date_start_fill); print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($line->date_start_fill);
} }
if ($line->date_start_fill && $line->date_end_fill) { if ($line->date_start_fill && $line->date_end_fill) {
print ' - '; print ' - ';
} }
if ($line->date_end_fill) { if ($line->date_end_fill) {
print '<span class="opacitymedium">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($line->date_end_fill); print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($line->date_end_fill);
} }
if ($line->date_start_fill || $line->date_end_fill) { if ($line->date_start_fill || $line->date_end_fill) {
print '</div>'; print '</div>';
@ -200,7 +200,16 @@ if (($line->info_bits & 2) == 2) {
} }
} }
//print get_date_range($line->date_start, $line->date_end, $format); // If we show the lines in a context to create a recurring sale invoice
if (basename($_SERVER["PHP_SELF"]) == 'card-rec.php') {
$default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
$default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
print '<div class="clearboth nowraponall daterangeofline-facturedetrec">';
print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateFrom")).'">'.$langs->trans('AutoFillDateFromShort').':</span> '.yn($default_start_fill);
print ' - ';
print '<span class="opacitymedium" title="'.dol_escape_htmltag($langs->trans("AutoFillDateTo")).'">'.$langs->trans('AutoFillDateToShort').':</span> '.yn($default_end_fill);
print '</div>';
}
} }
// Add description in form // Add description in form

View File

@ -106,7 +106,7 @@ class Fournisseur extends Societe
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $conf, $user; global $conf, $user, $hookmanager;
$this->nb = array(); $this->nb = array();
$clause = "WHERE"; $clause = "WHERE";
@ -120,6 +120,12 @@ class Fournisseur extends Societe
} }
$sql .= " ".$clause." s.fournisseur = 1"; $sql .= " ".$clause." s.fournisseur = 1";
$sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.entity IN (".getEntity('societe').")";
// Add where from hooks
if (is_object($hookmanager)) {
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View File

@ -5682,7 +5682,7 @@ class Product extends CommonObject
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $conf, $user, $hookmanager; global $hookmanager;
$this->nb = array(); $this->nb = array();
@ -5692,7 +5692,7 @@ class Product extends CommonObject
// Add where from hooks // Add where from hooks
if (is_object($hookmanager)) { if (is_object($hookmanager)) {
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
} }
$sql .= ' GROUP BY fk_product_type'; $sql .= ' GROUP BY fk_product_type';

View File

@ -260,12 +260,19 @@ if ($search_user) {
if ($search_label) { if ($search_label) {
$sql .= natural_search(array('s.label'), $search_label); $sql .= natural_search(array('s.label'), $search_label);
} }
if (!empty($search_date_start_from) && !empty($search_date_start_to)) { if (!empty($search_date_start_from)) {
$sql .= " AND s.datesp BETWEEN '".$db->idate($search_date_start_from)."' AND '".$db->idate($search_date_start_to)."'"; $sql .= " AND s.datesp >= '".$db->idate($search_date_start_from)."'";
} }
if (!empty($search_date_end_from) && !empty($search_date_end_to)) { if (!empty($search_date_end_from)) {
$sql .= " AND s.dateep BETWEEN '".$db->idate($search_date_end_from)."' AND '".$db->idate($search_date_end_to)."'"; $sql .= " AND s.dateep >= '".$db->idate($search_date_end_from)."'";
} }
if (!empty($search_date_start_to)) {
$sql .= " AND s.datesp <= '".$db->idate($search_date_start_to)."'";
}
if (!empty($search_date_end_to)) {
$sql .= " AND s.dateep <= '".$db->idate($search_date_end_to)."'";
}
if ($search_amount) { if ($search_amount) {
$sql .= natural_search("s.amount", $search_amount, 1); $sql .= natural_search("s.amount", $search_amount, 1);
} }

View File

@ -57,7 +57,7 @@ class Client extends Societe
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $user; global $user, $hookmanager;
$this->nb = array("prospects" => 0, "customers" => 0); $this->nb = array("prospects" => 0, "customers" => 0);
$clause = "WHERE"; $clause = "WHERE";
@ -71,6 +71,12 @@ class Client extends Societe
} }
$sql .= " ".$clause." s.client IN (1,2,3)"; $sql .= " ".$clause." s.client IN (1,2,3)";
$sql .= ' AND s.entity IN ('.getEntity($this->element).')'; $sql .= ' AND s.entity IN ('.getEntity($this->element).')';
// Add where from hooks
if (is_object($hookmanager)) {
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
}
$sql .= " GROUP BY s.client"; $sql .= " GROUP BY s.client";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);